本文介绍了我限制在Controls.pas中定义的光标数字在Delphi 7下?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows 7下使用 Delphi 7 下载文件。

I am using Delphi 7 under Windows 7 to download files.

我想在下载期间更改光标。

I want to change the cursor during the download.

我设置 Screen.Cursor:= crHourGlass; ,但是,看到 Controls.pas ,我想知道是否有其他数字,我可以用来更改光标到我不想添加一个光标到

I set the Screen.Cursor := crHourGlass; , but , after looking at the constant cursor numbers in Controls.pas, I was wondering whether there are other numbers I can use to change the cursor into ( I don't want to add a cursor to my resource file, I just want to use standard numbers which I can use without having to add resources ).

推荐答案

否。除以外的其他数字将产生与 TCursor(crDefault)(换句话说 - HCURSOR(Screen.Cursors [crDefault]))。这些内置游标驻留在应用程序资源中,并在VCL启动时预加载。要添加自定义光标,请 HAVE 添加CURSOR资源,然后将其加载并将其添加到VCL。

No. Other numbers besides built-in cursors constants will produce a default cursor which is identical to TCursor(crDefault) (in other terms - HCURSOR(Screen.Cursors[crDefault])). These built-in cursors resides in the application resources and preloaded on VCL startup. To add custom cursor you HAVE to add CURSOR resource and then load it and add it to VCL.

procedure TForm1.FormCreate(Sender: TObject); platform;
const
  crCustom = 42;
var
  Cursor: HCURSOR;
begin
  Cursor := LoadCursor(HInstance, 'CUSTOM');
  Win32Check(Cursor <> 0);  // required error check
  Screen.Cursors[crCustom] := Cursor;
  { Done, newly added crCustom is ready to use }

  Self.Cursor := crCustom; // for example - lets show custom cursor

  { also, TScreen object will manage resource handle }
  { and perform cleanup for you, so DestroyCursor call is unnecessary }
end;

NB :示例有许多缺陷:1) DestroyIcon 调用是错误的2)如果在所有API调用后检查错误,他们会注意到它

More complicated example with indirect cursor construction NB: example have numerous flaws: 1) DestroyIcon call is erroneous 2) they'd noticed it if there was error checking after all API calls

这篇关于我限制在Controls.pas中定义的光标数字在Delphi 7下?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 09:44