⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 00000018.txt

📁 水木清华BBS站的讨论区精华集锦
💻 TXT
字号:
 
                       --===BBS水木清华站∶精华区===--
 
                        -===BBS水木清华站∶精华区===-
 ------------------------------------------------------------ 
   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. 
 
                        -===BBS水木清华站∶精华区===-

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -