Advertisement
Guest User

licznik

a guest
Oct 13th, 2015
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. #include <Windows.h>
  2. #include "stdio.h"
  3.  
  4. TCHAR Class_Name[] = TEXT("OKNO_TEST");
  5. MSG Komunikat;
  6. char zmienna = 0;
  7. char ilosc[128];
  8. HINSTANCE *hInst;
  9. LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  10. {
  11.  
  12.  
  13. switch (msg) {
  14. case WM_LBUTTONDOWN:
  15. zmienna++;
  16. sprintf(ilosc, "%d", zmienna);
  17. SetWindowTextA(hwnd,ilosc);
  18. break;
  19. case WM_CLOSE:
  20. if((MessageBox(hwnd,TEXT("Czy chcesz wyłączyć okno ?"),TEXT("Pytanie"),MB_OKCANCEL))==IDOK)
  21. DestroyWindow(hwnd);
  22. else break;
  23. case WM_DESTROY:
  24. PostQuitMessage(0);
  25. break;
  26. default:
  27. return DefWindowProcW(hwnd, msg, wParam, lParam);
  28. }
  29. return 0;
  30. }
  31.  
  32. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
  33. {
  34. hInst = &hInstance;
  35. WNDCLASSEX window;
  36. window.cbClsExtra = NULL;
  37. window.cbSize = sizeof(WNDCLASSEX);
  38. window.cbWndExtra = NULL;
  39. window.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
  40. window.hCursor = LoadCursor(*hInst, IDC_ARROW);
  41. window.hIcon = LoadIcon(*hInst, IDI_APPLICATION);
  42. window.hIconSm = NULL;
  43. window.hInstance = *hInst;
  44. window.lpfnWndProc = WndProc;
  45. window.lpszClassName = Class_Name;
  46. window.lpszMenuName = 0;
  47. window.style = NULL;
  48.  
  49. if (!RegisterClassEx(&window)) {
  50. MessageBox(NULL, TEXT("Zarejestrowanie klasy nieudane! =("), TEXT("WARNING"), MB_OK | MB_ICONWARNING);
  51. return 1;
  52. }
  53.  
  54. HWND okno1, okno2;
  55. okno1 = CreateWindowEx(WS_EX_WINDOWEDGE, Class_Name, TEXT("Okno 1"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 400, 400, NULL, NULL, *hInst, NULL);
  56.  
  57. if (okno1 == NULL) {
  58. MessageBox(NULL, TEXT("Stworzenie okna nieudane! =("), TEXT("WARNING"), MB_OK | MB_ICONWARNING);
  59. return 2;
  60. }
  61.  
  62. ShowWindow(okno1, nCmdShow);
  63. UpdateWindow(okno1);
  64.  
  65. while (GetMessage(&Komunikat, NULL, 0, 0)) {
  66.  
  67. TranslateMessage(&Komunikat);
  68. DispatchMessage(&Komunikat);
  69. }
  70. UnregisterClass(Class_Name, *hInst);
  71. return Komunikat.wParam;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement