Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to display hints always under the mouse cursor Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
30-Aug-02
Category
Others
Language
Delphi 2.x
Views
92
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

How to display hints always under the mouse cursor

Answer:

This code snippet shows how to make your popup hint windows behave more like normal 
windows apps. Instead of always being square under the control they belong to, they 
are based on where the mouse is. This uses the GetIconInfo API, which is only 
available for Win32.

Add the following to your main form's OnCreate event handler:


1   procedure TMainForm.FormCreate(Sender: TObject);
2   begin
3     Application.OnShowHint := GetHintInfo;
4   end;



Add the following declaration to your main form's protected declartion:


procedure GetHintInfo(var HintStr: string; var CanShow: boolean; var HintInfo: 
THintInfo);


And, finally, add this procedure to your main form:

5   
6   procedure TMainForm.GetHintInfo(var HintStr: string; var CanShow: boolean; var 
7   HintInfo: THintInfo);
8   var
9     II: TIconInfo;
10    Bmp: Windows.TBitmap;
11  begin
12    with HintInfo do
13    begin
14      {Make sure we have a control that fired the hint}
15      if HintControl = nil then
16        exit;
17      {Convert the cursor's coordinates from relative to hint to relative to screen}
18      HintPos := HintControl.ClientToScreen(CursorPos);
19      {Get some information about the cursor that is used for the hint control}
20      GetIconInfo(Screen.Cursors[HintControl.Cursor], II);
21      {Get some information about the bitmap representing the cursor}
22      GetObject(II.hbmMask, SizeOf(Windows.TBitmap), @Bmp);
23      {If the info did not include a color bitmap then the mask bitmap is really two 
24  bitmaps, an AND & XOR mask. Increment our Y position by the bitmap's height}
25      if II.hbmColor = 0 then
26        inc(HintPos.Y, Bmp.bmHeight div 2)
27      else
28        inc(HintPos.Y, Bmp.bmHeight);
29      {Subtract out the Y hotspot position}
30      dec(HintPos.Y, II.yHotSpot);
31      {We are responsible for cleaning up the bitmap handles returned by GetIconInfo}
32      DeleteObject(II.hbmMask);
33      DeleteObject(II.hbmColor);
34    end;
35  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC