From 1a4daa78a44bbdce948c7ade2e2c10c7d7391d86 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 04:38:07 +0200 Subject: [PATCH] Initial commit --- WinAPI_test.mk | 3 + WinAPI_test.sym | Bin 0 -> 5374 bytes WinAPI_test.tgt | 81 +++++++++++++++++++++++ WinAPI_test.wpj | 43 ++++++++++++ main.cpp | 169 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 296 insertions(+) create mode 100644 WinAPI_test.mk create mode 100644 WinAPI_test.sym create mode 100644 WinAPI_test.tgt create mode 100644 WinAPI_test.wpj create mode 100644 main.cpp diff --git a/WinAPI_test.mk b/WinAPI_test.mk new file mode 100644 index 0000000..0599e9f --- /dev/null +++ b/WinAPI_test.mk @@ -0,0 +1,3 @@ +project : H:\Projekty_Watcom\WinAPI_test\WinAPI_test.exe .SYMBOLIC + +!include H:\Projekty_Watcom\WinAPI_test\WinAPI_test.mk1 diff --git a/WinAPI_test.sym b/WinAPI_test.sym new file mode 100644 index 0000000000000000000000000000000000000000..1604e450ababab2ceb648026e9f0d62699ed1c3c GIT binary patch literal 5374 zcmb7ITWs6b8UD#bE3)LqP8_#Q+I4Q7q-~P9siUT8*44FTJN6=5iloFTkbQYOj zN>Y&%xJ%nLSf7SvdDz1)MKKf@)?wJgHtf>36+_+zwAjNQ_A+4DQ-Pt_Lop29zWH z*nKzJF|oD<#D1zyU1JG!Ph@!Ka19*t?0gi1oL?=fwJ9^G69HRd&?G`)Dtpy;5-OSIiCXy1s6BRl9R#y=Bc6 zR&>vFy(=A~WldMRT{%LdOHWUqoLrwPXY;F}K%ybGXSib9ZBmutYSVBisSLZVhGo_! zWjCP=_pCSodY>t}M@cngb(^;1(U2PP`pBMbj+S*Vo%<2BZCec(6AhQZ9&K3H!FW1D zL&=C1VtbOq^|ozzq-n!7yH{zOq$NL5P9kNlS0nmZQACQ%cYU^5H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II2VE5e>*Ke4$WjWtTOAPQ7 z&5nJ|+{uT4hGi1SS~L58i?qE1#BAGk0~w_4A0U@ZZ?0nZuzuaYE3Mltw>&=L^CwwQ zoq<{m&DvH#eq?~WfThl{ujegk0cnp7aJS#>I=8 zO8=B&>Wj=-NOH<{JMgIs$g2vF|i7DvkA-jAZ#Zx6-8#I+S4nMPWTrUDm@|opC2BAEf5+qGNg!cMGS2`Gntv3JX|hMX1=nzC5Da* zksLp=CH8RRq1gQZ+Fwi_#FJYOTo59^xjE5$QD{%S`uy_~lZzc8o{zw7b2Eg-O|2_#= rjY6et_sdF)Z!# literal 0 HcmV?d00001 diff --git a/WinAPI_test.tgt b/WinAPI_test.tgt new file mode 100644 index 0000000..f6fe646 --- /dev/null +++ b/WinAPI_test.tgt @@ -0,0 +1,81 @@ +40 +targetIdent +0 +MProject +1 +MComponent +0 +2 +WString +4 +WEXE +3 +WString +5 +w_6en +1 +0 +1 +4 +MCommand +0 +5 +MCommand +0 +6 +MItem +15 +WinAPI_test.exe +7 +WString +4 +WEXE +8 +WVList +0 +9 +WVList +0 +-1 +1 +1 +0 +10 +WPickList +2 +11 +MItem +5 +*.cpp +12 +WString +6 +CPPOBJ +13 +WVList +0 +14 +WVList +0 +-1 +1 +1 +0 +15 +MItem +8 +main.cpp +16 +WString +6 +CPPOBJ +17 +WVList +0 +18 +WVList +0 +11 +1 +1 +0 diff --git a/WinAPI_test.wpj b/WinAPI_test.wpj new file mode 100644 index 0000000..173cf83 --- /dev/null +++ b/WinAPI_test.wpj @@ -0,0 +1,43 @@ +40 +projectIdent +0 +VpeMain +1 +WRect +-21 +-37 +10282 +10031 +2 +MProject +3 +MCommand +0 +4 +MCommand +0 +1 +5 +WFileName +15 +WinAPI_test.tgt +6 +WVList +1 +7 +VComponent +8 +WRect +0 +0 +5722 +4323 +2 +0 +9 +WFileName +15 +WinAPI_test.tgt +0 +1 +7 diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..f540be8 --- /dev/null +++ b/main.cpp @@ -0,0 +1,169 @@ +#include +#include + +#define BST_UNCHECKED 0x0000 +#define BST_CHECKED 0x0001 + +#define ID_PRZYCISK1 501 +#define ID_PRZYCISK2 502 +#define ID_CHECKBOX 503 +#define ID_LISTBOX 504 +#define ID_PRZYCISK3 505 +#define ID_EDITBOX 506 +#define ID_LISTBOX2 507 + +HWND hText; +HWND hListBox, hListBox2; + +LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); + +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) +{ + // MessageBox(NULL,"Fender!","Test",MB_ICONINFORMATION | MB_OK); + + WNDCLASS wc; + LPSTR NazwaKlasy = "Klasa Okienka"; + + wc.style = 0; + wc.lpfnWndProc = WndProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hInstance; + wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); + wc.lpszMenuName = NULL; + wc.lpszClassName = NazwaKlasy; + + if(!RegisterClass(&wc)) + { + MessageBox(NULL,"Nie udało się utworzyć okna.","Błąd",MB_ICONEXCLAMATION | MB_OK); + return 1; + } + + HWND hwnd; + + hwnd = CreateWindow(NazwaKlasy, "Oto okienko", WS_OVERLAPPEDWINDOW, 20, 20, 640, 480, + NULL, NULL, hInstance, NULL); + + if(hwnd == NULL) + { + MessageBox(NULL,"Nie udało się wyświetlić okna.","Błąd",MB_ICONEXCLAMATION | MB_OK); + return 1; + } + + HWND hPrzycisk, hPrzycisk2, hPrzycisk3; + HWND hCheckBox; + HWND hStatic; + + hPrzycisk = CreateWindow("BUTTON", "Wyświetl tekst", WS_CHILD | WS_VISIBLE, 160, 5, 150, 30, + hwnd, (HMENU)ID_PRZYCISK1, hInstance, NULL); + + hPrzycisk2 =CreateWindow("BUTTON", "Wyświetl stan", WS_CHILD | WS_VISIBLE, 160, 35, 150, 30, + hwnd, (HMENU)ID_PRZYCISK2, hInstance, NULL); + + hPrzycisk3 =CreateWindow("BUTTON", "Wyświetl wybrany", WS_CHILD | WS_VISIBLE, 160, 65, 150, 30, + hwnd, (HMENU)ID_PRZYCISK3, hInstance, NULL); + + hText = CreateWindow("EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL, + 5, 5, 150, 150, hwnd, (HMENU)ID_EDITBOX, hInstance, NULL); + + hCheckBox = CreateWindow("BUTTON", "Opcja", WS_CHILD | WS_VISIBLE | BS_CHECKBOX, 5, 165, 150, 30, + hwnd, (HMENU)ID_CHECKBOX, hInstance, NULL); + + hStatic = CreateWindow("STATIC", "Test", WS_CHILD | WS_VISIBLE | SS_LEFT, 5, 195, 150, 205, hwnd, NULL, hInstance, NULL); + + hListBox = CreateWindow("LISTBOX", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | ES_AUTOVSCROLL | LBS_NOTIFY, + 320, 5, 150, 150, hwnd, (HMENU)ID_LISTBOX, hInstance, NULL); + + hListBox2 =CreateWindow("LISTBOX", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | ES_AUTOVSCROLL | LBS_NOTIFY, + 320, 155, 150, 150, hwnd, (HMENU)ID_LISTBOX2, hInstance, NULL); + + SetWindowText(hStatic, "Test 2"); + + for(unsigned int x=0; x<1000; ++x) + { + char test[10]; + ltoa(x,test,10); + SendMessage(hListBox, LB_ADDSTRING, 0, (LPARAM) test); + } + + SendMessage(hListBox2, LB_ADDSTRING, 0, (LPARAM) "xD"); + + ShowWindow(hwnd,nCmdShow); + UpdateWindow(hwnd); + + MSG Komunikat; + + while(GetMessage(&Komunikat, NULL, 0, 0 )) + { + TranslateMessage(&Komunikat); + DispatchMessage(&Komunikat); + } + + return 0; +} + +LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) + { + case WM_COMMAND: + switch(wParam) + { + case ID_PRZYCISK1: + // Odczyt danych z pola tekstowego + DWORD dlugosc = GetWindowTextLength(hText); + LPSTR Bufor = (LPSTR)GlobalAlloc(GPTR, dlugosc+1); + GetWindowText(hText,Bufor,dlugosc+1); + MessageBox(hwnd,Bufor,"Pobrany tekst",MB_OK); + GlobalFree((unsigned)Bufor); + break; + case ID_PRZYCISK2: + if(IsDlgButtonChecked(hwnd, ID_CHECKBOX)) + { + MessageBox(0,"Zaznaczony!","Stan",MB_ICONINFORMATION); + } + else + { + MessageBox(0,"Niezaznaczony!","Stan",MB_ICONINFORMATION); + } + break; + case ID_CHECKBOX: + if(IsDlgButtonChecked(hwnd, ID_CHECKBOX)) + { + CheckDlgButton(hwnd, ID_CHECKBOX, BST_UNCHECKED); // = 0 + } + else + { + CheckDlgButton(hwnd, ID_CHECKBOX, BST_CHECKED); // = 1 + } + break; + case ID_PRZYCISK3: + long int index=SendMessage(hListBox, LB_GETCURSEL, 0, 0); + char test[10]; + ltoa(index,test,10); + MessageBox(0,test,"Wartość",MB_OK); + break; + case ID_LISTBOX: + if(HIWORD(lParam)==LBN_DBLCLK) + { + long int index=SendMessage(hListBox, LB_GETCURSEL, 0, 0); + char test[10]; + ltoa(index,test,10); + MessageBox(0,test,"Wartość",MB_OK); + } + break; + } + break; + case WM_CLOSE: + DestroyWindow(hwnd); + break; + case WM_DESTROY: + PostQuitMessage(0); + break; + default: + return DefWindowProc(hwnd,msg,wParam,lParam); + } + return 0; +}