CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 1999
    Posts
    11

    Context sensitive help

    Hi all!
    I have some problem with context help support at dialog boxes. I need 3 kind of help:
    1. Whole dialog help (called by pressing F1).
    2. Context help for dialog controls in popup windows (called by pressing Help Button in dialog caption, and then hitting some control).
    3. Context help for dialog controls in popup windows (called through context menu "What's this?" by right mouse click on the control).
    I realised 2 and 3 approachs but i don't know how to catch whole dialog help at F1 key instead calling focused control context help.
    Is anybody help me? I will be appreciate any comments.

    Thanks,
    Vlad Bychkoff.


  2. #2
    Join Date
    Jul 1999
    Location
    Montreal, Quebec, Canada
    Posts
    192

    Re: Context sensitive help

    I can't help you for #1 and #2, but if you found a way to do that, please let me know.

    On another hand, #3 is found in MSDN:

    How do I add "What's this" menus to my application—like Windows 95 hip apps have?

    Here are some steps to get you started:

    Put the following menu into a resource script:


    IDR_WHAT_IS_THIS_MENU MENU DISCARDABLE
    BEGIN
    BEGIN
    POPUP "a"
    BEGIN
    MENUITEM "What's this?", ID_WHAT_IS_THIS
    END
    END
    END




    Add to your dialog a right-click handler (OnRButtonDown) with menu IDR_WHAT_IS_THIS_MENU. You need to store the point of the last click in some variable—for example,

    CPoint m_cLastRClickPoint;




    and store here the client coordinates of the last right click.

    Put the following code into your dialog class (or probably the parent class of all your dialogs):

    BEGIN_MESSAGE_MAP(CMyDialog, CDialog)
    // {{AFX_MSG_MAP(CMyDialog)
    // Whatever
    //}}
    ON_COMMAND(ID_WHAT_IS_THIS, OnWhatIsThis)
    END_MESSAGE_MAP()
    void CMyDialog::OnWhatIsThis()
    {
    CWnd* pControl = ChildWindowFromPoint (m_cLastRClickPoint);
    // If the click wasn't on one of the controls, open Help for dialog.
    if (pControl == NULL || pControl->m_hWnd == m_hWnd)
    WinHelp (HID_BASE_RESOURCE + m_nIDHelp,
    HELP_CONTEXTPOPUP);
    else
    WinHelp (HID_BASE_CONTROL + pControl->GetDlgCtrlID(),
    HELP_CONTEXTPOPUP);
    }



    —and finally add the following lines to the makehelp.bat file:

    echo. >>hlp\wr.hm
    echo // Controls (IDC_*) >>hlp\wr.hm
    makehm IDC_,HIDC_,0x50000 resource.h >>hlp\wr.hm

    This wires everything to your Help system.





    ---
    Nicolas LeBlanc
    Software Engineer
    Ordiplan Inc.

  3. #3
    Join Date
    Apr 1999
    Posts
    11

    Re: Context sensitive help

    I already realized all enumerated cases, but I applyed some tricks. If you still interested I can explain you all or some you interested cases.

    Best regards
    Vlad Bychkoff
    e-mail: [email protected]



  4. #4
    Join Date
    Jul 1999
    Location
    Montreal, Quebec, Canada
    Posts
    192

    Re: Context sensitive help

    I managed also to make most of it work.. the only think I'm not able to do it seems, is make the F1 bring global help instead of focused control tip.


    ---
    Nicolas LeBlanc
    Software Engineer
    Ordiplan Inc.

  5. #5
    Join Date
    Apr 1999
    Posts
    11

    Re: Context sensitive help

    To make F1 call global help do following:
    in header file define

    #define HK_F1 1
    static WORD hk = 112; // F1-key code



    and define message handler for WM_HOTKEY

    afx_msg void OnHotKey( UINT nID, LPARAM lParam );



    in .cpp file add macro in message map

    ON_MESSAGE(WM_HOTKEY, OnHotKey)



    add code for handler

    void CMyDialog::OnHotKey( UINT nID, LPARAM lParam )
    {
    switch( nID)
    {
    case HK_F1: {
    AfxGetApp()->WinHelp(IDD_MYDIALOG);
    break;
    }
    }
    }



    and in OnInitDialog() add

    ..........
    RegisterHotKey(m_hWnd, HK_F1, HIBYTE( hk), LOBYTE( hk));
    ..........



    and in OnDestroy()

    UnregisterHotKey(m_hWnd, HK_F1);
    ...........




    wow... think that will work :-)

    Best regards
    Vlad Bychkoff



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured