Solved

Right click for what's this help

Posted on 1998-05-11
13
174 Views
Last Modified: 2011-09-20
I want to be able to right click on controls on my form and code to bring up context help for that control but in the format of the What's This help. (small yellow box with text from the help file). I have the help file written and working from the what's this button but i want it from the right click.
0
Comment
Question by:JasonC
  • 4
  • 3
  • 2
  • +4
13 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1344455
Just an idea :

What about assigning code to the mousedown event of the form (or spmething) :

 Cycling through all the components on  the form, looking at their position on the form and determining if x,y position of mouse click is on their control. If show show your yellow box.

Regards, ZiF.
0
 

Author Comment

by:JasonC
ID: 1344456
Thats fine, but how do I get the help window to appear (like the what's this help)
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1344457
Hi Jason

How are you currently getting the help to appear when the user clicks the what's this button?  Wouldn't the code be the same?

JB
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 8

Expert Comment

by:ZifNab
ID: 1344458
Agree, I thought you already had this code to let the help appear. Are am I misinterpreting something?

Hi JasonC,

The Delphi informant of April (I look it up) has a source code of the What's this help...

Regards, ZiF.
0
 
LVL 1

Expert Comment

by:michaue
ID: 1344459
Have you tried to use the THintWindow component to show the What's This help?
0
 
LVL 1

Expert Comment

by:Greedy
ID: 1344460
This was posted by Zif awile back

function RevealHint (Control: TControl): THintWindow;
{----------------------------------------------------------------}
{ Pops up Hint window for the specified Control, and returns a   }
{ reference to the hint object so it may subsequently be removed }
{ with RemoveHint (see below).                                   }
{----------------------------------------------------------------}
 var
   ShortHint: string;
   AShortHint: array[0..255] of Char;
   HintPos: TPoint;
   HintBox: TRect;
 begin
   { Create the window: }
   Result := THintWindow.Create(Control);

   { Get first half of hint up to '|': }
   ShortHint := GetShortHint(Control.Hint);

   { Calculate Hint Window position & size: }
   HintPos := Control.ClientOrigin;
   Inc(HintPos.Y, Control.Height + 6);    <<<< See note below
   HintBox := Bounds(0, 0, Screen.Width, 0);
   DrawText(Result.Canvas.Handle,
       StrPCopy(AShortHint, ShortHint), -1, HintBox,
       DT_CALCRECT or DT_LEFT or DT_WORDBREAK or DT_NOPREFIX);
   OffsetRect(HintBox, HintPos.X, HintPos.Y);
   Inc(HintBox.Right, 6);
   Inc(HintBox.Bottom, 2);

   { Now show the window: }
   Result.ActivateHint(HintBox, ShortHint);
 end; {RevealHint}

 procedure RemoveHint (var Hint: THintWindow);
{----------------------------------------------------------------}
{ Releases the window handle of a Hint previously popped up with }
{ RevealHint.                                                    }
{----------------------------------------------------------------}
 begin
   Hint.ReleaseHandle;
   Hint.Free;
   Hint := nil;
 end; {RemoveHint}

0
 

Author Comment

by:JasonC
ID: 1344461
OK , maybe I have my wires crossed, the button that appears next to the close and minimize, maximize buttons (I think the whats this button). When this is clicked an arrow appers and then I click on another control on the form. Now this opens a small window that displays help in the form of a hint but gets its information from the specified help file and context ID.
0
 
LVL 1

Expert Comment

by:Greedy
ID: 1344462
is that what you want of what your doing???
0
 

Author Comment

by:JasonC
ID: 1344463
This is what is happening now, but I have to go to the whats this button, I want to be able to right click on the control and have the same help popping up, without going to the 'whats this' help button.
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 1344464
What about using the MouseDown, check if button=mbRight.  If so, do something like:

Function TForm1.ShowHelp(Sender: TObject);
begin
   Application.helpContext(TWinControl(Sender).HelpContext);
end;

in the MouseDown event do,

...
If button=mbRight then
   ShowHelp(Sender);


Tell each of your controls to use this common function for the mousedown event.

I havent tried this, but I think it is where I would start.

Hope this works :)

Stuart.
0
 

Author Comment

by:JasonC
ID: 1344465
Thanks Stuart but we are not quite there yet, this will bring up the help in the standard help window, now all I need is it to come up in the window like the 'whats's this' button.
Now Zif, you said something about the code for the what's this button in the April Delphi informant, could you share? I don't get the informant.

Thanks in advance
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1344466
JasonC,

I'm not going to be in the office today, but I guess it isn't what you wanted, because you don't want to click on the what's this button. But I think they have there code placed here  : http://www.informant.com (see the delphi samples).

Regards Zif.
0
 
LVL 4

Accepted Solution

by:
BoRiS earned 50 total points
ID: 1344467
JasonC

What I used was the API call named WinHelp()

like so

I asigned a popup menu to a control like a button for instance the I got the context ID from the help file for the popup on this control then passed the API

procedure TForm1.WhatIs1Click(Sender: TObject);
begin
 WinHelp(Handle, 'YourHelpFilePath', HELP_CONTEXTPOPUP, 0);
end;

the buttons Helpcontext I asigned the correct context number e.g. 245

to handle this through the whole form get the sender first then popup the context for that control

If you need help let me know I'll send you a small demo...

Later
BoRiS
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

777 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