Hello!
I try to add controls in a window, but graphic problems occur with my control. Well, I know that if I add control in a dialog window everithing is ok, but what about my case?
BUG 01
When the application start, background of groupbox is not good:
Bug 01
I solve it as follows:
if( FALSE ) {
ShowWindow( hWnd, SW_MINIMIZE );
ShowWindow( hWnd, SW_RESTORE );
}
Anyway, I do not like it, but it works
BUG 02
When size the window I see that:
Bug 02
I can not find a solution to this problem!
GOAL
This is what I want to achieve:
GOAL
This is the entire program ( VS2003, VS2008 compatible ):
#include <windows.h>
#include <commctrl.h>
const char *ClsName = "cn_TestSize";
const char *WndName = "TestSize";
HWND hWndGroup;
#define MACRO_GB_CONTROL 30, rc.top + 5, rc.right - 60, 50
LRESULT CALLBACK WndProcedure( HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam ) {
switch( Msg ) {
case WM_CREATE:
{
RECT rc;
GetClientRect( hWnd, &rc );
hWndGroup = CreateWindowEx( NULL, WC_BUTTON, "Group Box",
WS_VISIBLE | WS_CHILD | BS_GROUPBOX, MACRO_GB_CONTROL,
hWnd, 0, GetModuleHandle( 0 ), NULL );
if( FALSE ) {
ShowWindow( hWnd, SW_MINIMIZE );
ShowWindow( hWnd, SW_RESTORE );
}
}
break;
case WM_SIZE:
{
RECT rc;
GetClientRect( hWnd, &rc );
MoveWindow( hWndGroup, MACRO_GB_CONTROL, TRUE );
}
break;
case WM_DESTROY:
PostQuitMessage(WM_QUIT);
break;
default:
return DefWindowProc( hWnd, Msg, wParam, lParam );
}
return FALSE;
}
INT WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) {
MSG Msg;
WNDCLASSEX WndClsEx;
HWND hWnd;
ZeroMemory( &WndClsEx, sizeof( WNDCLASSEX ) );
WndClsEx.cbSize = sizeof( WNDCLASSEX );
WndClsEx.style = CS_HREDRAW | CS_VREDRAW;
WndClsEx.lpfnWndProc = WndProcedure;
WndClsEx.hIcon = LoadIcon( NULL, IDI_APPLICATION );
WndClsEx.hCursor = LoadCursor( NULL, IDC_ARROW );
WndClsEx.hbrBackground = (HBRUSH)COLOR_BTNSHADOW;
WndClsEx.lpszClassName = ClsName;
WndClsEx.hInstance = hInstance;
WndClsEx.hIconSm = LoadIcon( NULL, IDI_APPLICATION );
RegisterClassEx( &WndClsEx );
hWnd = CreateWindow( ClsName,WndName, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN ,
10, 10, 400, 240, NULL, NULL, hInstance, NULL );
ShowWindow( hWnd, SW_SHOWNORMAL );
UpdateWindow( hWnd );
while( GetMessage(&Msg, NULL, 0, 0) ) {
TranslateMessage( &Msg );
DispatchMessage( &Msg );
}
return (int)Msg.wParam;
}
</commctrl.h></windows.h>
I would be grateful if you could help me!