Advertisement
Guest User

okno

a guest
Nov 1st, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. // Window - pierwsze własne okno
  2.  
  3. #include <string>
  4. #include <windows.h>
  5. #include <ctime>
  6. #include <iostream>
  7. #include <sstream>
  8.  
  9.  
  10. using namespace std;
  11.  
  12. // nazwa klasy okna
  13.  
  14. string g_strKlasaOkna = "od0dogk_Window";
  15.  
  16.  
  17. //--------------------------procedura zdarzeniowa okna----------------------------------
  18. LRESULT CALLBACK WindowEventProc(HWND hWindow, UINT uMsg, WPARAM wParam, LPARAM lParam)
  19. {
  20. switch (uMsg)
  21. {
  22. case WM_DESTROY:
  23. //kończy program
  24. PostQuitMessage(0);
  25. return 0;
  26. }
  27. return DefWindowProc(hWindow, uMsg, wParam, lParam);
  28.  
  29. }
  30.  
  31. int random(int nMin, int nMax) { return rand() % nMax + nMin; }
  32.  
  33. // --------------------------funkcja WinMain()-------------------------------------------
  34.  
  35.  
  36. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow)
  37. {
  38. // rejestrujemy klasę okna
  39. WNDCLASSEX KlasaOkna;
  40.  
  41. // wypełniamy strukturę WNDCLASSEX
  42. ZeroMemory (&KlasaOkna, sizeof(WNDCLASSEX));
  43. KlasaOkna.cbSize = sizeof(WNDCLASSEX);
  44. KlasaOkna.hInstance = hInstance;
  45. KlasaOkna.lpfnWndProc = WindowEventProc;
  46. KlasaOkna.lpszClassName = g_strKlasaOkna.c_str();
  47. KlasaOkna.hCursor = LoadCursor(NULL, IDC_ARROW);
  48. KlasaOkna.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  49. KlasaOkna.hbrBackground = (HBRUSH) COLOR_WINDOW;
  50.  
  51. // rejestrujemy klasę okna
  52. RegisterClassEx (&KlasaOkna);
  53.  
  54. /* tworzymy okno */
  55.  
  56. // tworzymy okno funkcją CreateWindowEx
  57. HWND hOkno;
  58. hOkno = CreateWindowEx(NULL, // rozszerzony styl
  59. g_strKlasaOkna.c_str(), // klasa okna
  60. "Pierwsze okno", // tekst na p. tytułu
  61. WS_OVERLAPPEDWINDOW, // styl okna
  62. CW_USEDEFAULT, // współrzędna X
  63. CW_USEDEFAULT, // współrzędna Y
  64. CW_USEDEFAULT, // szerokość
  65. CW_USEDEFAULT, // wysokość
  66. NULL, // okno nadrzędne
  67. NULL, // menu
  68. hInstance, // instancjs aplikacji
  69. NULL); // dodatkowe dane
  70.  
  71. // pokazujemy nasze okno
  72. ShowWindow (hOkno, nCmdShow);
  73.  
  74. /*srand (static_cast<unsigned int>(time(NULL)));
  75. int b = random (1,6);*/
  76.  
  77. int liczba;
  78.  
  79. std::stringstream ss;
  80. ss << liczba;
  81.  
  82. std::string liczbaString = liczba.str();
  83. MessageBox(NULL, liczbaString.c_str(), "Wiadomość", 0);
  84.  
  85.  
  86. /* pętla komunikatów */
  87.  
  88. MSG msgKomunikat;
  89. while (GetMessage(&msgKomunikat, NULL, 0, 0))
  90. {
  91. TranslateMessage (&msgKomunikat);
  92. DispatchMessage (&msgKomunikat);
  93. }
  94.  
  95. // zwracamy kod wyjścia
  96. return static_cast<int>(msgKomunikat.wParam);
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement