I would like to make my MDI child frames come up at a larger size. Is there an easy way to do this? How does MFC determine the default size?
Actually, even better might be to have them come up already maximized.
thanks!
Printable View
I would like to make my MDI child frames come up at a larger size. Is there an easy way to do this? How does MFC determine the default size?
Actually, even better might be to have them come up already maximized.
thanks!
Check this one:
CWnd::SetWindowPos
useful one..
if helped dont forget to "Rate this post"
This should work :
this should work !!Code:void CChildFrame::ActivateFrame(int nCmdShow)
{
// Update window size
nCmdShow = SW_SHOWMAXIMISED;
CMDIChildWnd::ActivateFrame(nCmdShow);
}
if helped dont forget to "Rate this post"
Well... Almost. Your code will prevent the MDI children from ever getting minimized or restored. Your ActivateFrame implementation should actually look like this:Quote:
Originally Posted by jayender.vs
Code:void CChildFrame::ActivateFrame(int nCmdShow)
{
if (nCmdShow == -1)
{
nCmdShow = SW_SHOWMAXIMIZED;
}
CMDIChildWnd::ActivateFrame(nCmdShow);
}
I believe PreCreateWindow() would be the correct place to do it. You'll be handed a CREATESTRUCT. Set its members appropriately. ActivateFrame will be called any time that window is activated or deactivated, and I don't think you want to resize it every time.
Actually it won't. What happens if the user changes the size, switches to another view, then comes back to this one?Quote:
Originally Posted by jayender.vs
Actually :( ,it will !! :D :DQuote:
Originally Posted by GCDEF
its working perfectly dude....Quote:
What happens if the user changes the size, switches to another view, then comes back to this one?
dont get :confused:
It's an MDI app. Open two windows. Resize 1. Switch to the second, switch back to the first. Doesn't the activate code get triggered again and resize the window when you switch back to it?Quote:
Originally Posted by jayender.vs
Regardless, PreCreateWindow is the normal place to do your initial sizing. It's provided for just that purpose.
Thanks guys... I'll try out these methods and see which one works out (and rate accordingly :-) )
Well, both things work.
ActivateFrame appears to be called only once, even if I switch between mdi children, maximize, restore, etc...
But I've decided to take the PreCreateWindow route...
Actually, PreCreateWindow doesn't work so well, because if I increase the size, MFC starts putting these things off the MDI area, and the user has to move them completely back on (e.g. the bottom is clipped).
It looks like MFC uses some percentage of the actually app size to determine the size of child windows. So maybe I'll just adjust my default app size.
Good .. to know it works well..
well .. the best place is PreCreateWindow , but it does make much difference as i said before .