Irwan
June 29th, 2010, 11:15 PM
Hi.
My writing a application.
1. The Main Window Client Area is splitted into several child window.
2. Each Child Window background is paint with different color.
3. Background color is register in the wndclass.hbrBackground for each child window.
4. The bush is created by CreateSolidBrush().
The question:
1. Do I need to delete the brushs?
2. Where to delete it?
The Code:
(unrelated lines is deleted)
#
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
// Win32 API Structure Declaration
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
static TCHAR szAppName[] = TEXT("SplitterApp");
// Main Window Class
wndclass.style = 0;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(hInstance, szAppName);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = CreateSolidBrush(RGB(195,218,249));
wndclass.lpszMenuName = 0;
wndclass.lpszClassName = szAppName;
RegisterClass(&wndclass);
// Left Panel Class
wndclass.lpfnWndProc = LeftPanelProc;
wndclass.hbrBackground = CreateSolidBrush(RGB(255,255,255));
wndclass.lpszClassName = TEXT("LeftPanel");
RegisterClass(&wndclass);
// Splitter Panel Class
wndclass.lpfnWndProc = SplitterPanelProc;
wndclass.hbrBackground = CreateSolidBrush(RGB(255,0,0));
wndclass.lpszClassName = TEXT("SplitterPanel");
RegisterClass(&wndclass);
// Create Window for Main Window
hwnd = CreateWindow(szAppName,
szAppName,
WS_OVERLAPPEDWINDOW | SW_MAXIMIZE | WS_VISIBLE,
us->getStartXPos(),
us->getStartYPos(),
us->getWndStartWidth(),
us->getWndStartHeight(),
NULL,
NULL,
hInstance,
szCmdLine);
//All child Window is Created in the WndProc()
// Message Pump
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
#
My writing a application.
1. The Main Window Client Area is splitted into several child window.
2. Each Child Window background is paint with different color.
3. Background color is register in the wndclass.hbrBackground for each child window.
4. The bush is created by CreateSolidBrush().
The question:
1. Do I need to delete the brushs?
2. Where to delete it?
The Code:
(unrelated lines is deleted)
#
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
// Win32 API Structure Declaration
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
static TCHAR szAppName[] = TEXT("SplitterApp");
// Main Window Class
wndclass.style = 0;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(hInstance, szAppName);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = CreateSolidBrush(RGB(195,218,249));
wndclass.lpszMenuName = 0;
wndclass.lpszClassName = szAppName;
RegisterClass(&wndclass);
// Left Panel Class
wndclass.lpfnWndProc = LeftPanelProc;
wndclass.hbrBackground = CreateSolidBrush(RGB(255,255,255));
wndclass.lpszClassName = TEXT("LeftPanel");
RegisterClass(&wndclass);
// Splitter Panel Class
wndclass.lpfnWndProc = SplitterPanelProc;
wndclass.hbrBackground = CreateSolidBrush(RGB(255,0,0));
wndclass.lpszClassName = TEXT("SplitterPanel");
RegisterClass(&wndclass);
// Create Window for Main Window
hwnd = CreateWindow(szAppName,
szAppName,
WS_OVERLAPPEDWINDOW | SW_MAXIMIZE | WS_VISIBLE,
us->getStartXPos(),
us->getStartYPos(),
us->getWndStartWidth(),
us->getWndStartHeight(),
NULL,
NULL,
hInstance,
szCmdLine);
//All child Window is Created in the WndProc()
// Message Pump
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
#