Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically resizing Dialog windows?

Status
Not open for further replies.

JurgenWellinger

Programmer
Aug 30, 2001
8
ZA
In writing a dialog based application I would like to have the dialog window change it's dimensions depending on what is to be displayed. How do I do that?
 
see *DeferWindowPos family functions. Use ot on resize window. Ion Filipski
1c.bmp


filipski@excite.com
 

Here's some code you can use to adjust the dialog box yourself. It will reposition the status bar also (if you add one). This code extends the bottom of the dailog box. You should add something to keep track of what state the dialog box is in. Add two buttons and map them to the two functions below. Put the functions in your dialog class. Once you play with them a little you'll see how to adjust the dialogs size. Basically I hide the window, resize it, then show it again. Have fun...

void CPracticeDlg::OnMove()
{
CRect rcWindow;
GetWindowRect(rcWindow);

rcWindow.bottom += 300;//rcClientStart.Height(); - .001;//rcClientNow.Width();

MoveWindow(rcWindow,FALSE);
ShowWindow(FALSE);
ShowWindow(TRUE);

RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST,0);
}

void CPracticeDlg::OnHide()
{
ShowWindow(FALSE);

CRect rcWindow,rcWindow2;
CRgn cRgn;
GetWindowRect(rcWindow);
rcWindow2 = rcWindow;
cRgn.CreateRectRgnIndirect(rcWindow2);

rcWindow.bottom += -300;//rcClientStart.Height(); - .001;//rcClientNow.Width();

ShowWindow(FALSE);
MoveWindow(rcWindow,FALSE);
ShowWindow(TRUE);

RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST,0);
}
 
see it,
it is just for resizing windows toghever:

void OnResizeYourMainWindow(HWND hWnd)
{
RECT rc;
HDWP hdwp;
GetClientRect(hWnd,&rc);
hdwp=BeginDeferWindowPos(4);
if(!hdwp)return;
DeferWindowPos(hdwp,factory.hwndTree,NULL,0,
32,rc.right/4, rc.bottom-52,SWP_NOZORDER);
DeferWindowPos(hdwp,hListWnd,NULL,((rc.right-rc.left)/4)+3,32,
(((rc.right-rc.left)/4)*3)-3,rc.bottom-52,SWP_NOZORDER);
DeferWindowPos(hdwp,hStatusWnd,NULL,0,rc.bottom-32,rc.right,rc.bottom,SWP_NOZORDER|SWP_NOMOVE);
DeferWindowPos(hdwp,hToolWnd,NULL,0,0,rc.right-3,rc.bottom,SWP_NOZORDER|SWP_NOMOVE);
EndDeferWindowPos(hdwp);
return;
}
Ion Filipski
1c.bmp


filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top