Thread View: cn.bbs.comp.program
1 messages
1 total messages
Started by �ϵ�
Sun, 19 Apr 1998 00:00
VC FAQ(7)
Author: �ϵ�
Date: Sun, 19 Apr 1998 00:00
Date: Sun, 19 Apr 1998 00:00
76 lines
2404 bytes
2404 bytes
2m������:m TMN (������)
2m�� ��:m RAD
2m�� ��:m VC FAQ(7)
2m����վ:m '3m�Ͻ�ɺ�m' (Wed Apr 8 08:15:20 1998) , 5mվ���ż�m
[������ҳ] [����������] [ȫ��������]
------------------------------------------------------------
How do I 'attach' a menu to a window's creation/destruction?
-----------------------------------------------------------
{Note the original question talked about dialogs, but you can interpolate
this
code to any kind of window that you want to have change the menu.}
One of the ways to do this is as follows**
1. Declare a variable CMenu pNewMenu in one of the dialog class.
2. Handle the WM_INITDIALOG and WM_CLOSE messages in the
dialog class as follows.
BOOL CMydlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Load the IDR_MYFRAME menu
pNewMenu = new CMenu;
pNewMenu->LoadMenu(IDR_MYFRAME);
// Set the mainframe menu to mainframe.
((CMainFrame *)AfxGetMainWnd())->SetMenu(pNewMenu);
return TRUE;
}
And
void CMydlg::OnClose()
{
// Detach the previous HMenu handle from the object.
pNewMenu->Detach();
pNewMenu->LoadMenu(IDR_MAINFRAME);
// Restore the mainframe menu.
((CMainFrame *)AfxGetMainWnd())->SetMenu(pNewMenu);
CDialog::OnClose();
}
4. If there are other methods of closing the dialog (example- By clicking
a
button in the Dialog), then The code given above in OnClose handler, must
be
put in the button click handler.
[������ҳ] [����������] [ȫ��������]
--
m;31m�� ��Դ:���Ͻ�ɺ� bbs.njupt.edu.cn��[FROM: pc05.info.njupt]m
--
[m[1;33m�� ��Դ:���ϴ�С�ٺ���Ϣ����վ bbs.nju.edu.cn��[FROM: a507yjh.nju.edu][m
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads