如何从HICON确定图标的大小? [英] How to determine the size of an icon from a HICON?
本文介绍了如何从HICON确定图标的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个由 HICON
标识的图标,我想以自定义控件为中心绘制。
I have an icon identified by an HICON
handle that I want to draw centered on a custom control.
如何确定图标的大小以便我可以计算出正确的绘图位置?
How do I determine the size of the icon so that I can calculate the correct drawing position?
推荐答案
Win32 GetIconInfo
调用将返回图标的源位图,作为其响应的一部分。您可以从中获取图标图像大小。
The Win32 GetIconInfo
call will return, as part of its response, the icon's source bitmap. You can get the icon image size from this.
Dim IconInf As IconInfo
Dim BMInf As Bitmap
If (GetIconInfo(hIcon, IconInf)) Then
If (IconInf.hbmColor) Then ' Icon has colour plane
If (GetObject(IconInf.hbmColor, Len(BMInf), BMInf)) Then
Width = BMInf.bmWidth
Height = BMInf.bmHeight
BitDepth = BMInf.bmBitsPixel
End If
Call DeleteObject(IconInf.hbmColor)
Else ' Icon has no colour plane, image data stored in mask
If (GetObject(IconInf.hbmMask, Len(BMInf), BMInf)) Then
Width = BMInf.bmWidth
Height = BMInf.bmHeight \ 2
BitDepth = 1
End If
End If
Call DeleteObject(IconInf.hbmMask)
End If
这篇关于如何从HICON确定图标的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文