1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
TCHAR greeting[] = _T("Hello, World!");
wchar_t listBoxStr[15];
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
case LISTBOX_GET:
SendMessageW(hListBox, LB_GETTEXT,0,(LPARAM)listBoxStr);
MessageBoxW(NULL, listBoxStr, L"", NULL);
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
case WM_CREATE://executes when the window is created
InitializeComponent(hWnd);
SendMessage(hListBox, LB_ADDSTRING, 0, (LPARAM)greeting);
SendMessage(hListBox, LB_ADDSTRING, 0, (LPARAM)"text------------------");
return 0;
}
return 0;
}
void InitializeComponent(HWND hWnd) {
HINSTANCE hInstance = GetModuleHandle(NULL);
// Adding a Button.
hBtn = CreateWindowExW(WS_EX_APPWINDOW
, L"BUTTON", NULL
, WS_CHILD | WS_VISIBLE
, 627, 7, 70, 21
, hWnd, NULL, hInstance, NULL);
SetWindowTextW(hBtn, L"&Lisa");
// Adding a Label.
hLabel = CreateWindowExW(WS_EX_CLIENTEDGE
, L"STATIC", NULL
, WS_CHILD | WS_VISIBLE
, 7, 7, 50, 21
, hWnd, NULL, hInstance, NULL);
SetWindowTextW(hLabel, L"Käsud:");
// Adding a ListBox.
hListBox = CreateWindowExW(WS_EX_CLIENTEDGE
, L"LISTBOX", NULL
, WS_CHILD | WS_VISIBLE | ES_VSCROLL | ES_AUTOVSCROLL
, 7, 35, 600, 200
, hWnd, NULL, hInstance, NULL);
// Adding a TextBox.
hTextBox = CreateWindowExW(WS_EX_CLIENTEDGE
, L"EDIT", NULL
, WS_CHILD | WS_VISIBLE | ES_AUTOVSCROLL
, 62, 7, 545, 21
, hWnd, NULL, hInstance, NULL);
SetWindowTextW(hTextBox, L"Input text here...");
}
|