Resizing a control.
-
This is a simple question though I can't seem to figure out the 'right way' of doing it. I have a dialog window with only a listbox and a titlebar. What is the best approach to make the listbox fill the entire window (with room for the title bar as well)? I'm using just a simple dialog and listbox resource and am not using MFC so I'm assuming there some message sending that will need to be done. Any information or even just a poke in the right direction would help. Sean
-
This is a simple question though I can't seem to figure out the 'right way' of doing it. I have a dialog window with only a listbox and a titlebar. What is the best approach to make the listbox fill the entire window (with room for the title bar as well)? I'm using just a simple dialog and listbox resource and am not using MFC so I'm assuming there some message sending that will need to be done. Any information or even just a poke in the right direction would help. Sean
Use GetCLientRect to find out the size of the Window and MoveWindow or SetWindowPos to resize the control. Christian I have come to clean zee pooollll. - Michael Martin Dec 30, 2001 Picture the daffodil. And while you do that, I'll be over here going through your stuff. Picture a world without war, without hate. And I can picture us attacking that world, because they would never expect it.
Sonork ID 100.10002:MeanManOz
I live in Bob's HungOut now
-
Use GetCLientRect to find out the size of the Window and MoveWindow or SetWindowPos to resize the control. Christian I have come to clean zee pooollll. - Michael Martin Dec 30, 2001 Picture the daffodil. And while you do that, I'll be over here going through your stuff. Picture a world without war, without hate. And I can picture us attacking that world, because they would never expect it.
Sonork ID 100.10002:MeanManOz
I live in Bob's HungOut now
Will GetCLientRect return the size of the ENTIRE window or the window-toolbar (aka the client area)? I'm assuming I have to do this on WM_RESIZE as well? Sean
-
Will GetCLientRect return the size of the ENTIRE window or the window-toolbar (aka the client area)? I'm assuming I have to do this on WM_RESIZE as well? Sean
It will return the rect of the client area, the area WM_PAINT can draw on. GetWindowRect will return the whole window, in screen co-ordinates. It's GetClientRect too, I made a typo... Christian I have come to clean zee pooollll. - Michael Martin Dec 30, 2001 Picture the daffodil. And while you do that, I'll be over here going through your stuff. Picture a world without war, without hate. And I can picture us attacking that world, because they would never expect it.
Sonork ID 100.10002:MeanManOz
I live in Bob's HungOut now
-
Will GetCLientRect return the size of the ENTIRE window or the window-toolbar (aka the client area)? I'm assuming I have to do this on WM_RESIZE as well? Sean
No. Just handle the WM_SIZE.
CListBox* pListBox = (ClistBox *) GetDlgItem (IDC_LIST_BOX);
if (pListBox != NULL) {
CRect clientRect;
GetClientRect (&clientRect);
pListBox->MoveWindow (&clientRect);
}/ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com
-
This is a simple question though I can't seem to figure out the 'right way' of doing it. I have a dialog window with only a listbox and a titlebar. What is the best approach to make the listbox fill the entire window (with room for the title bar as well)? I'm using just a simple dialog and listbox resource and am not using MFC so I'm assuming there some message sending that will need to be done. Any information or even just a poke in the right direction would help. Sean
LRESULT CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
RECT rect; //Holds client rectangle coordinates
HWND hList; //Handle to listbox//Retrieve coordinates of client rect
GetClientRect(hDlg, &rect);switch(uMsg)
{
case WM_SIZE:
hList = GetDlgItem(hDlg, IDC_MYLIST);
MoveWindow(hList, rect.left, rect.top, rect.right, rect.bottom, TRUE);
break;
}
}Hope i didn't forget anything...:) "An expert is someone who has made all the mistakes in thier field" - Niels Bohr