Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » CExtMenuControlBar and CMDIChildWnd... sysmenu left behind Collapse All
Subject Author Date
Merlin Avery Sep 27, 2006 - 4:25 PM

I setup a CMDIFrameWnd and CExtMenuControlBar with a tabbed mdi window.
I then do the following:

    CMDIChildWnd *wndMDIChild = new CMDIChildWnd;
    wndMDIChild->Create(NULL, "Blah", WS_CHILD | WS_VISIBLE | WS_MAXIMIZE | WS_SYSMENU | WS_CAPTION);

To simulate a VC2005 mdi system. It creates the window fine and adds it’s tab and puts the Sysmenu Icon to the left of the menu.

The problem is, when I close this mdi window, the sysmenu icon vanishes to the left of the menu, but the button is still there. interacting with this button throws an assert.

Is this button supposed to vanish on it’s own? Or am I supposed to handle something I’m not in the child or frame wnd?

hamid sherkat Mar 2, 2008 - 12:47 AM

ok, but let me know where should i call this function. i do it in Create after calling the base class Create. it works, but the main frame loses focus! maybe i should do it in OnCreate?
besides, why the style WS_MAXIMIZED doesn’t work. i sent it to the base Create, and it didn’t work. i remembered that Default() doesn’t pay attention to the args i pass, and uses the default arguments produced along with the message. am i right? so i put it in PreCreateWindow. i or’ed the cs.style with WS_MAXIMIZED. but this time it didn’t work too.
besides, it’s not a right way to call an additional function like MDIMaximize and cause the MDI frame gets maximized AFTER it has created with or without the WS_MAXIMIZED style set. it means that in no way this style is paid attention. it indicates some lack or bug. am i right?
what’s the best solution for creating an MDI child frame maximized by default?
my ideal is to:
1. open the 1st mdi child frame maximized (when there’s no open mdi child frame)
2. open new mdi frame maximized if the active mdi child frame is maximized.
3. open new mdi frame restored when the active one is not maximized.
4. when one mdi frame is maximized, the others get maximized also.
5. when an mdi frame is restored, the others get restored too.
oh, lots of question! :)
i hope one may answer all of them accurately and properly.
thanx

Technical Support Sep 28, 2006 - 11:43 AM

You can use the CMDIFrameWnd::CreateNewChild() function to create child windows of the MDI frame window:

void CMDIApp::OnFileNew() 
{
CMainFrame * pFrame =
  STATIC_DOWNCAST(
   CMainFrame,
   m_pMainWnd
   );
 // create a new MDI child window
 pFrame->CreateNewChild(
  RUNTIME_CLASS(CChildFrame),
  IDR_MDITYPE,
  m_hMDIMenu,
  m_hMDIAccel
  );
}



Merlin Avery Sep 28, 2006 - 1:56 PM

This has the same problem.

When I maximize the MDI CChildFrame it creates an iconic button to the left of the "File" menu item. This is the sysmenu. When I close the child, the button loses it’s icon, but the button remains. The MDI sample code doesn’t have this problem. I’m wondering what I am not handelling that causes the menu to drop this button when no CChildFrame is active.

Technical Support Sep 29, 2006 - 11:43 AM

We have no idea what the problem is. We need to take a look at your project so that we can proceed with this issue.

Merlin Avery Sep 29, 2006 - 12:25 PM

Good news. I fixed that issue and found another one.

It seems that if you set WS_MAXIMIZED when creating the child frame window this issue happens. If you do "ShowWindow(SW_MAXIMIZE)" in the OnCreate for the child. It doesn’t have the issue. I’m not certain why that is.

However, a new issue was found. If you do the ShowWindow(SW_MAXIMIZE) in the on create, when you expand the CMDIFrameWnd the children don’t update and stay at their same positions :) It just seems to hate the idea of maximized mdi document windows. Trying to figure this out right now. I’ll get the project setup for your viewing pleasure if I don’t figure this out soon.

Technical Support Oct 2, 2006 - 11:37 AM

It is not correct to use ShowWindow(SW_SHOWMAXIMIZED) with MDI child frame windows. The CMDIChildWnd windows are not independent window object but rather controlled by their parent window which is called the MDI client area window. You should use CMDIChildWnd::MDIMaximize() method instead.

Merlin Avery Sep 29, 2006 - 3:18 PM

Alright, both problems are fixed. I changed the style in precreate and did "cs.style &= ~(WS_MINIMIZEBOX | WS_MAXIMIZEBOX);" one of the styles were not allowing it to work correctly, but has been fixed.