如何可以顯示圖像的預覽(幾乎像一個提示)當我在文件名中的一個列表框將鼠標懸停在一個項目?我試圖展示一個表單並加載圖像,但是當預覽表單顯示時,我失去了列表框的焦點,這意味着當我移動鼠標時,當我轉到列表中的下一項時,預覽圖像不會改變。圖像中的列表框預覽
謝謝,彼得。
我有,基於從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;