Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
MDI Child form opens automatically in a maximized state when another child form opened previously is in a maximized state. I mean 1st form is maximized and then the second form is opent which should not be maximized.
Posted

1 solution

You resize window gets WM_WINDOWPOSCHANGING and WM_WINDOWPOSCHANGED commands pick them off and resize the client

In C/C++ you handle them in the window handler of the window that resizes like this so it will look something similar

// These next two messages are better to use rather than WM_MOVE/WM_SIZE.
// Remember WM_MOVE/WM_SIZE are from 16bit windows. In 32bit windows the window
// manager only sends these two messages and the DefWindowProc() handler actually
// accepts them and converts them to WM_MOVE/WM_SIZE.
// 
// We accept this so we can scale our controls to the client size.
     case WM_WINDOWPOSCHANGING:
     case WM_WINDOWPOSCHANGED:
     {
	RECT rc;
        HDWP hDWP;
         
        // Anywhere you see ??? you need to insert your value	

        // Create a deferred window handle.
        if(hDWP = BeginDeferWindowPos(???)){ // Deferring ??? of windows to move
           GetClientRect(hWnd, &rc);
 
           // Defer each window move/size until end and do them all at once.
           hDWP = DeferWindowPos(hDWP, ??? Handle to your window, NULL,
              ???x, ???y, ???cx, ???cy, SWP_NOZORDER | SWP_NOREDRAW);
 
           // RINSE AND REPEAT LINE ABOVE FOR EACH WINDOW YOU DEFERRED
           /* TIME FOR YOU TO ADD CODE */
 
           // Resize all windows under the deferred window handled together.
           EndDeferWindowPos(hDWP);
 
           // We told DeferWindowPos not to redraw the controls so we can redraw
           // them here all at once.
           RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN |
              RDW_ERASE | RDW_NOFRAME | RDW_UPDATENOW);
        }		
        
     }
     return 0;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900