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 » Unchanged system menu in CFrameWnd derived classes Collapse All
Subject Author Date
Dejan Misic Aug 20, 2004 - 8:34 AM

Hi,


I’ve tested your suite in MFC MDI and SDI application (just menu with single toolbar), and after some trial and error, everything seems to be working fine. I’ve also tried to change system menu in MDI child wnd (by default derived from CMDIFrameWnd) by implementing OnCreate() function:


int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)


{


if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)


return -1;



CMenu* pSysMenu = GetSystemMenu(FALSE);


if (pSysMenu != NULL)


{


pSysMenu->AppendMenu(MF_SEPARATOR);


pSysMenu->AppendMenu(MF_STRING | MF_ENABLED, 0x0010, "Extra Item");


pSysMenu->AppendMenu(MF_STRING | MF_CHECKED, 0x0011, "Extra Item 2");


}



return 0;


}


Everything worked fine, as expected.


However, when I include Prof-UIS in ’real-life’ project, I realized that all my system menus are unchanged in child frame windows. My child frame window class (CTabChildFrame) is derived from CFrameWnd class, and it’s created using code:


CRuntimeClass* pRuntimeClass = RUNTIME_CLASS(CTabChildFrame);


CString strWinClass = AfxRegisterWndClass(NULL, 0, 0, GetTachyonProApp()->LoadIcon(IDR_CHILDFRAME));


CTabChildFrame* pTabChildFrame = (CTabChildFrame*)pRuntimeClass->CreateObject();


pTabChildFrame ->Create(LPCSTR(strWinClass), "Tab Child Frame");


...


For completness, here is PreCreateWindow function:


BOOL CTabChildFrame::PreCreateWindow(CREATESTRUCT& cs)


{


cs.hMenu = NULL;


cs.style = WS_SYSMENU | WS_THICKFRAME;


cs.dwExStyle &= ~WS_EX_CLIENTEDGE;


cs.dwExStyle |= WS_EX_TOOLWINDOW;


return CFrameWnd::PreCreateWindow(cs);


}


I hope I’ve informed you enough,


regards,


Dejan

Dejan Misic Aug 20, 2004 - 8:37 AM

Sorry, I realize I forgot to clarify one thing:


System Menu of CTabChildFrame frame looks like normal system menu, and not like Prof-UIS one (obtainable e.g. by right-clicking on main frame’s title bar).


 


regards,


Dejan

Sergiy Lavrynenko Aug 22, 2004 - 4:14 AM

Dear Dejan,

In Prof-UIS based applications you should not try to access the HMENU handle’s data of MDI child frame’s system menu because the CExtMenuControlBar class changes behavior of the standard windows MDI interface and simply kills the MDI frame’s menu line. You should use your own menu bar class and override the following internal virtual method:


      virtual BOOL CExtMenuControlBar::
            _TrackFrameSystemMenu(
                  CWnd * pFrame,
                  CPoint * pPoint = NULL,
                  BOOL bSelectAny = FALSE,
                  LPCRECT rcExcludeArea = NULL,
                  UINT nTrackFlags = (UINT)(-1),
                  BOOL bCombinedMode = FALSE
                  );


This method is invoked from the following 3 methods:


      virtual BOOL CExtMenuControlBar::
            TrackMainFrameSystemMenu(
                  CPoint * pPoint = NULL,
                  BOOL bSelectAny = FALSE
                  );
      virtual BOOL CExtMenuControlBar::
            TrackChildFrameSystemMenu(
                  CPoint * pPoint = NULL,
                  BOOL bSelectAny = FALSE
                  );
      virtual UINT CExtBarMdiDocButton::OnTrackPopup(
            CPoint point,
            bool bSelectAny
            );


This approach allows you to control the Prof-UIS menus which correspond to the MDI child frame’s or main frame’s system menu. You should copy the body of this method from the same method in the CExtMenuControlBar class and modify the popup menu initialization code. Please use pFrame->IsKindOf(RUNTIME_CLASS(CAnyKindOfFrameWndInYouApp)) to check which frame’s system menu is to be tracked.