在基于MFC的对话框程序中,当选中对话框属性的"Context Help"时,在对话框的关闭按钮旁边会有一个"?",我想在程序运行时点击这个"?"就弹出我的关于对话框该怎么做???

解决方案 »

  1.   

    在OnSysCommand中进行处理,id为61824
    if ((nID & 0xFFF0) == IDM_ABOUTBOX)
    {
    CAboutDlg dlgAbout;
    dlgAbout.DoModal();
    }
    else if(nID == 61824)
    {
    CAboutDlg dlgAbout;
    dlgAbout.DoModal(); }
      

  2.   

    在主程序里处理以下消息
    ON_COMMAND(ID_HELP, CWinApp::OnHelp),在WinHelp(DWORD dwData, UINT nCmd)函数中可自己处理
      

  3.   

    the   ID   for   help   button   is   ID_HELP   
        
      add the following to the message map:   
        
      ON_COMMAND(ID_HELP,   OnHelp)   
        
      and add   
        
      afx_msg void OnHelp();   
        
      to AFX_MSG section:   
        
              //{{AFX_MSG(MyClass)   
              afx_msg   void   OnHelp();   
              //}}AFX_MSG   
        
      

  4.   

    if ((nID & 0xFFF0) == IDM_ABOUTBOX)
    {
    CAboutDlg dlgAbout;
    dlgAbout.DoModal();
    }
    else 
    if(nID == 61824)
    {
    CAboutDlg dlgAbout;
    dlgAbout.DoModal();

    }
    else
    {
    CDialog::OnSysCommand(nID, lParam);
    }2楼的应该这样,否则关闭按钮不能用了
      

  5.   

    To: happyhqr() and wenbaby(雯贝贝)  61824是什么值?在哪里有定义?
      

  6.   

    应该是"?"的ID值,好象是通过spy++查看?
      

  7.   

    #define SC_CONTEXTHELP  0xF180
    看下msdn的资料
    WM_SYSCOMMAND
    A window receives this message when the user chooses a command from the window menu (formerly known as the system or control menu) or when the user chooses the maximize button, minimize button, restore button, or close button.WM_SYSCOMMAND 
    uCmdType = wParam;        // type of system command requested 
    xPos = LOWORD(lParam);    // horizontal position, in screen coordinates 
    yPos = HIWORD(lParam);    // vertical position, in screen coordinates 
     
    Parameters
    uCmdType 
    Specifies the type of system command requested. This parameter can be one of the following values. Value Meaning 
    SC_CLOSE Closes the window. (((((((//关闭按钮)))))))
    SC_CONTEXTHELP ((((((((((((帮助按钮)))))Changes the cursor to a question  with a pointer. If the user then clicks a control in the dialog box, the control receives a WM_HELP message. 
    SC_DEFAULT Selects the default item; the user double-clicked the window menu. 
    SC_HOTKEY Activates the window associated with the application-specified hot key. The low-order word of lParam identifies the window to activate. 
    SC_HSCROLL Scrolls horizontally. 
    SC_KEYMENU Retrieves the window menu as a result of a keystroke. 
    SC_MAXIMIZE Maximizes the window. 
    SC_MINIMIZE Minimizes the window. 
    SC_MONITORPOWER   Sets the state of the display. This command supports devices that have power-saving features, such as a battery-powered personal computer.
    lParam can have the following values:1 means the display is going to low power.2 means the display is being shut off.
     
    SC_MOUSEMENU Retrieves the window menu as a result of a mouse click. 
    SC_MOVE Moves the window. 
    SC_NEXTWINDOW Moves to the next window. 
    SC_PREVWINDOW Moves to the previous window. 
    SC_RESTORE Restores the window to its normal position and size. 
    SC_SCREENSAVE Executes the screen saver application specified in the [boot] section of the SYSTEM.INI file. 
    SC_SIZE Sizes the window. 
    SC_TASKLIST Activates the Start menu. 
    SC_VSCROLL Scrolls vertically. 
    xPos 
    Specifies the horizontal position of the cursor, in screen coordinates, if a window menu command is chosen with the mouse. Otherwise, the xPos parameter is not used. 
    yPos 
    Specifies the vertical position of the cursor, in screen coordinates, if a window menu command is chosen with the mouse. This parameter is –1 if the command is chosen using a system accelerator, or zero if using a mnenomic. 
    Return Values
    An application should return zero if it processes this message.
      

  8.   

    把它放到vc文件中,右键,goto definition就可以了