vb6 图标在 Windows 上的位置

发布于 2024-11-26 06:42:32 字数 90 浏览 1 评论 0 原文

在哪里可以找到原始的 vb6(或 windows)图标? (.ico 文件)

我需要消息框中出现的错误、警告、问题和信息图标。

多谢。

Where can I find the orginal vb6 ( or windows ) icon? (.ico files)

I need, error, warning, question, and information icons which come up on the messagebox.

Thanks a lot.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

假装爱人 2024-12-03 06:42:32

由于每个操作系统版本的图标可能不同,您可以使用 LoadIcon() 传递标准图标 ID 之一从 Windows 获取图标。
请参阅 http://msdn.microsoft.com/en-us/library/ms648072。 aspx 了解详细信息。
如果您希望将它们作为 .ico 文件,您可以使用资源编辑器从 user32.dll 中提取它们(在您的开发计算机上)。

(更新了科迪·格雷的更正信息)

As the icons can differ for each OS version, you can get the icons from Windows using LoadIcon() passing one of the standard icon IDs.
See http://msdn.microsoft.com/en-us/library/ms648072.aspx for details.
If you want them as .ico files, you can extract them (on your development machine) from user32.dll using a resource editor.

(Updated with corrected info from Cody Gray)

三生路 2024-12-03 06:42:32

标准 Windows 消息框图标在不同版本的 Windows 中发生了多次变化。它们包含在几个系统 DLL 文件中,但您不应该尝试自己动态提取它们。正如我在对另一个答案的评论中提到的,ID 号未记录是有原因的:即因为它们可能在未来的 Windows 版本甚至未来的 Windows 更新中发生更改。也绝对没有理由费尽心思去提取它们。如果您提出要求,Windows 已经为您检索它们。

询问的好方法是使用 LoadIcon 函数,并指定所需图标的 IDI 标识符。 Windows 将返回一个 HICON 值或图标资源的句柄。

既然您提到您正在使用 VB.NET,您还可以使用 SystemIcons,它具有返回任何常见图标的静态属性。这是一个 .NET 包装器,使您不必亲自从 Windows API P/Invoke LoadIcon 函数。

更好的是,如果您只想显示包含其中一个图标的消息框,您只需调用 MessageBox API 函数。告诉 Windows 您想要的 MB_ICON 值,然后就可以了。和以前一样,.NET Framework 已将其封装在同名的 MessageBox

这两个函数的好处是,无论当前的 Windows 版本如何,它们都将始终返回正确的图标。试图澄清该问题的评论似乎表明您希望在当前版本的 Windows 上使用图标。但当然,您不想这样做。这些图标已在整个 Windows shell 中进行了更新,这是有充分理由的,您的应用程序应该利用它们。新的图标更加清晰,更符合整体系统主题。此外,如果您的应用程序仍然使用旧的图标,它会让用户感到困惑并且看起来很不合适。最好总是遵循标准平台约定,而不是尝试做“其他事情”,即使您认为您的“其他事情”出于某种原因比平台默认设置“更好”。你的用户不会同意,你的应用程序就会反映出你的粗制滥造。

由于提出此类问题的人不可避免地会不同意我的观点,并坚持认为无论如何他们都必须这样做,并且这是一个“要求”(无论这意味着什么),我将指出旧的图标在较新版本的 Windows 中不可用。由于某种原因,整个系统中的图标已被完全替换。许可协议还严格禁止从系统 DLL 文件中提取图标并将其与您的应用程序一起重新分发。不要这样做。

另外,在决定应在消息框中显示哪个图标之前,请务必查阅 Microsoft 的 Windows 用户体验交互指南,该指南提供了一些非常方便的规则,用于选择正确的图标来传达正确的消息和符合Windows的基调。我在 我的回答在这里;强烈推荐所有 Windows 应用程序开发人员阅读。

编辑:想要获得有关此问题的更多详细信息就像拔牙一样。我不知道为什么你对你想要完成的事情如此保密,但请注意,将来,你会更幸运地在你的问题中包含这些东西,而不是希望人们会这样做把它从你身上拉出来。大多数人并不像我那么坚持。

不管怎样,您最后提到您正在 VB 6 代码和 .NET 代码之间进行某种类型的互操作。这与使用消息框图标的情况无关。 VB 6 MsgBox 函数与我之前讨论的 Win32 API MessageBox 函数和 .NET MessageBox 类 100% 等效。它们都将使用当前的系统图标,并且不需要任何额外的工作来使它们看起来相同。确保您已将相同的图标说明符传递给所有函数。为了方便起见,这里有一个表格:

