From 13bc4027ff8e9a98eb2e1b0473830ca3118beb62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20=22Magnetic-Fox=22=20W=C4=99grzyn?= Date: Sun, 10 Sep 2023 13:30:38 +0200 Subject: [PATCH] Update main.cpp --- main.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/main.cpp b/main.cpp index f540be8..790f8a7 100644 --- a/main.cpp +++ b/main.cpp @@ -1,6 +1,8 @@ #include #include +#include "menuitems.h" + #define BST_UNCHECKED 0x0000 #define BST_CHECKED 0x0001 @@ -41,10 +43,12 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine return 1; } + HMENU hMenu = LoadMenu(hInstance, MAKEINTRESOURCE(200)); + HWND hwnd; hwnd = CreateWindow(NazwaKlasy, "Oto okienko", WS_OVERLAPPEDWINDOW, 20, 20, 640, 480, - NULL, NULL, hInstance, NULL); + NULL, hMenu, hInstance, NULL); if(hwnd == NULL) { @@ -81,7 +85,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine SetWindowText(hStatic, "Test 2"); - for(unsigned int x=0; x<1000; ++x) + for(unsigned long int x=0; x<65537; ++x) { char test[10]; ltoa(x,test,10); @@ -111,6 +115,9 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_COMMAND: switch(wParam) { + case ID_PLIK_ZAKONCZ: + PostQuitMessage(0); + break; case ID_PRZYCISK1: // Odczyt danych z pola tekstowego DWORD dlugosc = GetWindowTextLength(hText); @@ -122,11 +129,11 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case ID_PRZYCISK2: if(IsDlgButtonChecked(hwnd, ID_CHECKBOX)) { - MessageBox(0,"Zaznaczony!","Stan",MB_ICONINFORMATION); + MessageBox(hwnd,"Zaznaczony!","Stan",MB_ICONINFORMATION); } else { - MessageBox(0,"Niezaznaczony!","Stan",MB_ICONINFORMATION); + MessageBox(hwnd,"Niezaznaczony!","Stan",MB_ICONINFORMATION); } break; case ID_CHECKBOX: @@ -143,7 +150,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) long int index=SendMessage(hListBox, LB_GETCURSEL, 0, 0); char test[10]; ltoa(index,test,10); - MessageBox(0,test,"Wartość",MB_OK); + MessageBox(hwnd,test,"Wartość",MB_OK); break; case ID_LISTBOX: if(HIWORD(lParam)==LBN_DBLCLK) @@ -151,7 +158,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) long int index=SendMessage(hListBox, LB_GETCURSEL, 0, 0); char test[10]; ltoa(index,test,10); - MessageBox(0,test,"Wartość",MB_OK); + MessageBox(hwnd,test,"Wartość",MB_OK); } break; }