Originally posted by: fmmanrique
Hi,
I have also had the assert problem with the AutoLoad function. I was just going to change this function by LoadBitmaps function when I discovered the solution to the problem:
"If you use AutoLoad in the OnInitDialog function, you shall call it before the base class function. For example:
BOOL CSampleDlg::OnInitDialog()
{
//Init the buttons
m_bitmapButton1.AutoLoad( IDC_SAMPLE_BUTTON1, this);
CDialog::OnInitDialog();
//The following line generates an ASSERT ERROR!!
m_bitmapButton2.AutoLoad( IDC_SAMPLE_BUTTON2, this);
...
return TRUE;
}
I hope this will be helpful to somebody, BYE
I try as you said ,but it didn't work
ReplyOriginally posted by: Tri P.
While waiting for any answer on the assertion problem when using Autoload, I used the LoadBitmaps function and it works fine.
Does anyone out there know how to fix the assertion problem?
Originally posted by: Abe
Firstly, create two bitmaps and name them, say, IDB_MYB UTTUP and IDB_MYBUTTDWN. Then add a button to a dialog. Set it's "owner draw" and "bitmap" properties and create a control variable for it via classwizard, say, MyButtonCtrl. Then modify the dialog's class header file - change the variable's type class in AFX_DATA block from CButton to CBitmapButton. Finally, in the OnInitDialog() add MyButtonCtrl.LoadBitmaps(IDB_MYBUTTUP,IDB_MYBUTTDWN). You can eventually size the button via MyButtonCtrl.SizeToContent().
This works ok for me.
Abraham
ReplyOriginally posted by: Branco marks
I tried your program it worked, however mine does not work i donno why. if i disable BS_OWNERDRAW then the bitmap is not drawn, and if i enable it i get an error a DEBUG ASSERtION FAILED. can ynone help me
Originally posted by: jayamurugan
waaste of time on following your procedure
I was trying to add a bitmap to the button simply
I really got confused . I am sorry to say this
Once I tried thse I will send you teh simple step bystep to
create a bitmap on the button
bye
Originally posted by: jc
I have too assertion error, what can I do for??
Reply
Originally posted by: Anthony
When my code gets to the line:
ASSERT(m_bitmap.m_hObject != NULL); // required
in the DrawItem member fundtion of the CBitmapButton class it asserts! I have read and reread your article and have looked at some examples in MSDN and I cannot figure out why I have this problem! Also, when AutoLoad tries to load my bitmaps, it is not successful. I have labeled my bitmap "AGAINU", including the quotes (the VC++ documentation said I had to). Please help!!
Reply
Originally posted by: swallow
I have three Bitmaps:up,Focused,Down.
When the Mouse is over the button ,I want the Bitmap is the Focused,when the Mouse leave,the Bitmap is the up,and when clicking the button,the Bitmap is the Down.
How can I do?
Reply
Originally posted by: Alex
CBitmapButton myButton;
// Create the bitmap button (must include the BS_OWNERDRAW style).
// Load the bitmaps for the button.
// You'll need to call the Invalidate function in order
Here is the code I found in MSDN. The function you are
interested in the most here is the LoadBitmaps function.
It takes several arguments that correspond to the UP, DOWN,
FOCUS, and DISABLE pictures.
myButton.Create(NULL, WS_CHILD|WS_VISIBLE|BS_OWNERDRAW,
CRect(10,10,100,100), pParentWnd, 1);
myButton.LoadBitmaps(IDB_UP, IDB_DOWN, IDB_FOCUS, IDB_DISABLE);
// to update the GUI immediately.
myButton.Invalidate(TRUE);
Hope this is as easy to understand as this original sample.
Originally posted by: Arun Kumar Goyal
This a very important and good feature, which you have explained so easily. I have implemented this in my all projects.
Once again I say it is nice.