临江网

 找回密码
 点这里注册

QQ登录

只需一步,快速开始

搜索
热搜: 临江老照片

编辑推荐

查看: 1342|回复: 0
打印 上一主题 下一主题

Better Hint Windows D2 D3

[复制链接]

1368

主题

0

好友

3367

积分

五品

Rank: 6Rank: 6

帖子
1397
积分
3367
注册时间
2007-5-22
跳转到指定楼层
楼主
发表于 2007-7-18 22:32:27 |只看该作者 |倒序浏览
Better Hint Windows D2 D3
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. I think you can use LockResource, passing it a cursor handle, to get a pointer to a CURSORSHAPE structure on Win16, but I don't have it installed any more so I can't be sure. It is supposed to work that way on Win32 as well, but it appears to be a bug in Windows. If anyone get's this working under Delphi 1.x, please let me know so I can post it here.



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

procedure TMainForm.FormCreate(Sender: TObject);
begin
Application.OnShowHint := GetHintInfo;
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: }

procedure TMainForm.GetHintInfo(var HintStr: string;
var CanShow: boolean;
var HintInfo: THintInfo);
var
II: TIconInfo;
Bmp: Windows.TBitmap;
begin
with HintInfo do begin
// Make sure we have a control that fired the hint.
if HintControl = NIL then exit;
// Convert the cursor's coordinates from relative to hint to
// relative to screen.
HintPos := HintControl.ClientToScreen(CursorPos);
// Get some information about the cursor that is used for the
// hint control
GetIconInfo(Screen.Cursors[HintControl.Cursor], II);
// Get some information about the bitmap representing the cursor
GetObject(II.hbmMask, SizeOf(Windows.TBitmap), @Bmp);
// If the info did not include a color bitmap then the mask bitmap
// is really two bitmaps, an AND & XOR mask. Increment our Y
// position by the bitmap's height.
if II.hbmColor = 0 then
inc(HintPos.Y, Bmp.bmHeight div 2)
else
inc(HintPos.Y, Bmp.bmHeight);
// Subtract out the Y hotspot position
dec(HintPos.Y, II.yHotSpot);
// We are responsible for cleaning up the bitmap handles returned
// by GetIconInfo.
DeleteObject(II.hbmMask);
DeleteObject(II.hbmColor);
end;
end;
分享到: QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏0 顶0 踩0

发表回复

高级模式
B Color Image Link Quote Code Smilies
验证码 换一个

回顶部