|
|
Comments and Discussions
|
|
 |

|
In the OnHelpHitTest() function, do this instead:
LRESULT CMyFormView::OnHelpHitTest(WPARAM wParam, LPARAM lParam)
{
CPoint pt((DWORD)lParam) ;
CWnd *pWnd = ChildWindowFromPoint(pt, CWP_SKIPINVISIBLE); LRESULT nID = 0;
if (pWnd != NULL)
{
if (pWnd == this)
{
nID = IDD;
}
else
{
nID = pWnd->GetDlgCtrlID();
}
}
return nID ; }
Using ChildWindowFromPoint has two advantages:
1) It returns a CWnd for every control on the form, even if they're disabled, hidden, or transparent. You can also use the second parameter in the function to filter exactly what is found.
2) You don't need to use ScreenToClient() on the point before using it.
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|

|
Do you have a working samplke of the HtmlHelp in a CFormView that you could share?
I am catching the OnHelpHitTest in CFormView, and I can not for the life of me get the help to pop up.
I get an error message indicating that I have a problem with Aliases/Maps.
As far as I know (not a great deal I am afraid) the Alias/Maps can have any value for the #Defines.
I have simply taken the .hm file copied it, and added the #Defines.
This all workd terifically for the Dialog Boxes, but has been somewhat of a disappointment with the CFormView.
I have even tried catching the OnHelpHitTest and popping my own help message. Which kinda sorta works, but then the HelpResource ID is passed on the the Help API and I still get an error.
Actually, sometimes with this the help window are pops but no text is visible in the window.
Thanks for any advice/assistance.
|
|
|
|

|
I haven't done C++/MFC in over a year. I'm afraid I won't be of much help.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|

|
I dont know why you are using so many functions to get the ID of window under the cursor, even if a simple function OnToolHitTest can do the same job.
OnHelpHitTest could be replaced by this simple solution :-
LRESULT CYourFormView::OnHelpHitTest(WPARAM, LPARAM lParam)
{
int nID = OnToolHitTest((DWORD)lParam, NULL);
if (nID != -1)
return nID + 0x60000;
else
return IDD + 0x20000;
}
Tanmay
|
|
|
|

|
I tried this and it worked fine for me.
On One View.
WHen I tried it on another view, it return -1 (failure) on all the
controls and I could never determine why. Both Views are derived from CFormView.
Robert Ramey
|
|
|
|

|
As I use the HtmlHelp instead of the WinHelp in my application utilizing this code?
|
|
|
|

|
It should be.
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|

|
The code works great!!! Thank you!!!
I have a little problem...
When user clicks with the arrow in a control, the code calls onHelpHitTest().
I just want that the help appears in a popup.
I have inserted the command
AfxGetApp()->(helpId, HELP_CONTEXTPOPUP)
in the onHelpHitTest() function and before the return...
But the programm shows the popup and then the content help...
Any sugestions to help meeeee....
Alice
|
|
|
|

|
Hi,
i have a solution for you.
you try to modify the code below:
(in .h file)
afx_msg LRESULT OnHelpHitTest(WPARAM wParam, LPARAM lParam);
(in .cpp file)
ON_MESSAGE(WM_HELPHITTEST, OnHelpHitTest)
//function implementation
LRESULT CYourFormView::OnHelpHitTest(WPARAM wParam, LPARAM lParam)
{
CPoint p((DWORD)lParam) ;
ClientToScreen(&p) ;
CWnd *pWnd = WindowFromPoint(p) ;
if (pWnd != NULL) {
// convert to correct help ID, see makehelp.bat
if (pWnd == this)
return IDD + 0x20000 ;
else
return pWnd->GetDlgCtrlID() + 0x60000 ; // see later about 0x60000
}
return 0 ; // failed!
}
in:
(in .h file)
afx_msg void OnMyHelpHitTest(WPARAM wParam, LPARAM lParam);
(in .cpp file)
ON_MESSAGE(WM_HELPHITTEST, OnMyHelpHitTest)
//function implementation
void CEcdisBig::OnMyHelpHitTest(WPARAM wParam, LPARAM lParam)
{
CPoint p((DWORD)lParam) ;
ClientToScreen(&p) ;
CWnd *pWnd = WindowFromPoint(p) ;
if (pWnd != NULL) {
DWORD helpID;
if (pWnd == this)
helpID = IDD + 0x20000 ; // convert to correct help ID
else
helpID = pWnd->GetDlgCtrlID() + 0x60000 ;
AfxGetApp()->WinHelp(helpID,HELP_CONTEXTPOPUP);
}
}
now, recompile and run your application.
good luck.
|
|
|
|

|
I have another solution for you.
you try code below:
void CContextHelpView::OnMyHelpHitTest(WPARAM wParam, LPARAM lParam)
{
// message is sent to us as follows:
// dwContext = ::SendMessage(hWnd, WM_HELPHITTEST, 0, MAKELONG(point.x, point.y));
// WPARAM = 0 ;
// LPARAM = Point clicked
DWORD helpID;
CWinApp *theApp = AfxGetApp();
CString helpFilePath = theApp->m_pszHelpFilePath;
helpFilePath += ">NewWin"; //NewWin is defined in ContextHelp.hpj, in the section "Window"
CPoint p((DWORD)lParam) ;
ClientToScreen(&p) ;
CWnd *pWnd = WindowFromPoint(p) ;
if (pWnd != NULL)
{
if (pWnd == this)
helpID = IDD + 0x20000 ; // convert to correct help ID
else
helpID = pWnd->GetDlgCtrlID() + 0x60000 ;
::WinHelp(pWnd->m_hWnd, helpFilePath, HELP_CONTEXT, helpID);
}
}
for more information download the pdf file at:
http://www.smountain.com/resource/CPPWinHelp.pdf[^]
good luck.
|
|
|
|

|
Hallo!,
I tried the code and it works great! Thank you!!! :DDD
I still have a problem though... that when I use the help popup, first comes the popup and then the CONTEXT help :/ how can I avoid this?
Thank you very much in advance!
Xia.
|
|
|
|
|

|
Hi,
You can try this. I am using it and works fine.
Step 1] Add BOOL bPopup in CYourApp class, initialize it to FALSE.
Step 2] Override WinHelp in CYourApp & replace it by this code
void CYourApp::WinHelp(DWORD dwData, UINT nCmd)
{
CWinApp::WinHelp(dwData, bPopup? HELP_CONTEXTPOPUP: nCmd);
bPopup = FALSE; // No popup until I say
}
Step 3] Replace CYourView::OnHelpHitTest by this one:
int CYourView::OnHelpHitTest(WPARAM, LPARAM lParam)
{
// Find the child window ID under mouse cursor
int nID = OnToolHitTest((DWORD)lParam, NULL);
if(nID != -1)
{
// Show help in popup window
((CCatApp *)AfxGetApp())->bPopup = TRUE;
return HID_BASE_COMMAND+nID;
}
else
return 0;
}
Tanmay
|
|
|
|

|
Can you please tell me the way remove the shortcut key F1 so that the help of my application does not start when user presses F1 key.
Thanks,
Manoj Phirke
|
|
|
|
|
|

|
This article is a partial answer for dialogs also but is not a complete answer for dialogs. Note that I am still using VC 5 so if MFC has been improved since then in a relevant manner then I would not know about it.
There is a CDialog::OnHelpHitTest but the WM_HELPHITTEST message is not sent. The WM_COMMANDHELP message is sent when (context-sensitive) help mode is active but GetFocus won't get the control that is clicked.
It is not possible to detect help mode using CWinApp::m_bHelpMode because it is false when the WM_COMMANDHELP message is sent. CDialog does not have m_bHelpMode member.
So to allow determination of help mode, a member that serves the purpose of the m_bHelpMode member (in other classes) can be created for the dialog and the member can be called m_bHelpMode. It can be set to TRUE prior to the processing of the SC_CONTEXTHELP system command and FALSE following it.
Then in OnCommandHelp for the dialog if help mode is active then the following can be used instead of GetFocus:
CPoint Point(GetMessagePos());
CWnd* pWnd = WindowFromPoint(Point);
Just be careful while debugging because a breakpoint prior to the WindowFromPoint will make you think it's not working when you single-step over it.
|
|
|
|

|
Peter Moss has an article dealing with adding Context Sensitive help to Dialogs. The article is:
Implementing Context-sensitive Help in MFC Apps
By Peter Moss
http://www.codeproject.com/winhelp/mfchelp.asp
Don't know if it works with VC 5 but it does with VC 6.
|
|
|
|

|
Thank you.
I don't know if I was clear but I have context-sensitive help working quite well for my dialog. I think with my comments it should be very easy for others to do also.
For my dialog, I am happy to have the default help topic be shown when the F1 key is pressed. I probably can very easily implement the Shift-F1 keys to activate context-sensitive help but I have not done that yet. Otherwise the solution I have works greate for my dialog. That is, when the "context-sensitive help" button (the one in the upper-right with the "?") is pressed and the context-sensitive help mode is active, then when a control is clicked on the context-sensitive help topic for that control is shown.
|
|
|
|

|
The context-sensitive help works great! How do I get the F1 help to do the same? If the cursor is in a edit box and the user presses F1, I want it to retrieve the same help as if the user had used the context-sensitive help in the same edit box.
Any suggestions?
|
|
|
|

|
I'll have to think on this one. Sounds like I need to add a new section for the F1 key. I have an idea. I will try it out today, if it works, I'll post it.
Roger Allen
Sonork 100.10016
I have a terminal disease. Its called life!
|
|
|
|

|
I added the following code to the CFormView class:
afx_msg LRESULT OnCommandHelp(WPARAM wParam, LPARAM lParam);
ON_MESSAGE(WM_COMMANDHELP, OnCommandHelp)
LRESULT CContextHelpView::OnCommandHelp(WPARAM wParam, LPARAM lParam)
{
CWnd *pWnd = GetFocus();
if (pWnd != NULL)
{
DWORD helpID;
if (pWnd == this)
helpID = IDD + 0x20000 ; else
helpID = pWnd->GetDlgCtrlID() + 0x60000 ;
AfxGetApp()->WinHelp(helpID);
return TRUE;
}
return FALSE; }
The above code worked well in my example.
Roger Allen
Sonork 100.10016
I have a terminal disease. Its called life!
|
|
|
|

|
There is an error in your contexthelp.hpj file. In the [map] section, you have hard coded the path to the afxhelp.hm file, and that path does not match the path I used on my machine. To make it more user friendly, please include a copy of the file with the demo and reference that copy.
Also, after changing the path so that it compiles, I ran the demo, and when I click on the Contextsensitve help button to get the question mark cursor, then on one of the buttons on the form, I get a "topic not found" error.
CPUA 0x5041
Sonork 100.11743 Chicken Little
My pet, My pet stick
Nicer than a twig
Cooler than a rock.
(Microsoft ad)
Within you lies the power for good - Use it!
|
|
|
|

|
PJ Arends wrote:
I get a "topic not found" error
Is an upto date version of the help file in the release/debug directory of the app when you ran it?
I will also take a look at the [map] section. Its just that the .hpj file was automatically generated.
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
Context sensitive help does not distinguish individual controls on a FormView. This sorts that problem
| Type | Article |
| Licence | CPOL |
| First Posted | 17 Jul 2002 |
| Views | 95,032 |
| Bookmarked | 28 times |
|
|