Advertisement
Guest User

Untitled

a guest
Jun 5th, 2018
396
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.31 KB | None | 0 0
  1. // sdcsdc.cpp : Defines the entry point for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #pragma comment(lib, "winmm.lib")
  6. #include "sdcsdc.h"
  7. #include <mmsystem.h>
  8.  
  9. #define MAX_LOADSTRING 100
  10.  
  11. // Global Variables:
  12. HINSTANCE hInst; // current instance
  13. WCHAR szTitle[MAX_LOADSTRING]; // The title bar text
  14. WCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
  15.  
  16. // Forward declarations of functions included in this code module:
  17. ATOM MyRegisterClass(HINSTANCE hInstance);
  18. BOOL InitInstance(HINSTANCE, int);
  19. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  20. INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
  21.  
  22. int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
  23. _In_opt_ HINSTANCE hPrevInstance,
  24. _In_ LPWSTR lpCmdLine,
  25. _In_ int nCmdShow)
  26. {
  27. UNREFERENCED_PARAMETER(hPrevInstance);
  28. UNREFERENCED_PARAMETER(lpCmdLine);
  29.  
  30. // TODO: Place code here.
  31.  
  32. // Initialize global strings
  33. LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
  34. LoadStringW(hInstance, IDC_SDCSDC, szWindowClass, MAX_LOADSTRING);
  35. MyRegisterClass(hInstance);
  36.  
  37. // Perform application initialization:
  38. if (!InitInstance (hInstance, nCmdShow))
  39. {
  40. return FALSE;
  41. }
  42.  
  43. HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_SDCSDC));
  44.  
  45. MSG msg;
  46.  
  47. // Main message loop:
  48. while (GetMessage(&msg, nullptr, 0, 0))
  49. {
  50. if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
  51. {
  52. TranslateMessage(&msg);
  53. DispatchMessage(&msg);
  54. }
  55. }
  56.  
  57. return (int) msg.wParam;
  58. }
  59.  
  60.  
  61.  
  62. //
  63. // FUNCTION: MyRegisterClass()
  64. //
  65. // PURPOSE: Registers the window class.
  66. //
  67. ATOM MyRegisterClass(HINSTANCE hInstance)
  68. {
  69. WNDCLASSEXW wcex;
  70.  
  71. wcex.cbSize = sizeof(WNDCLASSEX);
  72.  
  73. wcex.style = CS_HREDRAW | CS_VREDRAW;
  74. wcex.lpfnWndProc = WndProc;
  75. wcex.cbClsExtra = 0;
  76. wcex.cbWndExtra = 0;
  77. wcex.hInstance = hInstance;
  78. wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SDCSDC));
  79. wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
  80. wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
  81. wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_SDCSDC);
  82. wcex.lpszClassName = szWindowClass;
  83. wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
  84.  
  85. return RegisterClassExW(&wcex);
  86. }
  87.  
  88. //
  89. // FUNCTION: InitInstance(HINSTANCE, int)
  90. //
  91. // PURPOSE: Saves instance handle and creates main window
  92. //
  93. // COMMENTS:
  94. //
  95. // In this function, we save the instance handle in a global variable and
  96. // create and display the main program window.
  97. //
  98. BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
  99. {
  100. hInst = hInstance; // Store instance handle in our global variable
  101.  
  102. HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
  103. 200, 150, 800, 400, nullptr, nullptr, hInstance, nullptr);
  104.  
  105.  
  106. if (!hWnd)
  107. {
  108. return FALSE;
  109. }
  110.  
  111. ShowWindow(hWnd, nCmdShow);
  112. UpdateWindow(hWnd);
  113.  
  114. return TRUE;
  115. }
  116.  
  117. //
  118. // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
  119. //
  120. // PURPOSE: Processes messages for the main window.
  121. //
  122. // WM_COMMAND - process the application menu
  123. // WM_PAINT - Paint the main window
  124. // WM_DESTROY - post a quit message and return
  125. //
  126. //
  127.  
  128. HWND hEdit;
  129. HWND hQ, hW, hE, hR, hT, hY, hA, hS, hD, hF, hG, hH, hZ, hX, hC, hV, hB, hN;
  130. void CreateAllButtons(HWND hWParent)
  131. {
  132.  
  133.  
  134. hQ=CreateWindow(L"button",L"Q", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 30, 30, 80, 60, hWParent, (HMENU)1, hInst, nullptr);
  135. hW=CreateWindow(L"button", L"W", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 140, 30, 80, 60, hWParent, (HMENU)2, hInst, nullptr);
  136. hE=CreateWindow(L"button", L"E", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 270, 30, 80, 60, hWParent, (HMENU)3, hInst, nullptr);
  137. hR=CreateWindow(L"button", L"R", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 400, 30, 80, 60, hWParent, (HMENU)4, hInst, nullptr);
  138. hT=CreateWindow(L"button", L"T", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 530, 30, 80, 60, hWParent, (HMENU)5, hInst, nullptr);
  139. hY=CreateWindow(L"button", L"Y", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 660, 30, 80, 60, hWParent, (HMENU)6, hInst, nullptr);
  140.  
  141.  
  142. hA=CreateWindow(L"button", L"A", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 30, 130, 80, 60, hWParent, (HMENU)7, hInst, nullptr);
  143. hS=CreateWindow(L"button", L"S", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 140, 130, 80, 60, hWParent, (HMENU)8, hInst, nullptr);
  144. hD=CreateWindow(L"button", L"D", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 270, 130, 80, 60, hWParent, (HMENU)9, hInst, nullptr);
  145. hF=CreateWindow(L"button", L"F", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 400, 130, 80, 60, hWParent, (HMENU)10, hInst, nullptr);
  146. hG=CreateWindow(L"button", L"G", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 530, 130, 80, 60, hWParent, (HMENU)11, hInst, nullptr);
  147. hH=CreateWindow(L"button", L"H", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 660, 130, 80, 60, hWParent, (HMENU)12, hInst, nullptr);
  148.  
  149. hZ=CreateWindow(L"button", L"Z", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 30, 230, 80, 60, hWParent, (HMENU)13, hInst, nullptr);
  150. hX=CreateWindow(L"button", L"X", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 140, 230, 80, 60, hWParent, (HMENU)14, hInst, nullptr);
  151. hC=CreateWindow(L"button", L"C", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 270, 230, 80, 60, hWParent, (HMENU)15, hInst, nullptr);
  152. hV=CreateWindow(L"button", L"V", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 400, 230, 80, 60, hWParent, (HMENU)16, hInst, nullptr);
  153. hB=CreateWindow(L"button", L"B", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 530, 230, 80, 60, hWParent, (HMENU)17, hInst, nullptr);
  154. hN=CreateWindow(L"button", L"N", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 660, 230, 80, 60, hWParent, (HMENU)18, hInst, nullptr);
  155.  
  156.  
  157. //hEdit = CreateWindow("edit", "0", WS_CHILD | WS_VISIBLE | ES_RIGHT, 10, 10, 180, 20, hWParent, (HMENU)20, hInst, nullptr);
  158.  
  159.  
  160. }
  161.  
  162.  
  163.  
  164. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  165. {
  166. int wmId = LOWORD(wParam);
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173. switch (message)
  174. {
  175.  
  176. case WM_CREATE:
  177. CreateAllButtons(hWnd);
  178. break;
  179.  
  180. case WM_COMMAND:
  181. {
  182.  
  183. // Parse the menu selections:
  184. switch (wmId)
  185. {
  186. case IDM_ABOUT:
  187. DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
  188. break;
  189. case IDM_EXIT:
  190. DestroyWindow(hWnd);
  191. break;
  192. default:
  193. SetFocus(hWnd);
  194. return DefWindowProc(hWnd, message, wParam, lParam);
  195. }
  196.  
  197. }
  198. break;
  199.  
  200. case WM_PAINT:
  201. {
  202. PAINTSTRUCT ps;
  203. HDC hdc = BeginPaint(hWnd, &ps);
  204. // TODO: Add any drawing code that uses hdc here...
  205. EndPaint(hWnd, &ps);
  206. }
  207. break;
  208.  
  209. case WM_DESTROY:
  210. PostQuitMessage(0);
  211. break;
  212.  
  213.  
  214. //PlaySound((LPCSTR)"Fat Kick.wav", NULL, SND_SYNC);
  215. //PlaySound(TEXT("Fat Kick.wav"), NULL, SND_ALIAS);
  216.  
  217.  
  218.  
  219. case WM_KEYDOWN:
  220.  
  221. switch (wmId)
  222. {
  223.  
  224. case 'Q':
  225. {
  226. SendMessage(hQ, WM_LBUTTONDOWN, 0, 0);
  227. PlaySound(TEXT("1.wav"), NULL, SND_ALIAS);
  228. SendMessage(hQ, WM_LBUTTONUP, 0, 0);
  229. }
  230. break;
  231.  
  232. case 'W':
  233. {
  234. SendMessage(hW, WM_LBUTTONDOWN, 0, 0);
  235. PlaySound(TEXT("2.wav"), NULL, SND_ALIAS);
  236.  
  237. SendMessage(hW, WM_LBUTTONUP, 0, 0);
  238. }
  239. break;
  240.  
  241. case 'E':
  242. {
  243. if (wParam == 'E')SendMessage(hE, WM_LBUTTONDOWN, 0, 0);
  244. PlaySound(TEXT("3.wav"), NULL, SND_ALIAS);
  245.  
  246. if (wParam == 'E')SendMessage(hE, WM_LBUTTONUP, 0, 0);
  247. }
  248. break;
  249. case 'R':
  250. {
  251. if (wParam == 'R')SendMessage(hR, WM_LBUTTONDOWN, 0, 0);
  252. PlaySound(TEXT("4.wav"), NULL, SND_ALIAS);
  253. Sleep(100);
  254. if (wParam == 'R')SendMessage(hR, WM_LBUTTONUP, 0, 0);
  255. }
  256. break;
  257.  
  258. case 'T':
  259. {
  260. if (wParam == 'T')SendMessage(hT, WM_LBUTTONDOWN, 0, 0);
  261. PlaySound(TEXT("5.wav"), NULL, SND_ALIAS);
  262. Sleep(100);
  263. if (wParam == 'T')SendMessage(hT, WM_LBUTTONUP, 0, 0);
  264. }
  265. break;
  266.  
  267. case 'Y':
  268. {
  269. if (wParam == 'Y')SendMessage(hY, WM_LBUTTONDOWN, 0, 0);
  270. PlaySound(TEXT("6.wav"), NULL, SND_ALIAS);
  271. Sleep(100);
  272. if (wParam == 'Y')SendMessage(hY, WM_LBUTTONUP, 0, 0);
  273. }
  274. break;
  275.  
  276. case 'A':
  277. {
  278. if (wParam == 'A')SendMessage(hA, WM_LBUTTONDOWN, 0, 0);
  279. PlaySound(TEXT("7.wav"), NULL, SND_ALIAS);
  280. Sleep(100);
  281. if (wParam == 'A')SendMessage(hA, WM_LBUTTONUP, 0, 0);
  282. }
  283. break;
  284.  
  285. case 'S':
  286. {
  287. if (wParam == 'S')SendMessage(hS, WM_LBUTTONDOWN, 0, 0);
  288. PlaySound(TEXT("8.wav"), NULL, SND_ALIAS);
  289. Sleep(100);
  290. if (wParam == 'S')SendMessage(hS, WM_LBUTTONUP, 0, 0);
  291. }
  292. break;
  293.  
  294. case 'D':
  295. {
  296. if (wParam == 'D')SendMessage(hD, WM_LBUTTONDOWN, 0, 0);
  297. PlaySound(TEXT("9.wav"), NULL, SND_ALIAS);
  298. Sleep(100);
  299. if (wParam == 'D')SendMessage(hD, WM_LBUTTONUP, 0, 0);
  300. }
  301. break;
  302.  
  303. case 'F':
  304. {
  305. if (wParam == 'F')SendMessage(hF, WM_LBUTTONDOWN, 0, 0);
  306. PlaySound(TEXT("10.wav"), NULL, SND_ALIAS);
  307. Sleep(100);
  308. if (wParam == 'F')SendMessage(hF, WM_LBUTTONUP, 0, 0);
  309. }
  310. break;
  311.  
  312. case 'G':
  313. {
  314. if (wParam == 'G')SendMessage(hG, WM_LBUTTONDOWN, 0, 0);
  315. Sleep(100);
  316. if (wParam == 'G')SendMessage(hG, WM_LBUTTONUP, 0, 0);
  317. }
  318. break;
  319.  
  320. case 'H':
  321. {
  322. if (wParam == 'H')SendMessage(hH, WM_LBUTTONDOWN, 0, 0);
  323. Sleep(100);
  324. if (wParam == 'H')SendMessage(hH, WM_LBUTTONUP, 0, 0);
  325. }
  326. break;
  327.  
  328. case 'Z':
  329. {
  330. if (wParam == 'Z')SendMessage(hZ, WM_LBUTTONDOWN, 0, 0);
  331. Sleep(100);
  332. if (wParam == 'Z')SendMessage(hZ, WM_LBUTTONUP, 0, 0);
  333. }
  334. break;
  335.  
  336. case 'X':
  337. {
  338. if (wParam == 'X')SendMessage(hX, WM_LBUTTONDOWN, 0, 0);
  339. Sleep(100);
  340. if (wParam == 'X')SendMessage(hX, WM_LBUTTONUP, 0, 0);
  341. }
  342. break;
  343.  
  344. case 'C':
  345. {
  346. if (wParam == 'C')SendMessage(hC, WM_LBUTTONDOWN, 0, 0);
  347. Sleep(100);
  348. if (wParam == 'C')SendMessage(hC, WM_LBUTTONUP, 0, 0);
  349. }
  350. break;
  351.  
  352. case 'V':
  353. {
  354. if (wParam == 'V')SendMessage(hV, WM_LBUTTONDOWN, 0, 0);
  355. Sleep(100);
  356. if (wParam == 'V')SendMessage(hV, WM_LBUTTONUP, 0, 0);
  357. }
  358. break;
  359.  
  360.  
  361. case 'B':
  362. {
  363. if (wParam == 'B')SendMessage(hB, WM_LBUTTONDOWN, 0, 0);
  364. Sleep(100);
  365. if (wParam == 'B')SendMessage(hB, WM_LBUTTONUP, 0, 0);
  366. }
  367. break;
  368.  
  369. case 'N':
  370. {
  371. if (wParam == 'N')SendMessage(hN, WM_LBUTTONDOWN, 0, 0);
  372. Sleep(100);
  373. if (wParam == 'N')SendMessage(hN, WM_LBUTTONUP, 0, 0);
  374. }
  375. break;
  376.  
  377. }
  378. break;
  379.  
  380. /*switch (wmId)
  381. {
  382. case 'N':
  383. {
  384. if (wParam == 'N')SendMessage(hN, WM_LBUTTONDOWN, 0, 0);
  385. PlaySound(TEXT("Clink Hit.wav"), NULL, SND_ALIAS);
  386. Sleep(100);
  387. if (wParam == 'N')SendMessage(hN, WM_LBUTTONUP, 0, 0);
  388. }
  389. break;
  390. }*/
  391.  
  392.  
  393.  
  394.  
  395. default:
  396.  
  397. return DefWindowProc(hWnd, message, wParam, lParam);
  398. break;
  399. }
  400.  
  401. return 0;
  402.  
  403.  
  404. }
  405.  
  406. // Message handler for about box.
  407. INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  408. {
  409. UNREFERENCED_PARAMETER(lParam);
  410. switch (message)
  411. {
  412. case WM_INITDIALOG:
  413. return (INT_PTR)TRUE;
  414.  
  415. case WM_COMMAND:
  416. if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
  417. {
  418. EndDialog(hDlg, LOWORD(wParam));
  419. return (INT_PTR)TRUE;
  420. }
  421. break;
  422. }
  423. return (INT_PTR)FALSE;
  424. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement