Go4Expert

Go4Expert (http://www.go4expert.com/)
-   MFC (http://www.go4expert.com/forums/mfc/)
-   -   CBitmapButton Problem (http://www.go4expert.com/forums/cbitmapbutton-problem-t15752/)

KaimTazz 7Jan2009 14:10

CBitmapButton Problem
 
Hi all..
I have placed button ctrl having ID = IDC_BUTTON1 over dialog and Added Bitmap having ID="BUTTON_IMPORT". I have written following code snippet in OnInitDialog():-

{
.
.
CBitmapButton MyBmpBtn;
MyBmpBtn.LoadBitmaps(_T("BUTTON_IMPORT"));

CButton *btn;
btn = reinterpret_cast<CButton *>(GetDlgItem(IDC_BUTTON1));

LONG GWLIMP = GetWindowLong(btn->m_hWnd, GWL_STYLE);
SetWindowLong(btn->m_hWnd, GWL_STYLE, GWLIMP | BS_OWNERDRAW);

MyBmpBtn.SubclassDlgItem(IDC_BUTTON1,this);
.
.
}

But Button is not visible on dialog when i execute program......
pls help me out know why button have been not displayed on screen....

thanks all

shabbir 7Jan2009 14:35

Re: CBitmapButton Problem
 
You should define your MyBmpBtn variable in the scope of the dialog class and not in InitDialog function as that would mean when the function ends the variable is out of scope. This is the most common mistake even I faced writing my first button though and had to learn the hard way out of assembly debugging.

KaimTazz 7Jan2009 16:10

Re: CBitmapButton Problem
 
oh thats great.... thankyou so much for your support.

KaimTazz 8Jan2009 12:39

Re: CBitmapButton Problem
 
Hi all,

Here i got another problem. Following is the hierarchy of class inheritance:-

class CXPropertyPage : Public CPropertyPage

class CPPage : Public CXPropertyPage

class CChild : Public CPPage

As Shabbir suggested to add CBitmapButton object in class, i tried to add it in CChild class and i found an assertion in OnInitDialog of CXPropertyPage. It occurs in CXPropertyPage::OnInitDialog() when it calls CPropertyPage::OnInitDialog() :-

BOOL CXPropertyPage::OnInitDialog()
{
CPropertyPage::OnInitDialog();

return TRUE;
}

I have no Idea why I am getting assertion/Exception !!
Pls help me to find out solution...

Thanks All

KaimTazz 8Jan2009 17:33

Re: CBitmapButton Problem
 
Hi All.

I dont know, but, if i try to add/delete any member in CChild( pls take a look at class hierarchy in previous quote) class program gives assertion otherwise things are going well.

shabbir 8Jan2009 18:34

Re: CBitmapButton Problem
 
Where are you getting the assertion?

KaimTazz 12Jan2009 16:11

Re: CBitmapButton Problem
 
Hi,
everything was fine after ur solution.. the problem was with file attributes and access rights....

Now there is no problem with CBitmapButton...
Thanks a Lot


All times are GMT +5.5. The time now is 05:14.