Thread: mdi workspace

  1. #1
    Registered User
    Join Date
    Dec 2004
    Posts
    38

    mdi workspace

    I am working with a mdi workspace. Usually in other programs like if you maximize a window there is the 3 buttons for the parent window like maximize, minimize and close then there is a smaller one for the child window that is maximized. My mdi client doesnt do that, is there like a special style I have to specify or something? Thanks.
    edit
    Here is my MDI proc:
    Code:
    LRESULT CALLBACK MainMDIProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    	switch(message)
    	{
    	case WM_DESTROY:
    		PostQuitMessage(0);
    	break;
    /*	case WM_SIZE:
    		HWND temp, riched;
    		temp = GetFocus();
    		if(temp != hwndtreeparent){
    			riched = FindWindowEx(temp, NULL, RICHEDIT_CLASS, NULL);
    			GetClientRect(temp, &rc);
    			MoveWindow(riched, 20, 0, rc.right-30, rc.bottom-30, FALSE);
    			break;
    		}
    		GetClientRect(hwndtreeparent, &rc);
    		MoveWindow(hwndtreeview, 10, 10, rc.right - 20, rc.bottom - 20, FALSE);
    	break;*/
    	case WM_CLOSE:
    		HWND temp2;
    		temp2 = GetFocus();
    		if(temp2 == hwndtreeparent){
    			ShowWindow(hwndtreeparent, SW_HIDE);
    			break;
    		}
    		ShowWindow(temp2, SW_HIDE);
    //		DestroyWindow(temp2);
    	break;
    	default:
    		return DefMDIChildProc(hwnd, message, wParam, lParam);
    	}
    	return 0;
    }
    Here is mdi window:
    Code:
    	hwndmdi = CreateWindowEx(0,
    						"mdiclient",
    						0,
    						WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS,
    						10, 10,
    						rc.right - 20, rc.bottom - 20,
    						hwnd,
    						0,
    						gInstance,
    						&ccs);
    Last edited by Elyubarov; 04-03-2005 at 09:05 AM.

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Your child window procedure is wrong. Change it to this:

    Code:
    LRESULT CALLBACK MainMDIProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    	switch(message)
    	{
    	//case WM_DESTROY: Why post a quit message when a child is destroyed?
    	//	PostQuitMessage(0);
    	//break;
    	case WM_SIZE: // notice now WM_SIZE calls DefMDIChildProc() where it didnt before
    		HWND temp, riched;
    		temp = GetFocus();
    		if(temp != hwndtreeparent){
    			riched = FindWindowEx(temp, NULL, RICHEDIT_CLASS, NULL);
    			GetClientRect(temp, &rc);
    			MoveWindow(riched, 20, 0, rc.right-30, rc.bottom-30, FALSE);
    			break;
    		}
    		GetClientRect(hwndtreeparent, &rc);
    		MoveWindow(hwndtreeview, 10, 10, rc.right - 20, rc.bottom - 20, FALSE);
    	break;
    	case WM_CLOSE:  // This handler doesn't seem to do anything special.
                                          // why not let the default handler take over instead?
    		HWND temp2;
    		temp2 = GetFocus();
    		if(temp2 == hwndtreeparent){
    			ShowWindow(hwndtreeparent, SW_HIDE);
    			break;
    		}
    		ShowWindow(temp2, SW_HIDE);
    //		DestroyWindow(temp2);
    	break;
    	}
    	return DefMDIChildProc(hwnd, message, wParam, lParam);
    }

  3. #3
    Registered User
    Join Date
    Dec 2004
    Posts
    38
    That like didnt help at all, its a problem with my mdi workspace, not WM_SIZE or WM_CLOSE..

  4. #4
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    You said:
    Usually in other programs like if you maximize a window there is the 3 buttons for the parent window like maximize, minimize and close then there is a smaller one for the child window that is maximized
    You WILL NOT get the min/max/restore icons for the child window when you return 0 from your WM_SIZE handler.

    Nothing else you posted indicates the problem you are describing. Post the code where you create a child window.

  5. #5
    Registered User
    Join Date
    Dec 2004
    Posts
    38
    Here is the full source to what I am writing, perhaps you can figure out the problem:
    Source

  6. #6
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    You are incorrectly creating your child windows. MDI Child windows are not created by calling CreateWindow(). They are created by sending the following message to your client window:

    Code:
    MDICREATESTRUCT mdicreate;
    // fill mdicreate struct here
    SendMessage(hwndClient,WM_MDICREATE,0,(LPARAM)&mdicreate);

  7. #7
    Registered User
    Join Date
    Dec 2004
    Posts
    38
    Heh, now the problem is half solved. That seemed to work except now when I maximize the child window inside the mdi I see the three buttons for the childwindow in the mdi bar but I cant click them. Thanks for your help.

  8. #8
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Actually, bithub, you can you use CreateWindowEx to create mdi child windows provided the window class has been previously registered and the WS_EX_MDICHILD extended style bit is used when creating the child window.

    >>That seemed to work except now when I maximize the child window inside the mdi I see the three buttons for the childwindow in the mdi bar but I cant click them.<<

    Replace the DefWindowProc call with DefFrameProc in the WM_COMMAND handler of the MainWindowProcedure function.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  9. #9
    Registered User
    Join Date
    Dec 2004
    Posts
    38
    There is no DefWindowProc for WM_COMMAND..

  10. #10
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    You 'break' to it - replace the 'break' with 'return DefFrameProc(...);'

    edit: Actually, it seems you 'break' to 'return 0' - change it anyway as previously described.
    Last edited by Ken Fitlike; 04-03-2005 at 03:30 PM.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  11. #11
    Registered User
    Join Date
    Dec 2004
    Posts
    38
    Thanks alot, it works.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. win32 api MDI windows
    By TheNewOne in forum Windows Programming
    Replies: 5
    Last Post: 03-20-2009, 09:11 PM
  2. Editor design: Traditional MDI versus Tabbed MDI
    By psychopath in forum Game Programming
    Replies: 7
    Last Post: 01-22-2007, 07:48 AM
  3. Inserting text into MDI program
    By Rutabega in forum Windows Programming
    Replies: 0
    Last Post: 12-23-2005, 11:25 AM
  4. MDI Problem
    By Rare177 in forum Windows Programming
    Replies: 3
    Last Post: 04-12-2005, 01:29 PM
  5. Daemon problem
    By gandalf_bar in forum Linux Programming
    Replies: 3
    Last Post: 07-20-2004, 06:23 AM