Solved

CButton

Posted on 1998-01-18
6
558 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
ID: 1314311
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
ID: 1314312
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
ID: 1314313
I don't understand your comment. Would you please explain it to me more clearly?
0
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.

 

Author Comment

by:sjm
ID: 1314314
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
ID: 1314315
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
ID: 1314316
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

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

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

919 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

21 Experts available now in Live!

Get 1:1 Help Now