我是否仅限于 Delphi 7 下 Controls.pas 中定义的光标编号?
我在 Windows 7 下使用 Delphi 7 下载文件。
我想在下载过程中更改光标。
我设置了 Screen.Cursor := crHourGlass;
,但是,在查看 Controls.pas
中的常量光标编号后,我想知道是否还有其他数字我可以使用将光标更改为(我不想将光标添加到我的资源文件中,我只想使用无需添加资源即可使用的标准数字 )。
I am using Delphi 7 under Windows 7 to download files.
I want to change the cursor during the download.
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 ).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
否。除了内置光标常量之外的其他数字将生成默认光标它与
TCursor(crDefault)
相同(换句话说 -HCURSOR(Screen.Cursors[crDefault])
)。这些内置游标驻留在应用程序资源中,并在 VCL 启动时预加载。要添加自定义光标,您必须添加 CURSOR 资源,然后加载它并将其添加到 VCL。间接游标构造的更复杂示例 注意 :示例有很多缺陷:1)
DestroyIcon
调用是错误的 2) 如果在所有 API 调用之后进行错误检查,他们会注意到这一点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.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“标准数字”(
crHourglass
、crDefault
等)是 Delphi 的 VCL 提供的预定义光标。您可以定义自己的定义并通过 Windows API 从资源或文件将它们加载到应用程序中,但是没有任何神奇的未发布的 TCursor 定义(或杂散数字)具有任何意义。尝试将 Screen.Cursors[] 设置为未知数字而不首先加载光标将导致数组越界错误,最坏的情况是访问冲突导致显示默认光标(请参阅Forms.pas
中的TScreen.GetCursors
)。简单说明:
TCursorRec
在 VCL 源代码中定义为包含指向下一条记录的指针、索引和游标句柄 (HCURSOR
) 的记录。它基本上是一个单链表,当您通过访问 Cursors 列表来请求游标时,VCL 会从第一项开始遍历列表,然后依次逐步浏览,直到找到符合以下条件的索引:与您请求的索引相匹配(此时它将光标设置为该项目的HCURSOR
值),或者确定未分配您请求的索引,在这种情况下它返回默认光标。The "standard numbers" (
crHourglass
,crDefault
, etc) are the predefined cursors that are provided by Delphi's VCL. You can define your own and load them into the application from a resource or from file via the Windows API, but there are no magic unpublishedTCursor
definitions (or stray numbers) that will mean anything. Trying to set Screen.Cursors[] to an unknown number without first loading a cursor willcause an array out of bounds error at minimum, and an access violation at the worstresult in the default cursor being displayed (seeTScreen.GetCursors
inForms.pas
).Quick explanation:
TCursorRec
is defined in the VCL source as a record containing a pointer to the next record, an index, and a cursor handle (HCURSOR
). It's basically a singly-linked list, and when you ask for a cursor by accessing theCursors
list, the VCL looks through the list starting at the first item and sequentially stepping through until it either finds an index that matches the one you requested (at which point it sets the cursor to that item'sHCURSOR
value), or determines that the index you requested isn't assigned, in which case it returns the default cursor.crHourGlass 的类型为 TCursor,它是一个整数别名(或多或少)。它是一个索引,可用于设置库存游标。
您可以使用添加游标,
因此如果您有新游标的句柄,则可以在 Delphi 中使用它。
请注意,crXXX 常量和 TCursor 类型是在 Controls 中定义的,而 Screen 类是在 Forms 中定义的。所以你可以自己看看代码。
crHourGlass is of type TCursor, which is an integer alias (more or less). It is an Index that can be used to set a cursor from stock.
You can add cursors using
So if you have a handle to a new cursor, you can use that in Delphi.
Note that the crXXX constants an the TCursor type are defined in Controls and the Screen class is defined in Forms. So you can see the code for yourself.