Solved

CBitmapButton  SubclassDlgItem throwing an assert

Posted on 2009-06-29
4
781 Views
Last Modified: 2013-12-27
I have an MFC button on my dialog.  I wich to use bitmap buttons to give it a nice look.  When I do the following:

CBitmapButton bmpOpt1;
m_bmpOpt1.SubclassDlgItem( IDC_BUTTON_1, this );
m_bmpOpt1.LoadBitmaps(IDB_BITMAP_GREENNEW, IDB_BITMAP_GREENNEW, 0, IDB_XPBTNMENUDIS_BITMAP);

I get an assert error on the second line above:
m_bmpOpt1.SubclassDlgItem( IDC_BUTTON_1, this );

The assert error is:
Debug Assert Failed
File: f:\sp\vctools\vclibsce\ship\atlmfc\src\mfc\wincore.cpp Line 375;
Abort | Retry | Ignore


Why is this??
0
Comment
Question by:Wanting2LearnMan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 

Author Comment

by:Wanting2LearnMan
ID: 24741377
I have just realised that I have a handler for this button already:

DDX_Control(pDX, IDC_BUTTON_1, m_button1);

could this be causing problems???
0
 
LVL 24

Accepted Solution

by:
alexey_gusev earned 500 total points
ID: 24741389
YES!!!! :)

look at that line and the very next:

      ASSERT(FromHandlePermanent(hWndNew) == NULL);
            // must not already be in permanent map <-- HERE
0
 

Author Comment

by:Wanting2LearnMan
ID: 24741410
I have took this out:
DDX_Control(pDX, IDC_BUTTON_1, m_button1);

and now its ok.



Thanks
0
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 24741434
to be honest, I'd do the opposite :)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Once again I push the limits of my phone.  An introduction to the Android Google Now Launcher.
A short article about problems I had with the new location API and permissions in Marshmallow
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question