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.
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]
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.
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