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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Maximize and minimize the dialogs

Status
Not open for further replies.

kaya17

Programmer
Feb 9, 2004
78
0
0
SG
HI, guys, now my project is on the final stage. but still, there is a problem not solved. that is the maximize and minimize of the dialogs.

i got some buttons and a list in the dialog, once i click the maxi and mini icons on the top right corner, the dialog indeed changed accordingly, however, the buttons and list still remain the same size and position.

what should i do i want them to be enlarged accordingly?
and,
how to make the dialog fully occupies the screen at the when it is initialized?


Thanks very much for any suggestions!

regards,
kaya
 
I've found that if you want the layout and/or size of dialog controls to change dynamically when your dialog box changes size, you have to do it yourself. Catch the WM_SIZE message, which is sent every time your dialog box changes size, and in there recalculate where you want to move each control and what size you want them to be, based on the new dialog box size.
 
you should use DefferWindowPos when receiving WM_SIZE and move/resize all windows according to positions.

Ion Filipski
1c.bmp
 
so, you are saying that i have to do it manully?
 
hi, could any of you give me some examples to illustrate how to use the DeferWindowPos()?


thanks a lot!

kaya
 
Code:
LRESULT CALLBACK WndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
{
.....
    switch(message)
    {
....
    case WM_SIZE:
       ResizeAllWindows(hWnd);
       break;
 .....
    }
.....
}
void ResizeAllWindows(HWND hWnd)
{
    RECT rc;
    H[COLOR=red]DWP[/color] hdwp;
    GetClientRect(hWnd,&rc);
    hdwp=BeginDeferWindowPos(4);
    if(!hdwp)return;

    DeferWindowPos(hdwp,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
 
HI, thanks a lot for your code.

when i tried it out, it said the GetClientRect(hWnd, &rc); doesn't take 2 parameters, is there any header file should i add? i added the #include <windows.h>, but it still persisted.


and what is the hwndTree, hListWnd, hStatusWnd, and hToolWnd?

in my dialog, there are 5 buttons, one list, and a text display, and some combo-boxes. in my case, what should i write to replace the hwndTree, hListWnd...?

looking forward to your reply.


regards,
kaya
 
you may use one or
::GetClientRect(hWnd, &rc);
or
GetClientRect(&rc);
As I see you're using MFC.

hwndTree, hListWnd, hStatusWnd, and hToolWnd are some windows handles from one of my applications. It is just a copy/paste. You will have yours in your application (any or buttons/toolbars/different controls/..... what could be identified by some HWND).

Ion Filipski
1c.bmp
 
Hi, thanks for your reply.
but would you tell me how to get the HWND of thoes controls (like buttons, lists, combo boxes or whatsoever)?


Looking forward to your reply.
thanks.

kaya
 
If you have only ID's of your controls you can use GetDlgItem(ID_YOURCONTROL) or nonMFC equivalent is GetDlgItem(yourDlgHwnd, ID_YOURCONTROL);
Else if you have created controls manually in code, then you should use them by variable names:
CButton* yourButton;
......

HWND hwndOfYourButton = yourButton->GetHandle();

Ion Filipski
1c.bmp
 
i tried the GetDlgItem(IDC_ListControl)
but it said cannot convert parameter 2 from 'class CWnd *' to 'struct HWND_*'
IN THE DeferWindowPos(...) function....

oh...headache....

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top