When you create a window that contains a listbox, that listbox will not resize when the window resizes. Thus if you created the window below, and maximized (or just resized) it, the listbox would stay the same size.
In order to have any subwindow (including a listbox) resize when the window is resized, you must override the WM_SIZE message handler. In this handler you can get the size of the new rectangle. In this handler you can retrieve the new size of the mainwindow using GetWindowRect. If you store the offset of the listbox from the upper-left corner of the window, and the differences between the width and height of the window and the listbox, you can resize the listbox so that it is proportional to the change in the main window.
All you need to do is create four enum identifiers in the private part of the windows class definition. The values were derived by some experimentation, but should work for most windows.
private:
enum {LEFT_OFFSET = 10,TOP_OFFSET = 10,WIDTH_OFFSET = 30,HEIGHT_OFFSET=50};
The first line of this function is provided by Class Expert. It actually resizes the window Generic. Once the window is resized, get its size using GetWindowRect and then use SetWindowPos to resize the listbox. Notice the upper-left offset is in the coordinates of the Generic window. The third and fourth parameters of the function are the new width and height. You calculate these by taking the fixed differences of the window height and width and the listbox height and width.
void Generic::EvSize (uint sizeType, TSize& size)
{
TDialog::EvSize(sizeType, size);
// INSERT>> Your code here.
if (sizeType != SIZE_MINIMIZED)// resize if not minimize
{
TRect rect = GetWindowRect();
_listIt->SetWindowPos(0,LEFT_OFFSET,TOP_OFFSET, //Set the corner of the listbox
rect.Width()-WIDTH_OFFSET, // set the width relative to the new window size
rect.Height()- HEIGHT_OFFSET, //set the height relative to the new window size
SWP_NOZORDER );
}
}
The complete code for this problem is given in facade.zip .