Solved

Using ClassWizard to add a CButton variable

Posted on 2002-03-18
5
235 Views
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?
0
Comment
Question by:vintsang
  • 3
  • 2
5 Comments
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
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
0
 

Author Comment

by:vintsang
Comment Utility
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));
    m_button.SetIcon(hIcon);

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?
0
 

Author Comment

by:vintsang
Comment Utility
Oh, I have solved the problem already. Just forgot to call CFormView::OnInitialUpdate() first... :>
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 5 total points
Comment Utility
I'm glad I was able to solve your problem for you.

-- Dan
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
vintsang:
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
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

743 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

11 Experts available now in Live!

Get 1:1 Help Now