- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我只是打开我的 FindDialog:
FindDialog.Execute;
在我的 FindDialog.OnFind 事件中,我想将光标更改为沙漏形以搜索大文件,这可能需要几秒钟。所以在 OnFind 事件中我这样做:
Screen.Cursor := crHourglass;
(code that searches for the text and displays it) ...
Screen.Cursor := crDefault;
发生的情况是,在搜索文本时,光标正确地变为沙漏(或 Vista 中的旋转圆圈),然后在搜索完成时返回到指针。
但是,这只发生在主窗体上。 FindDialog 本身不会发生这种情况。搜索期间默认光标保留在 FindDialog 上。当搜索发生时,如果我将光标移到 FindDialog 上,它会更改为默认值,如果我将其移开并移到主窗体上,它会变成沙漏。
这看起来不像是应该发生的事情。我是否做错了什么,或者是否需要做一些特殊的事情才能使光标在所有表单上成为沙漏?
作为引用,我使用的是 Delphi 2009。
最佳答案
我猜这是有原因的。查找对话框不是一个表单,而是一个对话框(通用对话框)。
您可以尝试设置类光标(对对话框的控件没有影响);
procedure TForm1.FindDialog1Find(Sender: TObject);
begin
SetClassLong(TFindDialog(Sender).Handle, GCL_HCURSOR, Screen.Cursors[crHourGlass]);
try
Screen.Cursor := crHourglass;
try
// (code that searches for the text and displays it) ...
finally
Screen.Cursor := crDefault;
end;
finally
SetClassLong(TFindDialog(Sender).Handle, GCL_HCURSOR, Screen.Cursors[crDefault]);
end;
end;
另一种方法是在搜索期间子类化 FindDialog 并使用“SetCursor”响应 WM_SETCURSOR 消息。如果我们阻止进一步处理消息,对话框上的控件将不会设置自己的光标。
type
TForm1 = class(TForm)
FindDialog1: TFindDialog;
...
private
FSaveWndProc, FWndProc: Pointer;
procedure FindDlgProc(var Message: TMessage);
...
end;
....
procedure TForm1.FormCreate(Sender: TObject);
begin
FWndProc := classes.MakeObjectInstance(FindDlgProc);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
classes.FreeObjectInstance(FWndProc);
end;
procedure TForm1.FindDialog1Find(Sender: TObject);
begin
FSaveWndProc := Pointer(SetWindowLong(FindDialog1.Handle, GWL_WNDPROC,
Longint(FWndProc)));
try
Screen.Cursor := crHourGlass;
try
// (code that searches for the text and displays it) ...
finally
Screen.Cursor := crDefault;
end;
finally
if Assigned(FWndProc) then
SetWindowLong(FindDialog1.Handle, GWL_WNDPROC, Longint(FSaveWndProc));
// SendMessage(FindDialog1.Handle, WM_SETCURSOR, FindDialog1.Handle,
// MakeLong(HTNOWHERE, WM_MOUSEMOVE));
SetCursor(Screen.Cursors[crDefault]);
end;
end;
procedure TForm1.FindDlgProc(var Message: TMessage);
begin
if Message.Msg = WM_SETCURSOR then begin
SetCursor(Screen.Cursors[crHourGlass]);
Message.Result := 1;
Exit;
end;
Message.Result := CallWindowProc(FSaveWndProc, FindDialog1.Handle,
Message.Msg, Message.WParam, Message.LParam);
end;
关于delphi - 为什么我的光标在 Delphi 的 FindDialog 中没有变成沙漏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2660799/
在Delphi 2009中,我做了一个简单的: FindDialog.Execute; FindDialog 窗口按其应有的方式保留在程序主窗口的顶部。 但是,如果我在自己的程序窗口上从其他程序打开另
我只是打开我的 FindDialog: FindDialog.Execute; 在我的 FindDialog.OnFind 事件中,我想将光标更改为沙漏形以搜索大文件,这可能需要几秒钟。所以在 OnF
在“C++ GUI Programming with Qt 4”一书中,第 1 部分第 2 章中有一个 FindDialog Widget 示例逐步显示,现在我正在尝试使用 qmake 生成的 Mak
我是一名优秀的程序员,十分优秀!