从系统中取得指定资源图像

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

// OEM Resource Ordinal Numbers
#define OBM_OLD_CLOSE32767
#define OBM_SIZE32766
#define OBM_OLD_UPARROW32765
#define OBM_OLD_DNARROW32764
#define OBM_OLD_RGARROW32763
#define OBM_OLD_LFARROW32762
#define OBM_BTSIZE32761
#define OBM_CHECK32760
#define OBM_CHECKBOXES32759
#define OBM_BTNCORNERS32758
#define OBM_OLD_REDUCE32757
#define OBM_OLD_ZOOM32756
#define OBM_OLD_RESTORE32755
#define OBM_CLOSE32754
#define OBM_UPARROW32753
#define OBM_DNARROW32752
#define OBM_RGARROW32751
#define OBM_LFARROW32750
#define OBM_REDUCE32749
#define OBM_ZOOM32748
#define OBM_RESTORE32747
#define OBM_REDUCED32746
#define OBM_ZOOMD32745
#define OBM_RESTORED32744
#define OBM_UPARROWD32743
#define OBM_DNARROWD32742
#define OBM_RGARROWD32741
#define OBM_LFARROWD32740
#define OBM_MNARROW32739
#define OBM_COMBO32738
#define OBM_UPARROWI32737
#define OBM_DNARROWI32736
#define OBM_RGARROWI32735
#define OBM_LFARROWI32734


// Standard Icon IDs
#define IDI_APPLICATIONMAKEINTRESOURCE(32512)
#define IDI_HANDMAKEINTRESOURCE(32513)
#define IDI_QUESTIONMAKEINTRESOURCE(32514)
#define IDI_EXCLAMATIONMAKEINTRESOURCE(32515)
#define IDI_ASTERISKMAKEINTRESOURCE(32516)
#define IDI_WINLOGOMAKEINTRESOURCE(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);
}
}

你可能感兴趣的:(系统)