Query on WM_SIZE in MDI Application

This is a discussion on Query on WM_SIZE in MDI Application within the Windows Programming forums, part of the Platform Specific Boards category; I'm trying my hand at writing an MDI application, and have an issue of conflicting information. In the code below: ...

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    123

    Query on WM_SIZE in MDI Application

    I'm trying my hand at writing an MDI application, and have an issue of conflicting information. In the code below:

    Code:
    LRESULT CALLBACK MdiChildWndProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
    {
    	RECT hwndRect;
    	SCROLLINFO si;
    	HWND hwndThis;
    	int nScrollCode, clientrange, disenabler, ScrollFlag;
    	register int ii, jj, nPos, newPos, lowest, width, height;
    	static char namework[51];
    
    	switch(msg)
    	{
    ...
    ...
    		case WM_SIZE:
    			hwndThis = (HWND)SendMessage(hwndMDIClient, WM_MDIGETACTIVE, (WPARAM)0, (LPARAM)(BOOL)NULL); // This window
    			switch (wparam)
    			{
    				case SIZE_MINIMIZED:
    				case SIZE_RESTORED:
    				case SIZE_MAXIMIZED:
    					width = (int)LOWORD(lparam);
    					height = (int)HIWORD(lparam);
    					si.cbSize = sizeof(si);
    					si.fMask = SIF_PAGE; // Only page needs amending
    					si.nPage = height; // Set page size to height of client area
    					SetScrollInfo(hwnd, SB_VERT, &si, TRUE); // Redraw the vertical scrollbar
    					si.nPage = width; // Set page width to width of client area
    					SetScrollInfo(hwnd, SB_HORZ, &si, TRUE); // Redraw the horizontal scrollbar
    					// return 0; // Should return zero, but doing so messes up the MDI stuff
    					break;
    				default:
    					break;
    			}
    			UpdateWindow(hwndThis);
    			break;
    ...
    ...
    	}
    	return DefMDIChildProc(hwnd, msg, wparam, lparam);
    }
    If I return zero, then I experience the exact same problem as described in this thread here.

    However, the documentation says that an "application should return zero if it processes this message."

    So my question is, Which is correct? Should I return zero or lett it fall though to DefMDIChildProc()?

    Thanks.
    I think you can put a signature here.

  2. #2
    Registered User
    Join Date
    Jan 2010
    Posts
    412
    I believe the docs on WM_SIZE only applies to normal windows.
    DefMDIChildProc Function (Windows) says this in the remarks section:
    WM_SIZE Performs operations necessary for changing the size of a window, especially for maximizing or restoring an MDI child window. Failing to pass this message to the DefMDIChildProc function produces highly undesirable results.

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    123
    Thanks for the speedy response _Mike, that answers it perfectly.
    I think you can put a signature here.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 07-03-2010, 02:18 PM
  2. Convirt my C program to a GUI application/Web Application
    By kapil1089thekin in forum C Programming
    Replies: 6
    Last Post: 07-21-2008, 02:43 AM
  3. Replies: 1
    Last Post: 09-18-2005, 10:06 PM
  4. Unicode vurses Non Unicode client server application with winsock2 query?
    By dp_76 in forum Networking/Device Communication
    Replies: 0
    Last Post: 05-16-2005, 08:26 AM
  5. MFC :: WM_SIZE message causes access violation?
    By SyntaxBubble in forum Windows Programming
    Replies: 1
    Last Post: 06-09-2003, 11:01 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21