Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. MDI maximized child bug

MDI maximized child bug

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++question
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hsuch
    wrote on last edited by
    #1

    Hi all, It is very common to create a mdi child in a initially maximized state in some cases. I set SW_MAXIMIZE style in the MDICREATESTRUCT structure then send a message to mdi client window. After that, I saw twin sizing boxes on the top-right corner of my frame window (a pair of [Min][Max][Close] tri-buttons). If I restore the child window, the child got one and there was still one remaining on the corner. I was using Win32 SDK, not MFC. The code I used to create the child is like this:

    HWND child_createWnd(HWND hwndClient, int x, int y, int w, int h, TCHAR szCaption[], TCHAR szFilename[])
    {
    HWND hwndChild ;
    MDICREATESTRUCT mdicreate ;

    if(!childClass) childClass = zw\_child\_registerClass();
    
    mdicreate.szClass = szChildClass ;
    mdicreate.szTitle = szCaption ;
    mdicreate.hOwner  = GetModuleHandle(0) ;
    mdicreate.x       = CW\_USEDEFAULT ;
    mdicreate.y       = CW\_USEDEFAULT ;
    mdicreate.cx      = CW\_USEDEFAULT ;
    mdicreate.cy      = CW\_USEDEFAULT ;
    mdicreate.style   = WS\_VSCROLL | WS\_HSCROLL | WS\_MAXIMIZE; `//MAXIMIZE window style`
    mdicreate.lParam  = (LPARAM)szFilename ;
    
    hwndChild = (HWND) SendMessage (hwndClient,
    	WM\_MDICREATE, 0,
    	(LPARAM) (LPMDICREATESTRUCT) &mdicreate) ;
    
    return hwndChild;
    

    }

    I followed Petzold's sample code (cha18, Programming Windows 5ed.)to do this. I wander if I missed something. So I tried it on the sample code directly and add the flag to the style, but still happened. Did anyone ever get this problem? I'm very thankful if anyone can help me.

    H 1 Reply Last reply
    0
    • H hsuch

      Hi all, It is very common to create a mdi child in a initially maximized state in some cases. I set SW_MAXIMIZE style in the MDICREATESTRUCT structure then send a message to mdi client window. After that, I saw twin sizing boxes on the top-right corner of my frame window (a pair of [Min][Max][Close] tri-buttons). If I restore the child window, the child got one and there was still one remaining on the corner. I was using Win32 SDK, not MFC. The code I used to create the child is like this:

      HWND child_createWnd(HWND hwndClient, int x, int y, int w, int h, TCHAR szCaption[], TCHAR szFilename[])
      {
      HWND hwndChild ;
      MDICREATESTRUCT mdicreate ;

      if(!childClass) childClass = zw\_child\_registerClass();
      
      mdicreate.szClass = szChildClass ;
      mdicreate.szTitle = szCaption ;
      mdicreate.hOwner  = GetModuleHandle(0) ;
      mdicreate.x       = CW\_USEDEFAULT ;
      mdicreate.y       = CW\_USEDEFAULT ;
      mdicreate.cx      = CW\_USEDEFAULT ;
      mdicreate.cy      = CW\_USEDEFAULT ;
      mdicreate.style   = WS\_VSCROLL | WS\_HSCROLL | WS\_MAXIMIZE; `//MAXIMIZE window style`
      mdicreate.lParam  = (LPARAM)szFilename ;
      
      hwndChild = (HWND) SendMessage (hwndClient,
      	WM\_MDICREATE, 0,
      	(LPARAM) (LPMDICREATESTRUCT) &mdicreate) ;
      
      return hwndChild;
      

      }

      I followed Petzold's sample code (cha18, Programming Windows 5ed.)to do this. I wander if I missed something. So I tried it on the sample code directly and add the flag to the style, but still happened. Did anyone ever get this problem? I'm very thankful if anyone can help me.

      H Offline
      H Offline
      hsuch
      wrote on last edited by
      #2

      I read "Daniel Bowen, Creating a new MDI child: maximization and focus issues" and got some idea. I should handle redraw and focus issues. Set the client window as MDIS_ALLCHILDSTYLES style and change the function to :

      HWND child_createWnd(HWND hwndClient, int x, int y, int w, int h, TCHAR szCaption[], TCHAR szFilename[])
      {
      HWND hwndChild ;
      MDICREATESTRUCT mdicreate ;
      int fMax = 0;

      if(!childClass) childClass = zw\_child\_registerClass(); 
      
      mdicreate.szClass = szChildClass ;
      mdicreate.szTitle = szCaption ;
      mdicreate.hOwner  = GetModuleHandle(0) ;
      mdicreate.x       = CW\_USEDEFAULT ;
      mdicreate.y       = CW\_USEDEFAULT ;
      mdicreate.cx      = CW\_USEDEFAULT ;
      mdicreate.cy      = CW\_USEDEFAULT ;
      mdicreate.style   = `WS_OVERLAPPEDWINDOW | WS_CHILD | WS_CLIPSIBLINGS | WS_VSCROLL | WS_HSCROLL;`
      mdicreate.lParam  = (LPARAM)szFilename ;	
      
      `SendMessage(hwndClient, WM_SETREDRAW, FALSE, 0); /* Disable redraw */` 
      
      hwndChild = (HWND) SendMessage (hwndClient,
      	WM\_MDICREATE, 0,
      	(LPARAM) (LPMDICREATESTRUCT) &mdicreate) ; 
      
      	
      `/* Should maximize? */ 	SendMessage(hwndClient, WM_MDIGETACTIVE, 0, &fMax); 	fMax? ShowWindow(hwndChild, SW_MAXIMIZE) : ShowWindow(hwndChild, SW_NORMAL); 	 	/* Handle focus here */ 	SetFocus(hwndChild); 	 	/* Enable and redraw */ 	SendMessage(hwndClient, WM_SETREDRAW, TRUE, 0);  	RedrawWindow(hwndClient, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN);`	
      
      
      return hwndChild;
      

      Right now everything is correct except very slow. If you have better idea, please let me know, thanks.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups