Using ClassWizard to add a CButton variable

Posted on 2002-03-18
Last Modified: 2013-11-20
This should be easy, but I'm having problems with it. I have used the ClassWizard to create a CButton variable (namely m_button) in my FormView Class, but I get assertion failure whenever I call any functions of it, coz the m_hwnd variable is always null. Do I need to call the Create function in the constructor of my FormView, but then will I lose the dimensions which I set using the resource editor?
Question by:vintsang
  • 3
  • 2
LVL 49

Expert Comment

ID: 6879231
It does work.  But you must only call CButton member variables after all of the controls have been created.  Which means:  wait until OnInitialUpdate() to start doing stuff.

-- Dan

Author Comment

ID: 6879580
Thanks Dan, but actually I'm doing everything in OnInitialUpdate(). I used ClassWizard to create a CButton variable (m_button) in my FormView class, then in the OnInitialUpdate() function I called:

HICON hIcon = LoadIcon(::AfxGetInstanceHandle(),        MAKEINTRESOURCE(IDI_STOP));

to set the icon of the button, but I got assertion failure in the second statement because at that time m_button.m_hWnd is still null. Did I miss anything important?

Author Comment

ID: 6879693
Oh, I have solved the problem already. Just forgot to call CFormView::OnInitialUpdate() first... :>
LVL 49

Accepted Solution

DanRollins earned 5 total points
ID: 6881359
I'm glad I was able to solve your problem for you.

-- Dan
LVL 49

Expert Comment

ID: 6883026
Why have you insulted me with a C?

You offer only 5 points for a question -- when 50 points is the level that means 'easy'.  Nobody else would even look at a 5-pt question, but out of the kindness of my heart, I helped you find the solution.  Then you slap me in the face.  Why?

-- Dan

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Add content to output file 4 62
Best tools for Backup and restore of Wordpress site 6 55
ffmpeg - "rtsp://...... Operation not permitted" 4 74
ShiftLeft challenge 21 78
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Internet Business Fax to Email Made Easy - With  eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

863 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now