VB 6 "MsgBox" Icon Constant | VB.NET "MessageBox" Icon Identifier
---------------------------------------------------------------------------------
vbCritical                  | MessageBoxIcon.Error                
vbQuestion                  | MessageBoxIcon.Question  (DEPRECATED -- do not use)
vbExclamation               | MessageBoxIcon.Warning
vbInformation               | MessageBoxIcon.Information

请注意,“问题”样式图标已被弃用,您不应使用此值。如果您仍在 VB 6 代码中使用它,则应该更改该代码以使用不同的图标(或根本不使用图标)。上面链接的 Windows 用户体验交互指南提供了有关此图标为何被弃用以及如何选择合适的替代品的更多详细信息。

The standard Windows message box icons have changed many times across the various versions of Windows. They're included with a couple of the system DLL files, but you shouldn't try and extract them dynamically yourself. As I mentioned in a comment to another answer, the ID numbers are undocumented for a reason: namely because it's possible for them to change in future versions of Windows or even in future Windows updates. There's absolutely no reason to go through the effort trying to extract them, either. Windows will already retrieve them for you, if you ask nicely.

The nice way of asking is to use the LoadIcon function, and specify the IDI identifier of the icon you want. Windows will return an HICON value, or a handle to an icon resource.

Since you mention that you're using VB.NET, you can also use the SystemIcons class, which has static properties to return any of the common icons. This is a .NET wrapper that saves you from having to P/Invoke the LoadIcon function from the Windows API yourself.

Better yet, if you just want to display a message box containing one of the icons, all you have to do is call the MessageBox API function. Tell Windows the MB_ICON value that you want, and you're off. As before, this has already been wrapped for you by the .NET Framework in the identically-named MessageBox class.

The benefit of both of these functions is that they'll always return the correct icons regardless of the current version of Windows. A comment made attempting to clarify the question seems to suggest that you want to use the old icons on a current version of Windows. But of course, you do not want to do this. The icons have been updated throughout the Windows shell for a good reason, and your application should take advantage of them. The new icons are more clear and fit in better with the overall system theme. Additionally, if your app still uses the old icons, it will be confusing to users and look very out of place. It's always best to follow standard platform conventions, rather than trying to do "something else", even if you think your "something else" is "better" for whatever reason than the platform default. Your users will not agree, and your application will reflect your shoddy craftsmanship.

Since people who ask this type of question inevitably disagree with me and insist that they must do it anyway, and that it is a "requirement" (whatever that means), I'll point out that the old icons are not available in the newer versions of Windows. The icons have been completely replaced throughout the system for a reason. It's also strictly forbidden by the licensing agreements to extract icons from system DLL files and redistribute them with your application. Don't do this.

Also, before deciding on which icon you should display in your message box, be sure to consult Microsoft's Windows User Experience Interaction Guidelines, which provide some very handy rules on selecting the proper icon to convey the right message and fit with the Windows tone. I provide more information on that in my answer here; very much recommended reading for any Windows application developer.

Edit: It's like pulling teeth to get any more details on this question. I'm not sure why you're so secretive about what you're trying to accomplish, but note that in the future, you'll have a lot better luck including these things in your question to start with, rather than hoping people will pull it out of you. Most people aren't nearly as persistent as I am.

Anyway, you finally mention that you're doing some type of interop between VB 6 code and .NET code. That should not be relevant in the case of the message box icons used. The VB 6 MsgBox function is 100% equivalent to the Win32 API MessageBox function and the .NET MessageBox class that I discussed earlier. All of them are going to use the current system icons, and it shouldn't require any extra work to make them look the same. Ensure that you've passed the same icon specifier to all of the functions. Here's a table for convenience:

VB 6 "MsgBox" Icon Constant | VB.NET "MessageBox" Icon Identifier
---------------------------------------------------------------------------------
vbCritical                  | MessageBoxIcon.Error                
vbQuestion                  | MessageBoxIcon.Question  (DEPRECATED -- do not use)
vbExclamation               | MessageBoxIcon.Warning
vbInformation               | MessageBoxIcon.Information

Note that the "Question" style icon has since been deprecated and you should not use this value. If you're still using it in the VB 6 code, you should change that code to use a different icon (or no icon at all). The above-linked Windows User Experience Interaction Guidelines provide more details on why this icon has been deprecated and how to choose a suitable replacement.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文