Solved

CButton

Posted on 1998-01-18
6
566 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
[X]
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
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adapt this command to show who installed 29 114
Tab names are off by one 5 54
ShiftLeft challenge 21 95
NotAlone Challenge 20 93
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: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

751 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