🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: cn.bbs.comp.program
Article #1095

VC FAQ(7)

#1095
From: �ϵ�
Date: Sun, 19 Apr 1998 00:00
76 lines
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

--
�� ��Դ:���ϴ�С�ٺ���Ϣ����վ bbs.nju.edu.cn��[FROM: a507yjh.nju.edu]
Technical Details
Message-ID: <3OAiTc$svA@bbs.nju.edu.cn>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: fc86e,a2b0312f05f5fe19,start
X-Google-Attributes: gidfc86e,public
From: mendy.bbs@bbs.nju.edu.cn (�ϵ�)
Subject: VC FAQ(7)
Date: 1998/04/19
Message-ID: <3OAiTc$svA@bbs.nju.edu.cn>
X-Deja-AN: 345966150
X-Filename: Programming/M.893022614.A
Organization: nju_bbs
Newsgroups: cn.bbs.comp.program