从系统中取得指定资源图像(转载)

博客介绍了Winuser.h中定义的系统常用资源,如对话框图标、按钮图像等,给出了部分OEM资源序号和标准ICON的ID,还展示了通过LoadBitmap从系统中取得指定资源图像的代码示例,包括获取位图和图标的操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在Winuser.h中定义了一些系统常用的资源,比如对话框的图标,某些按钮上的图像等。
以下是部分OEM资源序号和一些标准ICON的ID:
//---------------------------------------------------------------------------

// OEM Resource Ordinal Numbers
#define OBM_OLD_CLOSE       32767
#define OBM_SIZE            32766
#define OBM_OLD_UPARROW     32765
#define OBM_OLD_DNARROW     32764
#define OBM_OLD_RGARROW     32763
#define OBM_OLD_LFARROW     32762
#define OBM_BTSIZE          32761
#define OBM_CHECK           32760
#define OBM_CHECKBOXES      32759
#define OBM_BTNCORNERS      32758
#define OBM_OLD_REDUCE      32757
#define OBM_OLD_ZOOM        32756
#define OBM_OLD_RESTORE     32755
#define OBM_CLOSE           32754
#define OBM_UPARROW         32753
#define OBM_DNARROW         32752
#define OBM_RGARROW         32751
#define OBM_LFARROW         32750
#define OBM_REDUCE          32749
#define OBM_ZOOM            32748
#define OBM_RESTORE         32747
#define OBM_REDUCED         32746
#define OBM_ZOOMD           32745
#define OBM_RESTORED        32744
#define OBM_UPARROWD        32743
#define OBM_DNARROWD        32742
#define OBM_RGARROWD        32741
#define OBM_LFARROWD        32740
#define OBM_MNARROW         32739
#define OBM_COMBO           32738
#define OBM_UPARROWI        32737
#define OBM_DNARROWI        32736
#define OBM_RGARROWI        32735
#define OBM_LFARROWI        32734


// Standard Icon IDs
#define IDI_APPLICATION     MAKEINTRESOURCE(32512)
#define IDI_HAND            MAKEINTRESOURCE(32513)
#define IDI_QUESTION        MAKEINTRESOURCE(32514)
#define IDI_EXCLAMATION     MAKEINTRESOURCE(32515)
#define IDI_ASTERISK        MAKEINTRESOURCE(32516)
#define IDI_WINLOGO         MAKEINTRESOURCE(32517)


我们可以通过LoadBitmap从系统中取得指定资源图像:

void __fastcall TMainForm::Button1Click(TObject *Sender)
{
    for(int i=0; i<30; i++)
    {
        HBITMAP hBitmap = ::LoadBitmap(NULL, MAKEINTRESOURCE(32734 + i));
        TImage *img = new TImage(this);
        img->Picture->Bitmap->Handle = hBitmap;
        Canvas->Draw(9 + i *16, 9, img->Picture->Bitmap);
        delete img;
        DeleteObject(hBitmap);
    }
    for(int i=0; i<5; i++)
    {
        HICON hIcon = ::LoadIcon(NULL, MAKEINTRESOURCE(32512 + i));
        TImage *img = new TImage(this);
        img->Picture->Icon->Handle = hIcon;
        Canvas->Draw(10 + i *32, 50, img->Picture->Icon);
        delete img;
        DeleteObject(hIcon);
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值