?
Solved

CDialog: How to determine which help was used?

Posted on 2005-04-27
9
Medium Priority
?
861 Views
Last Modified: 2013-11-20
Hi experts,
I am using a CDialog and have WinHelp overridden.
How can I determine which help was called or how
help was called ((Shift-)F1, ?, F1, help)?
Thanks Jens
0
Comment
Question by:allmer
  • 6
  • 3
9 Comments
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 13874038
the help file will be in your application name. if your application name is allmer.exe, help file should be allmer.hlp.
Pressing "F1" will invoke the help (OnHelp function), where ever you mapped ID_HELP (using ON_COMMAND(ID_HELP, OnHelp))

~roshan
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 13874048
In the default implementation, the help file name is taking from your application name (i.e. if your application name is allmer.exe, help file would be allmer.hlp).
Pressing "F1" will invoke the help (OnHelp function), where ever you mapped ID_HELP (using ON_COMMAND(ID_HELP, OnHelp))

~roshan
0
 
LVL 5

Author Comment

by:allmer
ID: 13874063
Right roshmon,
my problem is within OnHelp:
...OnHelp() {
   HELP whichhelpwascalled
   switch (whichhelpwascalled) {
       case: context_help
       case: regular_help
       case: ?what cases are possible here?
       default: !break down and cry!
    }
}
Clear?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 23

Expert Comment

by:Roshan Davis
ID: 13874102
Then you can use PreTranslateMessahe function and check for the WM_CHAR

~roshan
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 13874171
eg.

BOOL CCMyDialog::PreTranslateMessage(MSG* pMsg)
{

      if ( pMsg->message == WM_CHAR )
      {
            if ( pMsg->wParam == VK_F1 )
            {
      
                  if ( 0x8000 & GetKeyState(VK_SHIFT) )
                  {
                        // SHIFT + F1
                  }
                  else
                  {
                        // Only F1
                  }
            }
      }
      else if ( pMsg->message == WM_COMMAND )
      {
            if ( pMsg->wParam == ID_HELP )
            {
                  // Pressed Help
            }
      }      
      else
            CDialog::PreTranslateMessage(MSG* pMsg);
}

~roshan
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 13874218
sorry for re-post, try this

BOOL CCMyDialog::PreTranslateMessage(MSG* pMsg)
{
       if ( pMsg->message == WM_KEYDOWN )
     {
          if ( pMsg->wParam == VK_F1 )
          {
     
               if ( 0x8000 & GetKeyState(VK_SHIFT) )
               {
                    AfxMessageBox("SHIFT + F1");
               }
               else
               {
                    AfxMessageBox("F1");
               }

                     return TRUE;
          }

     }
     else if ( pMsg->message == WM_COMMAND )
     {
          if ( pMsg->wParam == ID_HELP )
          {
               AfxMessageBox("Pressed Help");
                     return TRUE;
          }
     }    
     else
          return CDialog::PreTranslateMessage(pMsg);
}
~roshan
0
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 1000 total points
ID: 13874262
yeah found!!!

map WM_HELPINFO

BOOL CMyDialog::OnHelpInfo(HELPINFO* pHelpInfo)
{
    short state = GetKeyState (VK_F1);
    if (state < 0)   // F1 key is down, get help for the dialog
        return CDialog::OnHelpInfo(pHelpInfo);
    else
    {    // F1 key not down, get help for specific control
        if (pHelpInfo->dwContextId)
            WinHelp (pHelpInfo->dwContextId,
                HELP_CONTEXTPOPUP);
        return TRUE;
    }
}

~roshan
0
 
LVL 5

Author Comment

by:allmer
ID: 13874691
How abut this:

void CAutoPeaksDlg::WinHelp(DWORD dwData, UINT nCmd)
{
      switch(nCmd) {
            case HELP_CONTEXTPOPUP :
                  ::HtmlHelp(      pWnd->GetSafeHwnd(), ??,
                                    HH_DISPLAY_TEXT_POPUP, ??);
            case  ??:
                  ::HtmlHelp(      pWnd->GetSafeHwnd(), ??,
                                    HH_DISPLAY_TOPIC, ??);
                  break;
            case  ??:
                  ::HtmlHelp(      pWnd->GetSafeHwnd(), ??,
                                    HH_HELP_CONTEXT, ??);
                  break;
            case ?? :
                  ::HtmlHelp(      pWnd->GetSafeHwnd(), ??,
                                    HH_TP_HELP_CONTEXTMENU, ??);
                  break;
            case  ??:
                  ::HtmlHelp(      pWnd->GetSafeHwnd(), ??,
                                    HH_TP_HELP_WM_HELP, ??);
                  break;
      }
      CDialog::WinHelp(dwData, nCmd);
}

This didn't work, but it shows what I want do do, I guess.
I want to call HtmlHelp(,,,) depending on the case above.
I might be wrong using it in that function at all.
How can I achive this behaviour using your suggestion?
And what are the IDs like HELP_CONTEXTPOPUP for the other cases
or where can I find them?
Thanks,
Jens
0
 
LVL 5

Author Comment

by:allmer
ID: 13903503
OK found it in the HtmlHelpWorkshop documentation.
Thans Jens
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month13 days, 8 hours left to enroll

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question