Guest User

Untitled

a guest
Jan 20th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.48 KB | None | 0 0
  1. #include <windows.h>
  2.  
  3. #define p1 101
  4. #define p2 102
  5. #define p3 103
  6.  
  7. /* Declare Windows procedure */
  8. LRESULT CALLBACK WindowProcedure1 (HWND, UINT, WPARAM, LPARAM);
  9. LRESULT CALLBACK WindowProcedure2 (HWND, UINT, WPARAM, LPARAM);
  10. LRESULT CALLBACK WindowProcedure3 (HWND, UINT, WPARAM, LPARAM);
  11. LRESULT CALLBACK tworzPrzycisk(HWND);
  12. HWND global;
  13. HWND przycisk1;
  14. HWND przycisk2;
  15. HWND przycisk3;
  16. /* Make the class name into a global variable */
  17. char szClassName1[ ] = "WindowsApp1";
  18. char szClassName2[ ] = "WindowsApp2";
  19. char szClassName3[ ] = "WindowsApp3";
  20. HINSTANCE hInstance;
  21. int WINAPI WinMain (HINSTANCE hThisInstance,
  22. HINSTANCE hPrevInstance,
  23. LPSTR lpszArgument,
  24. int nFunsterStil)
  25.  
  26. {
  27. hInstance = hThisInstance;
  28.  
  29. HWND hwnd1;
  30. HWND hwnd2;
  31. HWND hwnd3; /* This is the handle for our window */
  32. MSG messages; /* Here messages to the application are saved */
  33. WNDCLASSEX wincl1;
  34. WNDCLASSEX wincl2;
  35. WNDCLASSEX wincl3; /* Data structure for the windowclass */
  36.  
  37. /* The Window structure */
  38. wincl1.hInstance = hThisInstance;
  39. wincl1.lpszClassName = szClassName1;
  40. wincl1.lpfnWndProc = WindowProcedure1; /* This function is called by windows */
  41. wincl1.style = CS_DBLCLKS; /* Catch double-clicks */
  42. wincl1.cbSize = sizeof (WNDCLASSEX);
  43. wincl2.hInstance = hThisInstance;
  44. wincl2.lpszClassName = szClassName2;
  45. wincl2.lpfnWndProc = WindowProcedure2; /* This function is called by windows */
  46. wincl2.style = CS_DBLCLKS; /* Catch double-clicks */
  47. wincl2.cbSize = sizeof (WNDCLASSEX);
  48. wincl3.hInstance = hThisInstance;
  49. wincl3.lpszClassName = szClassName3;
  50. wincl3.lpfnWndProc = WindowProcedure3; /* This function is called by windows */
  51. wincl3.style = CS_DBLCLKS; /* Catch double-clicks */
  52. wincl3.cbSize = sizeof (WNDCLASSEX);
  53.  
  54. /* Use default icon and mouse-pointer */
  55. wincl1.hIcon = LoadIcon (NULL, IDI_APPLICATION);
  56. wincl1.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
  57. wincl1.hCursor = LoadCursor (NULL, IDC_ARROW);
  58. wincl1.lpszMenuName = NULL; /* No menu */
  59. wincl1.cbClsExtra = 0; /* No extra bytes after the window class */
  60. wincl1.cbWndExtra = 0;
  61. wincl2.hIcon = LoadIcon (NULL, IDI_APPLICATION);
  62. wincl2.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
  63. wincl2.hCursor = LoadCursor (NULL, IDC_ARROW);
  64. wincl2.lpszMenuName = NULL; /* No menu */
  65. wincl2.cbClsExtra = 0; /* No extra bytes after the window class */
  66. wincl2.cbWndExtra = 0;
  67. wincl3.hIcon = LoadIcon (NULL, IDI_APPLICATION);
  68. wincl3.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
  69. wincl3.hCursor = LoadCursor (NULL, IDC_ARROW);
  70. wincl3.lpszMenuName = NULL; /* No menu */
  71. wincl3.cbClsExtra = 0; /* No extra bytes after the window class */
  72. wincl3.cbWndExtra = 0; /* structure or the window instance */
  73. /* Use Windows's default color as the background of the window */
  74. wincl1.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
  75. wincl2.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
  76. wincl3.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
  77.  
  78. /* Register the window class, and if it fails quit the program */
  79. if (!RegisterClassEx (&wincl1))
  80. return 0;
  81. if (!RegisterClassEx (&wincl2))
  82. return 0;
  83. if (!RegisterClassEx (&wincl3))
  84. return 0;
  85.  
  86. /* The class is registered, let's create the program*/
  87. hwnd1 = CreateWindowEx (
  88. 0, /* Extended possibilites for variation */
  89. szClassName1, /* Classname */
  90. "Program nr.1", /* Title Text */
  91. WS_OVERLAPPEDWINDOW, /* default window */
  92. 100, /* Windows decides the position */
  93. 100, /* where the window ends up on the screen */
  94. 544, /* The programs width */
  95. 375, /* and height in pixels */
  96. HWND_DESKTOP, /* The window is a child-window to desktop */
  97. NULL, /* No menu */
  98. hThisInstance, /* Program Instance handler */
  99. NULL /* No Window Creation data */
  100. );
  101. /* Make the window visible on the screen */
  102. ShowWindow (hwnd1, nFunsterStil);
  103. hwnd2 = CreateWindowEx (
  104. 0, /* Extended possibilites for variation */
  105. szClassName2, /* Classname */
  106. "Program nr.2", /* Title Text */
  107. WS_OVERLAPPEDWINDOW, /* default window */
  108. 300, /* Windows decides the position */
  109. 200, /* where the window ends up on the screen */
  110. 544, /* The programs width */
  111. 375, /* and height in pixels */
  112. HWND_DESKTOP, /* The window is a child-window to desktop */
  113. NULL, /* No menu */
  114. hThisInstance, /* Program Instance handler */
  115. NULL /* No Window Creation data */
  116. );
  117.  
  118. ShowWindow (hwnd2, nFunsterStil);
  119. hwnd3 = CreateWindowEx (
  120. 0, /* Extended possibilites for variation */
  121. szClassName3, /* Classname */
  122. "Program nr.3", /* Title Text */
  123. WS_OVERLAPPEDWINDOW, /* default window */
  124. 500, /* Windows decides the position */
  125. 300, /* where the window ends up on the screen */
  126. 544, /* The programs width */
  127. 375, /* and height in pixels */
  128. HWND_DESKTOP, /* The window is a child-window to desktop */
  129. NULL, /* No menu */
  130. hThisInstance, /* Program Instance handler */
  131. NULL /* No Window Creation data */
  132. );
  133. global = hwnd2;
  134. /* Make the window visible on the screen */
  135. ShowWindow (hwnd3, nFunsterStil);
  136. /* Run the message loop. It will run until GetMessage() returns 0 */
  137. while (GetMessage (&messages, NULL, 0, 0))
  138. {
  139. /* Translate virtual-key messages into character messages */
  140. TranslateMessage(&messages);
  141. /* Send message to WindowProcedure */
  142. DispatchMessage(&messages);
  143. }
  144.  
  145. /* The program return-value is 0 - The value that PostQuitMessage() gave */
  146. return messages.wParam;
  147. }
  148.  
  149.  
  150. /* This function is called by the Windows function DispatchMessage() */
  151.  
  152. LRESULT CALLBACK WindowProcedure1 (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  153. {
  154. switch (message) /* handle the messages */
  155. {
  156. case WM_DESTROY:
  157. if(hwnd == global)
  158. {
  159. PostQuitMessage (0); /* send a WM_QUIT to the message queue */
  160. break;
  161. }
  162. default: /* for messages that we don't deal with */
  163. return DefWindowProc (hwnd, message, wParam, lParam);
  164. case WM_CHAR:
  165. switch(wParam)
  166. {
  167. case '1':
  168. PostQuitMessage (0);
  169. break;
  170. }
  171.  
  172. }
  173.  
  174. return 0;
  175. }
  176. LRESULT CALLBACK WindowProcedure2 (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  177. {
  178. switch (message) /* handle the messages */
  179. {
  180. case WM_DESTROY:
  181. if(hwnd == global)
  182. {
  183. PostQuitMessage (0); /* send a WM_QUIT to the message queue */
  184. break;
  185. }
  186. default: /* for messages that we don't deal with */
  187. return DefWindowProc (hwnd, message, wParam, lParam);
  188. case WM_CHAR:
  189. switch(wParam)
  190. {
  191. case '2':
  192. PostQuitMessage (0);
  193. break;
  194. }
  195. }
  196.  
  197. return 0;
  198. }
  199. LRESULT CALLBACK WindowProcedure3 (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  200. {
  201. switch (message) /* handle the messages */
  202. {
  203. case WM_DESTROY:
  204. if(hwnd == global)
  205. {
  206. PostQuitMessage (0); /* send a WM_QUIT to the message queue */
  207. break;
  208. }
  209. default: /* for messages that we don't deal with */
  210. return DefWindowProc (hwnd, message, wParam, lParam);
  211. case WM_CHAR:
  212. switch(wParam)
  213. {
  214. case '3':
  215. PostQuitMessage (0);
  216. break;
  217. }
  218. case WM_CREATE:
  219. tworzPrzycisk(hwnd);
  220. break;
  221. case WM_COMMAND:
  222. switch(wParam)
  223. case p1:
  224. PostQuitMessage (0);
  225. break;
  226. }
  227.  
  228. return 0;
  229. }
  230.  
  231. LRESULT CALLBACK tworzPrzycisk(HWND hwnd)
  232. {
  233. przycisk1 = CreateWindowEx (
  234. 0, /* Extended possibilites for variation */
  235. "BUTTON", /* Classname */
  236. "Przycisk1", /* Title Text */
  237. WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, /* default window */
  238. 50, /* Windows decides the position */
  239. 50, /* where the window ends up on the screen */
  240. 100, /* The programs width */
  241. 50, /* and height in pixels */
  242. hwnd, /* The window is a child-window to desktop */
  243. (HMENU)p1, /* No menu */
  244. hInstance, /* Program Instance handler */
  245. NULL /* No Window Creation data */
  246. );
  247. przycisk2 = CreateWindowEx (
  248. 0, /* Extended possibilites for variation */
  249. "BUTTON", /* Classname */
  250. "Przycisk2", /* Title Text */
  251. WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON, /* default window */
  252. 150, /* Windows decides the position */
  253. 150, /* where the window ends up on the screen */
  254. 100, /* The programs width */
  255. 50, /* and height in pixels */
  256. hwnd, /* The window is a child-window to desktop */
  257. (HMENU)p2, /* No menu */
  258. hInstance, /* Program Instance handler */
  259. NULL /* No Window Creation data */
  260. );
  261. przycisk3 = CreateWindowEx (
  262. 0, /* Extended possibilites for variation */
  263. "BUTTON", /* Classname */
  264. "Przycisk3", /* Title Text */
  265. WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, /* default window */
  266. 250, /* Windows decides the position */
  267. 250, /* where the window ends up on the screen */
  268. 100, /* The programs width */
  269. 50, /* and height in pixels */
  270. hwnd, /* The window is a child-window to desktop */
  271. (HMENU)p3, /* No menu */
  272. hInstance, /* Program Instance handler */
  273. NULL /* No Window Creation data */
  274. );
  275. }
Add Comment
Please, Sign In to add comment