Changing Menu's per View using MultiDocTemplate
Dean Henkel -- Dean_Henkel@mixcom.com
Wednesday, September 18, 1996
Environment: VC++ 4.2, NT 4.0 Beta
Earlier this week I posted a question regarding redrawing of
DialogBars. Recalclayout() did that trick. My next problem
I've been battling with is that I would like to change the Menu
associated with a view and have it track properly. In my
application I have:
Multiple's of these
CMultiDocTemplate* pPatListDocTemplate =
new CMultiDocTemplate(CLicense().ImageReview()?
IDR_PATIENTLIST_VIEW_MENU:IDR_UPR_PATIENTLIST_VIEW_MENU,
RUNTIME_CLASS(CPatientInfoDoc),
RUNTIME_CLASS(CChildWnd),
RUNTIME_CLASS(CPatientListView));
AddDocTemplate(pPatListDocTemplate);
In my MainFrm.cpp I woule like to:
void CMainFrame::OnOptionsPreferences()
{
// TODO: Add your command handler code here
CPreferencesSheet().DoModal();
CFrameWnd *p;
// Use the Global thePatListView which is a
//CPatientListView object;
p = thePatientListView->GetParentFrame();
CMenu *m = p->GetMenu();
m->DestroyMenu();
CMenu newMenu;
newMenu.LoadMenu(CLicense().ImageReview()?
IDR_PATIENTLIST_VIEW_MENU:IDR_UPR_PATIENTLIST_VIEW_MENU);
p->SetMenu(&n);
}
The Problem is that the SetMenu() call fails GetLastError() is
1436 which is Child Windows Cannot Have Menu's. Obviously I am
doing something wrong. Can anyone help? Can this even be done?
I looked at the MFC code and it almost looks like it cannot.
Thanks.
Dean
Deepak Saxena -- Deepak_Saxena@ccm.ch.intel.com
Friday, September 20, 1996
Text item:
Earlier this week I posted a question regarding redrawing of
DialogBars. Recalclayout() did that trick. My next problem
I've been battling with is that I would like to change the Menu
associated with a view and have it track properly. In my
application I have:
Multiple's of these
CMultiDocTemplate* pPatListDocTemplate =
new CMultiDocTemplate(CLicense().ImageReview()?
IDR_PATIENTLIST_VIEW_MENU:IDR_UPR_PATIENTLIST_VIEW_MENU,
RUNTIME_CLASS(CPatientInfoDoc),
RUNTIME_CLASS(CChildWnd),
RUNTIME_CLASS(CPatientListView));
AddDocTemplate(pPatListDocTemplate);
In my MainFrm.cpp I woule like to:
void CMainFrame::OnOptionsPreferences()
{
// TODO: Add your command handler code here
CPreferencesSheet().DoModal();
CFrameWnd *p;
// Use the Global thePatListView which is a
//CPatientListView object;
p = thePatientListView->GetParentFrame();
CMenu *m = p->GetMenu();
m->DestroyMenu();
CMenu newMenu;
newMenu.LoadMenu(CLicense().ImageReview()?
IDR_PATIENTLIST_VIEW_MENU:IDR_UPR_PATIENTLIST_VIEW_MENU);
// p->SetMenu(&n);
// Replace the above with:
SetMenu(&n);
//
// The reason for this is that you main window frame, and not your mdi frame
// holds the menu for your application.
//
}
The Problem is that the SetMenu() call fails GetLastError() is
1436 which is Child Windows Cannot Have Menu's. Obviously I am
doing something wrong. Can anyone help? Can this even be done?
I looked at the MFC code and it almost looks like it cannot.
Thanks.
Dean
Text item: External Message Header
The following mail header is for administrative use
and may be ignored unless there are problems.
***IF THERE ARE PROBLEMS SAVE THESE HEADERS***.
Reply-To: mfc-l@netcom.com
Precedence: bulk
Errors-To: owner-mfc-l@majordomo.netcom.com
Sender: owner-mfc-l@majordomo.netcom.com
ganeshs@nationwide.com
Monday, September 23, 1996
[Mini-digest: 2 responses]
Environment: VC++ 4.2, NT 4.0 Beta
> Earlier this week I posted a question regarding redrawing of
> DialogBars. Recalclayout() did that trick. My next problem
> I've been battling with is that I would like to change the Menu
> associated with a view and have it track properly. In my
> application I have:
>
> Multiple's of these
>
> CMultiDocTemplate* pPatListDocTemplate =
> new CMultiDocTemplate(CLicense().ImageReview()?
> IDR_PATIENTLIST_VIEW_MENU:IDR_UPR_PATIENTLIST_VIEW_MENU,
> RUNTIME_CLASS(CPatientInfoDoc),
> RUNTIME_CLASS(CChildWnd),
> RUNTIME_CLASS(CPatientListView));
> AddDocTemplate(pPatListDocTemplate);
>
> In my MainFrm.cpp I woule like to:
>
> void CMainFrame::OnOptionsPreferences()
> {
> // TODO: Add your command handler code here
> CPreferencesSheet().DoModal();
>
> CFrameWnd *p;
> // Use the Global thePatListView which is a
> //CPatientListView object;
>
> p = thePatientListView->GetParentFrame();
>
> CMenu *m = p->GetMenu();
> m->DestroyMenu();
>
> CMenu newMenu;
> newMenu.LoadMenu(CLicense().ImageReview()?
> IDR_PATIENTLIST_VIEW_MENU:IDR_UPR_PATIENTLIST_VIEW_MENU);
>
> p->SetMenu(&n);
> }
>
> The Problem is that the SetMenu() call fails GetLastError() is
> 1436 which is Child Windows Cannot Have Menu's. Obviously I am
> doing something wrong. Can anyone help? Can this even be done?
> I looked at the MFC code and it almost looks like it cannot.
>
> Thanks.
>
> Dean
Yep, a CMDIChildWnd cannot have a menu. The menu belongs to the
CMDIFrameWnd, the top-level window. Use MDISet/GetMenu to set/get the
menu.
/ ___| / ___| __ _ _ __ ___ ___| |
\___ \ | | _ / _` | '_ \ / _ \/ __| '_ \
___) | | |_| | (_| | | | | __/\__ \ | | |
|____(_) \____|\__,_|_| |_|\___||___/_| |_|
-----From: "John Bundgaard"
The menuchange is done by MFC automaticly, all you have to do
is create menu resources with the id's IDR_PATIENTLIST_VIEW_MENU
and IDR_UPR_PATIENTLIST_VIEW_MENU.
John Bundgaard
johnb@image.dk
| Вернуться в корень Архива
|