Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.66 KB | None | 0 0
  1. // KontrolnoPS2ro.cpp : Defines the entry point for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "KontrolnoPS2ro.h"
  6. #include "Resource.h"
  7. #include <CommCtrl.h>
  8.  
  9.  
  10. #define MAX_LOADSTRING 100
  11. #define TIMER 100
  12. int step = 3;
  13.  
  14. // Global Variables:
  15. HINSTANCE hInst; // current instance
  16. WCHAR szTitle[MAX_LOADSTRING]; // The title bar text
  17. WCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
  18.  
  19. // Forward declarations of functions included in this code module:
  20. ATOM MyRegisterClass(HINSTANCE hInstance);
  21. BOOL InitInstance(HINSTANCE, int);
  22. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  23. INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
  24. INT_PTR CALLBACK EventMenu(HWND, UINT, WPARAM, LPARAM);
  25.  
  26.  
  27. int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
  28. _In_opt_ HINSTANCE hPrevInstance,
  29. _In_ LPWSTR lpCmdLine,
  30. _In_ int nCmdShow)
  31. {
  32. UNREFERENCED_PARAMETER(hPrevInstance);
  33. UNREFERENCED_PARAMETER(lpCmdLine);
  34.  
  35. // TODO: Place code here.
  36.  
  37. // Initialize global strings
  38. LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
  39. LoadStringW(hInstance, IDC_KONTROLNOPS2RO, szWindowClass, MAX_LOADSTRING);
  40. MyRegisterClass(hInstance);
  41.  
  42. // Perform application initialization:
  43. if (!InitInstance (hInstance, nCmdShow))
  44. {
  45. return FALSE;
  46. }
  47.  
  48. HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_KONTROLNOPS2RO));
  49.  
  50. MSG msg;
  51.  
  52. // Main message loop:
  53. while (GetMessage(&msg, nullptr, 0, 0))
  54. {
  55. if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
  56. {
  57. TranslateMessage(&msg);
  58. DispatchMessage(&msg);
  59. }
  60. }
  61.  
  62. return (int) msg.wParam;
  63. }
  64.  
  65.  
  66.  
  67. //
  68. // FUNCTION: MyRegisterClass()
  69. //
  70. // PURPOSE: Registers the window class.
  71. //
  72. ATOM MyRegisterClass(HINSTANCE hInstance)
  73. {
  74. WNDCLASSEXW wcex;
  75.  
  76. wcex.cbSize = sizeof(WNDCLASSEX);
  77.  
  78. wcex.style = CS_HREDRAW | CS_VREDRAW;
  79. wcex.lpfnWndProc = WndProc;
  80. wcex.cbClsExtra = 0;
  81. wcex.cbWndExtra = 0;
  82. wcex.hInstance = hInstance;
  83. wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_KONTROLNOPS2RO));
  84. wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
  85. wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
  86. wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_KONTROLNOPS2RO);
  87. wcex.lpszClassName = szWindowClass;
  88. wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
  89.  
  90. return RegisterClassExW(&wcex);
  91. }
  92.  
  93. //
  94. // FUNCTION: InitInstance(HINSTANCE, int)
  95. //
  96. // PURPOSE: Saves instance handle and creates main window
  97. //
  98. // COMMENTS:
  99. //
  100. // In this function, we save the instance handle in a global variable and
  101. // create and display the main program window.
  102. //
  103. BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
  104. {
  105. hInst = hInstance; // Store instance handle in our global variable
  106.  
  107. HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
  108. CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr);
  109.  
  110. if (!hWnd)
  111. {
  112. return FALSE;
  113. }
  114.  
  115. ShowWindow(hWnd, nCmdShow);
  116. UpdateWindow(hWnd);
  117.  
  118. return TRUE;
  119. }
  120.  
  121. //
  122. // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
  123. //
  124. // PURPOSE: Processes messages for the main window.
  125. //
  126. // WM_COMMAND - process the application menu
  127. // WM_PAINT - Paint the main window
  128. // WM_DESTROY - post a quit message and return
  129. //
  130. //
  131. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  132. {
  133. switch (message)
  134. {
  135. case WM_COMMAND:
  136. {
  137. int wmId = LOWORD(wParam);
  138. // Parse the menu selections:
  139. switch (wmId)
  140. {
  141. case IDM_CALC:
  142. DialogBox(hInst, MAKEINTRESOURCE(IDD_CALC), hWnd, EventMenu);
  143. break;
  144. case IDM_ABOUT:
  145. DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
  146. break;
  147. case IDM_EXIT:
  148. DestroyWindow(hWnd);
  149. break;
  150. default:
  151. return DefWindowProc(hWnd, message, wParam, lParam);
  152. }
  153. }
  154. break;
  155. case WM_PAINT:
  156. {
  157. PAINTSTRUCT ps;
  158. HDC hdc = BeginPaint(hWnd, &ps);
  159. // TODO: Add any drawing code that uses hdc here...
  160. EndPaint(hWnd, &ps);
  161. }
  162. break;
  163. case WM_DESTROY:
  164. PostQuitMessage(0);
  165. break;
  166. default:
  167. return DefWindowProc(hWnd, message, wParam, lParam);
  168. }
  169. return 0;
  170. }
  171.  
  172. // Message handler for about box.
  173. INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  174. {
  175. UNREFERENCED_PARAMETER(lParam);
  176. switch (message)
  177. {
  178. case WM_INITDIALOG:
  179. return (INT_PTR)TRUE;
  180.  
  181. case WM_COMMAND:
  182. if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
  183. {
  184. EndDialog(hDlg, LOWORD(wParam));
  185. return (INT_PTR)TRUE;
  186. }
  187. break;
  188. }
  189. return (INT_PTR)FALSE;
  190. }
  191.  
  192. INT_PTR CALLBACK EventMenu(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  193. {
  194. UNREFERENCED_PARAMETER(lParam);
  195. int time = 100;
  196. switch (message)
  197. {
  198. case WM_INITDIALOG:
  199.  
  200. SendDlgItemMessage(hDlg, IDC_PROGRESS1, PBM_SETSTEP, step, 0);
  201. SendDlgItemMessage(hDlg, IDC_PROGRESS1, PBM_SETRANGE, 0, MAKEWPARAM(0, 100));
  202. return (INT_PTR)TRUE;
  203.  
  204. case WM_COMMAND:
  205. {
  206. if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
  207. {
  208. EndDialog(hDlg, LOWORD(wParam));
  209. return (INT_PTR)TRUE;
  210. }
  211. if (LOWORD(wParam) == IDC_BUTTON1)
  212. {
  213. int a, b, c;
  214. a = GetDlgItemInt(hDlg, IDC_MOUSEX, NULL, true);
  215. b = GetDlgItemInt(hDlg, IDC_MOUSEY, NULL, true);
  216.  
  217. c = a * b;
  218.  
  219. SetTimer(hDlg, TIMER, 20, NULL);
  220.  
  221.  
  222. }
  223.  
  224. break;
  225. }
  226.  
  227. case WM_LBUTTONDOWN:
  228. {
  229. if (wParam & MK_SHIFT)
  230. {
  231. int lx = LOWORD(lParam);
  232. int ly = HIWORD(lParam);
  233. SetDlgItemInt(hDlg, IDC_MOUSEX, lx, TRUE);
  234. SetDlgItemInt(hDlg, IDC_MOUSEY, ly, TRUE);
  235. }break;
  236. }
  237.  
  238. case WM_TIMER:
  239. // if Progress 1 is full
  240. if (SendDlgItemMessage(hDlg, IDC_PROGRESS1, PBM_GETPOS, 0, 0) >= 100)
  241. {
  242. SetDlgItemInt(hDlg, IDC_RESULT, c, true);
  243.  
  244. }
  245. else if (SendDlgItemMessage(hDlg, IDC_PROGRESS1, PBM_GETPOS, 0, 0) < 100 && x)
  246. {
  247. MessageBox(hDlg, "Fuck", "this shit", MB_OK | MB_ICONERROR);
  248. }
  249. else
  250. {
  251. SendDlgItemMessage(hDlg, IDC_PROGRESS1, PBM_SETSTEP, step, 0);
  252. SendDlgItemMessage(hDlg, IDC_PROGRESS1, PBM_STEPIT, 0, 0);
  253. }
  254.  
  255. break;
  256. }
  257. return (INT_PTR)FALSE;
  258. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement