从系统中取得指定资源图像
当前位置:以往代写 > C/C++ 教程 >从系统中取得指定资源图像
2019-06-13

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

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

在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);
   }
}
//---------------------------------------------------------------------------

    关键字:

在线提交作业