gpt4 book ai didi

delphi - 列表框中的图像预览

转载 作者:行者123 更新时间:2023-12-03 19:46:06 25 4
gpt4 key购买 nike

将鼠标悬停在文件名列表框中的项目上时,如何显示图像的预览(几乎像提示)?我尝试显示表单并加载图像,但是当显示预览表单时,我失去了对列表框的关注,这意味着当我移动鼠标时,转到列表中的下一个项目时预览图像不会更改。

谢谢,彼得。



根据TOndrej的回答,我尝试实现自定义THintWindow,但是Canvas.StretchDraw不会绘制作为参数发送的位图。任何想法为什么不呢?文本正常显示。

procedure TFormMain.DisplayPreview(HintImage: TBitmap);
var
CustomHint: THintWindow;
Rect: TRect;
MousePoint: TPoint;
begin
*{
Based on Source: http://www.chami.com/tips/delphi/112996D.html
}*
GetCursorPos(MousePoint);
with Rect do
begin
// set the position and size of the hint window
Left := MousePoint.X;
Top := MousePoint.Y;
Right := Left + 50;
Bottom := Top + 25;
end;

CustomHint := THintWindow.Create(Self);
try
with CustomHint do
begin
// set the background color
//Color := clNone;
**Canvas.StretchDraw(Rect, HintImage);**
ActivateHint(Rect, 'Hint');
Application.ProcessMessages;
//
// perform your tasks here
// before closing the hint window
//
Sleep(500);
ReleaseHandle;
end;

finally
if Assigned(CustomHint) then
CustomHint.Free;
end;
end;

最佳答案

在我看来,您似乎需要自定义提示窗口。为此,您应该编写一个新的THintWindow后代,或者通过将新类分配给HintWindowClass单元中的Forms全局变量,将其全局设置为整个应用程序,或者编写自己的列表框后代来处理CM_HINTSHOW消息,并将新的提示窗口类分配给HintInfo.HintWindowClass。 (HintInfo指向VCL在CM_HINTSHOW消息中传递给您的控件的记录。)

关于delphi - 列表框中的图像预览,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/767866/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com