1. CButton圖片

(1) CButton

CButton mbutton;
mbutton.ModifyStyle(0, BS_BITMAP);

HINSTANCE hInstance = AfxFindResourceHandle(
  MAKEINTRESOURCE(IDB_BITMAP),
  RT_GROUP_ICON);

HBITMAP hBitmap = ::LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BITMAP));    
mBitmap.SetBitmap(hBitmap);

(2) 按下不同圖片

Initialize:
mbutton.SubclassDlgItem(IDC_BUTTON, this);
mbutton.ModifyStyle(0, BS_OWNERDRAW);
mbutton.LoadBitmaps(IDB_UP, IDB_DOWN);

2. CBitmapButton圖片

裝載各種狀態的圖片 CBitmapButton::LoadBitmaps
連結想要的按鈕 CBitmapButton::SubclassDlgItem
使按鈕適合圖片大小 CBitmapButton::SizeToContent

CBitmapButton btn;
btn.LoadBitmaps(IDB_UP, IDB_DOWN);
btn.SubclassDlgitem(IDB_BITMAP);
btn.SizeToContent(IDC_BUTTON1, this);

3. CStatic 圖片

(1) CStatic only

CStatic   m_static;
m_static.Create(_T( " "), WS_CHILD|WS_VISIBLE|SS_BITMAP, rect,this, IDC_STATIC);
m_static.SetBitmap(::LoadBitmap(NULL,MAKEINTRESOURCE(IDB_BITMAP)));

(2) CStatic + HBITMAP

HBITMAP   hbitmap;
CStatic   *pStatic=(CStatic *)GetDlgItem(IDC_SHOWBMP);
HBITMAP   Bitmap;
pStatic-> ModifyStyle(0xF,SS_BITMAP|SS_CENTERIMAGE);
pStatic-> SetBitmap(hBitmap);

4. 加入 tips

4.1 PreTranslateMessage:

mctrl.RelayEvent(pMsg);

4.2 Initialize:

CToolTipCtrl mctrl;
EnableToolTips(TRUE);
mctrl.Create(this);
mctrl.Activate(TRUE);
mctrl.SetTipTextColor(RGB(0x00, 0xff, 0xff));
mctrl.SetDelay(100);

edisonx 發表在 痞客邦 PIXNET 留言(0) 人氣()