Code:
CDlgMain(HWND hWnd): CWindowClass(hWnd)
{
.....
//Create a canvas
canvas.create(CreateWindowEx(WS_EX_CLIENTEDGE,
"PANELCLASS",
"",
WS_CHILD | WS_VSCROLL | WS_HSCROLL,
0,
0,
0,
0,
getHandle(),
NULL,
CApplication::getHandle(),
NULL));
//Create menu tab
menuTab.create(CreateWindowEx(0, WC_TABCONTROL, "", WS_CHILD | TCS_MULTILINE, 0, 0, 0, 0,
getHandle(), NULL, CApplication::getHandle(), NULL));
//Create map tab
mapTab.create(CreateWindowEx(0, WC_TABCONTROL, "", WS_CHILD, 0, 0, 0, 0,
getHandle(), NULL, CApplication::getHandle(), NULL));
//force the WM_SIZE message to be sent (to adjust the scroll bars on the canvas)
canvas.sendSizeMessage();
//force the WM_SIZE message to be sent to main window (to set the shape and position of some of the child windows)
this->sendSizeMessage();
.....
}
int onSize(const TSizeEvent& event)
{
int canvasWidth = event.width - 210;
int canvasHeight = event.height - 76;
//Autosize status bar and scroll bar
statusBar.sendMessage(WM_SIZE, 0, 0);
toolBar.sendMessage(WM_SIZE, 0, 0);
//Auto size the other stuff
MoveWindow(canvas.getHandle(), 206, 55, canvasWidth, canvasHeight, true);
MoveWindow(menuTab.getHandle(), 14, 32, 188, event.height - 54, true);
MoveWindow(mapTab.getHandle(), 206, 32, event.width - 210, 24, true);
//Resize back buffer
if(canvasWidth > backBuffer->w || canvasHeight > backBuffer->h)
{
SDL_FreeSurface(backBuffer);
backBuffer = SDL_CreateRGBSurface(SDL_SWSURFACE, canvasWidth, canvasHeight, 24, 0x00FF0000, 0x0000FF00, 0x000000FF, 0);
updateCanvas(true);
}
return 1;
}
Now i just dont even bother putting the size and position in CreateWindow