Solved

CButton

Posted on 1998-01-18
6
557 Views
Last Modified: 2013-11-20
Hi all,

How can I create a button derived form CButton in a ClistView class.  I need to create it in my OnDraw(). But when I  do I get an arror saying that pWnd cannot be NULL.  I use "this" when I create my button.  If I try to use afxgetparet, the button will not display correctly in the view.  And when I try to resize I get the same error as before.  I know this should be easy but I can't seem to get it.  Could some one help me.
0
Comment
Question by:sjm
  • 3
  • 3
6 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
Comment Utility
You should create it in OnCreate() rather than OnDraw. Put the button object as a member variable of your CListView.
0
 

Author Comment

by:sjm
Comment Utility
Chenusa,

I can't put it in OnCreate because im using a derived class of CDC to do a BitMap copy of the screen to prevent flicker. I already have my buttons in OnCreate, but when I do an update flicker is gone, except for the buttons.
0
 
LVL 23

Expert Comment

by:chensu
Comment Utility
I don't understand your comment. Would you please explain it to me more clearly?
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:sjm
Comment Utility
Chenusa,

Ok, I am trying to get rid of the flicker I get when my app updates the screen.  I have a class derived from CDC that creates a bitmap image of the screen and blts it so that the screen redraws as one image to remove the flicker.  I have all my drawing routines in my Cview drevided class under OnDraw and my CDocument class under GetData.  But the buttons I use for the app are created under OnCreate in my Cview class.  When the screen updates it copies the images and blts it back, but after this process completes, the OnCreate functions redraws the buttons and I again have the flicker of the redrawn buttons.  When I tryied to place the buttons in my OnDraw function, I get an error saying that pWnd can't be NULL, refering the the CWnd* used by the creation of the buttons.  I tried to use afxgetparent but this caused the button to be painted outside the view.  And when I went ahead and resized the screen the same error came up.  I am trying to find the correct Cwnd* for my Cview to pass to the the button creation.  This should allow me to create the buttons in my OnDraw function.  
0
 
LVL 23

Expert Comment

by:chensu
Comment Utility
Apply WS_CLIPCHILDREN style to your view. You should not create the button in OnDraw since OnDraw is called frequently.

> I am trying to find the correct Cwnd* for my Cview to pass to the the button creation. This should allow me to create the buttons in my OnDraw function.

CView is derived from CWnd. You can pass the this pointer.
0
 

Author Comment

by:sjm
Comment Utility
chensu,

The WS_CLIPCHILDREN style worked great.  But note that I too thought that I could use the "this" pointer.  But as I said earlier, this caused an error stating that pWnd can not be NULL.
But thanks for the better way to go.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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…
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…

772 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

10 Experts available now in Live!

Get 1:1 Help Now