Click here to Skip to main content
15,918,123 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: adapter disconnected Pin
deeps_cute8-Apr-07 4:53
deeps_cute8-Apr-07 4:53 
QuestionHow to access to registry in vista Pin
bensonchen05088-Apr-07 1:29
bensonchen05088-Apr-07 1:29 
AnswerRe: How to access to registry in vista Pin
bob169728-Apr-07 6:06
bob169728-Apr-07 6:06 
GeneralRe: How to access to registry in vista Pin
bensonchen050810-Apr-07 14:55
bensonchen050810-Apr-07 14:55 
QuestionCheck if the user is admin Pin
near2world7-Apr-07 14:13
near2world7-Apr-07 14:13 
AnswerRe: Check if the user is admin Pin
cp98767-Apr-07 14:39
cp98767-Apr-07 14:39 
GeneralRe: Check if the user is admin Pin
near2world7-Apr-07 22:17
near2world7-Apr-07 22:17 
QuestionCBitmapButton with transparent bitmap Pin
af140017-Apr-07 9:05
af140017-Apr-07 9:05 
I need to write a program which using CBitmapButton class in a dialog box, so I find the sample code in MSDN and put the code into my program as follow:

In my header file(in a CDialog class)
<br />
CBitmapButton  btnBitmapButton;<br />
BOOL m_btnChecked;<br />


In my resource header file
<br />
#define IDC_BTN_BMPBTN     1020<br />


In my CPP file
<br />
m_btnChecked = FALSE;      //in dialog constructor set the initial value to FALSE<br />
<br />
BOOL CMyDialog::OnInitDialog()<br />
{<br />
       .<br />
       .<br />
       .<br />
      btnBitmapButton.Create( "", WS_CHILD|WS_VISIBLE|BS_OWNERDRAW, CRect(200, 200, 10, 10), this, IDC_BTN_BMPBTN );<br />
<br />
     if( ! btnBitmapButton.LoadBitmaps(_T("MYBUTTONU"), _T("MYBUTTOND")) )<br />
     {<br />
           TRACE0("Failed to load bitmaps for buttons\n");<br />
           AfxThrowResourceException();<br />
     }<br />
<br />
<br />
     btnBitmapButton.SizeToContent();<br />
     .<br />
     .<br />
     .<br />
}<br />



In Event Handler
<br />
void CMyDialog::OnBtnBitmapButton()<br />
{<br />
      if(m_btnChecked)<br />
      {<br />
           btnBitmapButton.SetState(FALSE);<br />
           m_btnChecked = FALSE;<br />
      }<br />
      else<br />
      {<br />
           btnBitmapButton.SetState(TRUE);<br />
           m_btnChecked=TRUE;<br />
      }<br />
<br />
}<br />




After compile and run the project, the codes above runs well, but there is a problem which I need the bitmap displays with transparent, and I can only use BMP format picture, so use a GIF transparent picture is not an option, I know how to load a bitmap to a CDC object, and know how to make it be a transparent bitmap, but I just don't know how to put this transparent picture on the CBitmapButton object.

I had search articles about how to implement a tranparent bitmap button both on CG and CodeProject website, and also find some articles which might useful to me, but those codes are all too complex to me, and I don't have time to check the code to figure out how I can use them.

I think I might need to create a class that inherit from CBitmapButton, then override the DrawItem member function, but I didn't have any clue to tell me how to override it.

So, does any one can tell me how to use CBitmapButton class and can use a transparent picture which doing transparent job dynamically?



-- modified at 7:01 Monday 9th April, 2007
AnswerRe: CBitmapButton with transparent bitmap Pin
Ravi Bhavnani7-Apr-07 11:01
professionalRavi Bhavnani7-Apr-07 11:01 
GeneralRe: CBitmapButton with transparent bitmap Pin
af140019-Apr-07 1:01
af140019-Apr-07 1:01 
GeneralRe: CBitmapButton with transparent bitmap Pin
Ravi Bhavnani9-Apr-07 1:39
professionalRavi Bhavnani9-Apr-07 1:39 
QuestionCheckbox Pin
deeps_cute7-Apr-07 7:59
deeps_cute7-Apr-07 7:59 
AnswerRe: Checkbox Pin
Ravi Bhavnani7-Apr-07 10:57
professionalRavi Bhavnani7-Apr-07 10:57 
GeneralRe: Checkbox Pin
deeps_cute8-Apr-07 1:49
deeps_cute8-Apr-07 1:49 
GeneralRe: Checkbox Pin
Hamid_RT8-Apr-07 2:33
Hamid_RT8-Apr-07 2:33 
GeneralRe: Checkbox Pin
saisp8-Apr-07 3:32
saisp8-Apr-07 3:32 
Questionunzip Pin
prathuraj7-Apr-07 4:27
prathuraj7-Apr-07 4:27 
AnswerRe: unzip Pin
bob169727-Apr-07 5:47
bob169727-Apr-07 5:47 
GeneralRe: unzip Pin
prathuraj7-Apr-07 7:09
prathuraj7-Apr-07 7:09 
GeneralRe: unzip Pin
bob169727-Apr-07 7:24
bob169727-Apr-07 7:24 
QuestionLoaded 'C:\WINDOWS\system32\version.dll', No symbols loaded Pin
hsuch7-Apr-07 3:24
hsuch7-Apr-07 3:24 
AnswerRe: Loaded 'C:\WINDOWS\system32\version.dll', No symbols loaded Pin
William.Wang8-Apr-07 19:20
William.Wang8-Apr-07 19:20 
QuestionDefault Sound Device Pin
mertology7-Apr-07 2:26
mertology7-Apr-07 2:26 
AnswerRe: Default Sound Device Pin
Mark Salsbery7-Apr-07 6:55
Mark Salsbery7-Apr-07 6:55 
QuestionReuse of existing Dialog boxes into a new project Pin
gilmegviv7-Apr-07 2:18
gilmegviv7-Apr-07 2:18 

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

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