Board index » cppbuilder » How to implement the "What's This?" form border icon?

How to implement the "What's This?" form border icon?


2008-02-21 11:45:03 AM
cppbuilder10
Howdy,
I'm using C++ Builder 6.0, which supports only WinHelp-type .HLP files
(at least natively). I managed to get an acceptable HTML Help-type
.CHM file working using a Delphi unit posted on the HelpScribble HTML
Help composer web site. This did not require registering a help
viewer, but rather hooks directly into a .LIB file created from the
Windows-supplied hhctrl.ocx. My compile options may be screwy since
following the directions given did not work, but I finally figured out
what was wrong and it's hunky-dory now.
My problem is that, while I can code a Help button that provides all
manner of help (topic, contents, index, context), I do not know how to
code the "What's This?" form border icon, nor the F1 key, to display
context-sensitive help. I've surfed the 'Net for the equivalent of
several days without success. I find articles that *mention* the "?"
icon, but nothing that tells me how to hook it up.
I thought I could use an OnClick event to discern whether the cursor
was an arrow, in which case I proceed with the normal routine, or a
question mark, in which case I instead display context-sensitive help.
But it seems that the cursor turns back into an arrow as soon as the
click is made, so it always comes to the event as an arrow.
Borland must surely support this, since clicking the icon does turn
the cursor into a question mark. I just don't know what to do after
that.
Can anyone help me out here? And conversely, if anyone needs to know
how to get HTML Help working in the first place (on versions prior to
2007, where it's built-in), I can provide detailed instructions.
Thanks in advance,
{*word*104}Sapien
 
 

Re:How to implement the "What's This?" form border icon?

Ciao, the button obtained with
Form1->BorderIcons << biHelp
just generates a WM_HELP message that you can intercept either with
something like
void __fastcall WhenHelp (TMessage& Message);
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(WM_HELP, TMessage, WhenHelp)
END_MESSAGE_MAP(TForm)
Or with the event handler 'OnHelp' of 'TApplicationEvents'
To deal with chm help files
Instead of static linking, my advice is use dynamic load of hhctrl.ocx
as you can see in the following c++ unit:
matteo.gattanini.googlepages.com/unt_HtmlHelp.7z
 

Re:How to implement the "What's This?" form border icon?

On Thu, 21 Feb 2008 04:25:02 -0800 (PST), XXXX@XXXXX.COM
wrote:
Quote
To deal with chm help files
Instead of static linking, my advice is use dynamic load of hhctrl.ocx
as you can see in the following c++ unit:
matteo.gattanini.googlepages.com/unt_HtmlHelp.7z
Thank you for your reply. However, the cls_HtmlHelp class header
includes header unt_MatCommon.h, which I cannot find on your site. Can
you tell me where it might be?
Thanks,
{*word*104}Sapien
 

{smallsort}

Re:How to implement the "What's This?" form border icon?

On 21 Feb, 22:58, {*word*104}Sapien wrote:
Quote
Thank you for your reply. However, the cls_HtmlHelp class header
includes header unt_MatCommon.h, which I cannot find on your site. Can
you tell me where it might be?
Ehm, ok, if you want a ready to use solution, here it is:
matteo.gattanini.googlepages.com/bcb_HtmlHelp.7z
I have included in 'cls_HtmlHelp' the external functions contained in
unt_MatCommon.h,
removing the include (was just necessary to wrap the call to
ShellExecute API)
Note two things:
1) This example hooks help calls assigning a custom handler to
Application->OnHelp event
2) When you enable [biHelp] BorderIcon, all help commands become
popups requests
 

Re:How to implement the "What's This?" form border icon?

On Fri, 22 Feb 2008 01:36:29 -0800 (PST), XXXX@XXXXX.COM
wrote:
Quote
On 21 Feb, 22:58, {*word*104}Sapien wrote:
>Thank you for your reply. However, the cls_HtmlHelp class header
>includes header unt_MatCommon.h, which I cannot find on your site. Can
>you tell me where it might be?

Ehm, ok, if you want a ready to use solution, here it is:

matteo.gattanini.googlepages.com/bcb_HtmlHelp.7z

I have included in 'cls_HtmlHelp' the external functions contained in
unt_MatCommon.h,
removing the include (was just necessary to wrap the call to
ShellExecute API)

Note two things:
1) This example hooks help calls assigning a custom handler to
Application->OnHelp event
2) When you enable [biHelp] BorderIcon, all help commands become
popups requests
Thanks, I'll look into this.
Actually, I did manage to use your code to (almost) get my code
working. It is still complaining about data type mismatches, which
are artifacts of mixing VCL with MFC. For instance, the MFC struct
HELPINFO contains hItemHandle, which MS says is a HANDLE data type but
which BCB claims is a void pointer. I had to cast it as a HWND__
pointer to please BCB:
wc = FindControl((HWND__ *)hi->hItemHandle);
Your code does not contain this cast, so I wonder how my setup may be
different. I am still unable to fix this statement:
HtmlHelp(this->Handle, Application->HelpFile.c_str(), HH_HELP_CONTEXT,
wc->HelpContext);
This throws the error:
[C++ Error] main.cpp(359): E2342 Type mismatch in parameter
'hwndCaller' (wanted 'unsigned int', got 'HWND__ *')
Casting the Handle as unsigned (HWND__ doesn't work):
HtmlHelp((unsigned)this->Handle, Application->HelpFile.c_str(),
HH_HELP_CONTEXT, wc->HelpContext);
allows it to compile and diagnostics show that the correct context ID
is in wc->HelpContext, but HTML Help does not appear.
I wish I knew what was different about my IDE or project setup from
everyone else's, as many things I find do not work for me :-(
{*word*104}Sapien
 

Re:How to implement the "What's This?" form border icon?

Quote
On 21 Feb, 22:58, {*word*104}Sapien wrote:
Your code does not contain this cast, so I wonder how my setup may be
different. I am still unable to fix this statement:
HtmlHelp(this->Handle, Application->HelpFile.c_str(), HH_HELP_CONTEXT,wc->HelpContext);
This throws the error:
[C++ Error] main.cpp(359): E2342 Type mismatch in parameter 'hwndCaller' (wanted 'unsigned int', got 'HWND__ *')
That's strange, the VCL property 'TWinControl::Handle'
is a HWND type, not a pointer.
From 'htmlhelp.h' it is apparent that 'hwndCaller'
is also a HWND type.
The question is: do 'this' points to a standard
TWinControl?
Try to use the global variable 'Application->Handle'
instead of 'this->Handle', and see what happens.
However I would not mess with HELPINFO structure
unless forced to do so: you may leave
OnHelp event to do it for you, because it already
provides HelpContext ID associated with
involved control (int Data), as you can
see in my example.
Regarding 'HELPINFO.hItemHandle', in my BCB5 environment
(standard installation on windows XP)
the windows interface is provided in 'windows.pas',
which tells that 'hItemHandle' is a 'THandle',
which is a 'LongWord', that should be equivalent
to the c++ 'unsigned int', not a pointer type.
'HWND' is also a 'LongWord'.
Hope this helps.