Click here to Skip to main content
Licence 
First Posted 27 Mar 2003
Views 161,434
Bookmarked 67 times

Image Button Control

By | 27 Mar 2003 | Article
Image Button Control MFC Class ( CImageButton )

Sample Image - CImageButton.jpg

Class header file

CImageButton class info :

class CImageButton : public CButton
{
// Construction
public:
 CImageButton();

 enum {
    TEXT_INCLUDE      = 0x0001, 
    IMAGE_RIGHT      = 0x0002,
    IMAGE_VCENTER     = 0x0004,
    IMAGE_BOTTOM      = 0x0008,
    IMAGE_HCENTER     = 0x0010,
    FOCUS_TEXTONLY    = 0x0020,
    }; 
// Attributes
public: 
// Operations
public: 
// Overrides
 // ClassWizard generated virtual function overrides
 //{{AFX_VIRTUAL(CImageButton)
 public:
 virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
 //}}AFX_VIRTUAL 
// Implementation
public:
 void SetTextColor( COLORREF color );
 BOOL SetAlignStyle( DWORD dwStyle );
 BOOL SetButtonImage( UINT uiImageID , COLORREF  clrMask );
 virtual ~CImageButton(); 
 // Generated message map functions
protected: 

 void ReCalculateSettings(); 

 COLORREF    m_clrMask;
 CBitmap     m_bitmapImage;
 BITMAP      m_bitmap;
 HBITMAP     m_hbmpDisabled;
 CImageList m_ImageList;
 BOOL        m_bLoaded; 
 DWORD       m_dwAlign;   //View Style 

 CRect       m_RectImage;
 CRect       m_RectText;
 CRect       m_RectTextFocus; 
 COLORREF    m_clrText;       //Text Color
 
 //{{AFX_MSG(CImageButton)
 afx_msg void OnSetFocus(CWnd* pOldWnd);
 afx_msg void OnSysColorChange();
 afx_msg void OnSize(UINT nType, int cx, int cy);
 afx_msg void OnEnable(BOOL bEnable);
 //}}AFX_MSG 
 DECLARE_MESSAGE_MAP()
}; 
  

Class Usage

Here is some sample code to show you how to use the class.

CImageButton m_Button; 
m_Button.SetTextColor( RGB( 200 , 0 , 0 ) );
m_Button.SetAlignStyle( CImageButton::FOCUS_TEXTONLY |  
    CImageButton::TEXT_INCLUDE |   CImageButton::IMAGE_RIGHT | 
    CImageButton::IMAGE_VCENTER );
 m_Button.SetButtonImage( IDB_BITMAP1 , RGB( 255 , 0 , 255 ) ); 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

HAMZADAYI

Web Developer

Turkey Turkey

Member

I'm working as a software developer in a local software company. My firm is a special solution company. This is work about different projects. Some friends thinking it is amazing. Smile | :) ))

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Generalit does a specific job and it does it well enough Pinmemberphilipcunningham12:24 10 Jan '10  
GeneralNice one! Pinmembersoftwaremonkey17:05 25 Sep '06  
QuestionHow deep the bitmap? PinmemberDo Manh Hung16:10 20 May '05  
GeneralI like it Pinmemberluftwaffe20:03 1 Apr '04  
GeneralIt has no comments but.. Pinmembermeeths11:42 4 Jan '04  
GeneralDon't be so harsh Pinmemberarmentage10:51 5 Jun '03  
GeneralRe: Don't be so harsh PinmemberChristian Graus11:38 5 Jun '03  
GeneralYou are lazy people! Pinmembere-sushi9:38 14 Apr '03  
GeneralRe: You are lazy people! Pinmemberrazankbj6119:17 13 Feb '05  
GeneralRe: You are lazy people! PinsussNCE_NCE0:25 10 Oct '05  
GeneralThis effort is lacking!! PinmemberWREY23:31 4 Apr '03  
GeneralRe: This effort is lacking!! Pinmemberkicknfast9:46 3 Aug '03  
GeneralRe: This effort is lacking!! PinmemberWREY13:07 3 Aug '03  
GeneralRe: This effort is lacking!! Pinmemberkicknfast15:06 3 Aug '03  
GeneralRe: This effort is lacking!! PinmemberWREY19:18 3 Aug '03  
GeneralRe: This effort is lacking!! Pinmemberkicknfast21:21 3 Aug '03  
GeneralHmmm... PinmemberDavid Stone6:29 29 Mar '03  
GeneralNo, no ,no! Not again! PinmemberRickard Andersson6:07 29 Mar '03  
GeneralArticle Text PinmemberJohn M. Drescher8:50 28 Mar '03  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 28 Mar 2003
Article Copyright 2003 by HAMZADAYI
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid