CBitmap, CButton, HBITMAP and more...
-
This function do not work, why... CSpecialControl is derived from CWnd BOOL CSpecialControl::Create(const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) { BOOL Oktemp; //after this line hbm is null, IDB_BITMAP1 is a valid resource... HBITMAP hbm = ::LoadBitmap(NULL,MAKEINTRESOURCE(IDB_BITMAP1)); //this work CBitmap MyBitmap; MyBitmap.LoadBitmap( IDB_BITMAP1); //this work Oktemp = CWnd::Create (NULL,_T(""),WS_CHILD|WS_CLIPCHILDREN, rect, pParentWnd, nID ,pContext); //this work, I can see the button and catch his command Oktemp &= m_cBouton_1.Create (_T(""),WS_CHILD |BS_PUSHBUTTON|BS_BITMAP|WS_VISIBLE ,CRect(0,0,16,16),pParentWnd,IDC_BUTTONGAUCHE); //and the bitmap is never displayed on the button.... m_cBouton_1.SetBitmap(MyBitmap); m_cBouton_1.ShowWindow(SW_SHOWNORMAL); return Oktemp; } Remi Morin Rmorin@Operamail.com Remi.Morin@Lyrtech.com
-
This function do not work, why... CSpecialControl is derived from CWnd BOOL CSpecialControl::Create(const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) { BOOL Oktemp; //after this line hbm is null, IDB_BITMAP1 is a valid resource... HBITMAP hbm = ::LoadBitmap(NULL,MAKEINTRESOURCE(IDB_BITMAP1)); //this work CBitmap MyBitmap; MyBitmap.LoadBitmap( IDB_BITMAP1); //this work Oktemp = CWnd::Create (NULL,_T(""),WS_CHILD|WS_CLIPCHILDREN, rect, pParentWnd, nID ,pContext); //this work, I can see the button and catch his command Oktemp &= m_cBouton_1.Create (_T(""),WS_CHILD |BS_PUSHBUTTON|BS_BITMAP|WS_VISIBLE ,CRect(0,0,16,16),pParentWnd,IDC_BUTTONGAUCHE); //and the bitmap is never displayed on the button.... m_cBouton_1.SetBitmap(MyBitmap); m_cBouton_1.ShowWindow(SW_SHOWNORMAL); return Oktemp; } Remi Morin Rmorin@Operamail.com Remi.Morin@Lyrtech.com
I guess you want a skinned button. I found a source code here in "CodeProject". It's a class derived from CButton that make create the button from resource bitmaps. I'll bet if you search in the CodeProject for "skin button" or "skin CButton", you'll find it. if not, email me and I'll send you by mail the source code. Name: STR Mission: Take Over The World (c: Tips: If you build it, he will come. EMail: sagiv@musicgenome.com