Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Using ClassWizard to add a CButton variable

Posted on 2002-03-18
Medium Priority
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
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
  • 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 10 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

722 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