Repository navigation
Expand file tree
/
Copy pathCMainWindow.cpp
More file actions
90 lines (70 loc) · 2.65 KB
/
Copy pathCMainWindow.cpp
File metadata and controls
90 lines (70 loc) · 2.65 KB
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
#include "CMainWindow.h"
#include <Commctrl.h>
CMainWindow::CMainWindow(LPCSTR lpszCaption, LPWNDCLASSEX lpwndClassEx)
: CWindow( lpszCaption, lpwndClassEx)
{
}
CMainWindow::CMainWindow(LPCSTR lpszCaption, HINSTANCE hInstance, LPCTSTR lpszClassName)
:CWindow(lpszCaption, hInstance, lpszClassName) {
}
CMainWindow::CMainWindow(LPCSTR lpszCaption, HINSTANCE hInstance, LPCTSTR lpszClassName,
UINT style, HICON hIcon, HCURSOR hCursor, HBRUSH hbrBackground,
LPCTSTR lpszMenuName, HICON hIconSm)
: CWindow(lpszCaption, hInstance, lpszClassName,
style, hIcon, hCursor, hbrBackground,
lpszMenuName, hIconSm)
{
}
LRESULT CALLBACK CMainWindow::wndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
static HWND hwndStatics[] = { NULL, NULL };
static HWND hwndStatus = NULL;
RECT rc;
int statusHeight;
long style;
switch (uMsg)
{
case WM_CREATE:
GetWindowRect(NULL, &rc);
SetWindowPos(
hwnd,
0,
GetSystemMetrics(SM_CXSCREEN) / 2 - 320,
GetSystemMetrics(SM_CYSCREEN) / 2 - 240,
640,
480,
SWP_NOZORDER
);
style = GetWindowLong(hwnd, GWL_STYLE);
style &= ~WS_MAXIMIZEBOX;
style &= ~WS_MINIMIZEBOX;
SetWindowLong(hwnd, GWL_STYLE, style);
InitCommonControls();
hwndStatics[0] = CreateWindowEx(0L, "Static", "Lista", WS_CHILD | WS_VISIBLE | SS_ETCHEDFRAME, 10, 10, 100, 100, hwnd, (HMENU)NULL, this->_hInstance, (LPVOID)NULL);
hwndStatics[1] = CreateWindowEx(0L, "Static", "Static", WS_CHILD | WS_VISIBLE | SS_ETCHEDFRAME, 110, 10, 100, 100, hwnd, (HMENU)NULL, this->_hInstance, (LPVOID)NULL);
hwndStatus = CreateWindowEx(0,STATUSCLASSNAME,(PCTSTR)NULL,SBARS_SIZEGRIP | WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hwnd, (HMENU)0L, this->_hInstance,NULL);
return 0;
case WM_SIZE:
GetWindowRect(hwndStatus, &rc);
statusHeight = rc.bottom - rc.top;
SendMessage(hwndStatus, WM_SIZE, 0, 0);
GetClientRect(hwnd, &rc);
rc.right -= rc.left;
rc.bottom -= rc.top;
SetWindowPos(hwndStatics[0], 0, rc.left + 10, rc.top + 10, rc.right / 2 - 15, rc.bottom - 20 - statusHeight, SWP_NOZORDER);
SetWindowPos(hwndStatics[1], 0, rc.right / 2 + 5, rc.top + 10, rc.right / 2 - 15, rc.bottom - 20 - statusHeight, SWP_NOZORDER);
return ::DefWindowProc(hwnd, uMsg, wParam, lParam);
case WM_GETMINMAXINFO:
((LPMINMAXINFO)lParam)->ptMaxSize.x = 640;
((LPMINMAXINFO)lParam)->ptMaxSize.y = 480;
((LPMINMAXINFO)lParam)->ptMaxTrackSize.x = 640;
((LPMINMAXINFO)lParam)->ptMaxTrackSize.y = 480;
((LPMINMAXINFO)lParam)->ptMinTrackSize.x = 320;
((LPMINMAXINFO)lParam)->ptMinTrackSize.y = 240;
return 0;
case WM_DESTROY:
::PostQuitMessage(0);
return 0;
default:
return ::DefWindowProc(hwnd, uMsg, wParam, lParam);
}
}