Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Defining a child CWnd object from a CRect

Posted on 2001-07-22
9
Medium Priority
?
407 Views
Last Modified: 2013-11-20
Hi:
   I want to get a CWnd object of my view class that is a portion of the view window.  Basically what I want is a CWnd object that represents
  CRect(100,100,500,500)
of the view window.  
   Then, given the CWnd object (call it pWnd) I should be able to go
 
CDC * pDC = pWnd->GetDC();
pDC->TextOut(0,0,"Hey-Hey");

I don't know if the following info will help but the reason I need the pWnd object is because I need to tell the clipper returned by Direct3D's function DirectDrawCreateClipper what window it can draw on.  

   Glenn


0
Comment
Question by:GlennDean
[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
  • 5
  • 4
9 Comments
 
LVL 49

Accepted Solution

by:
DanRollins earned 600 total points
ID: 6306909
You can only get a valid CWnd* from a valid window -- not from an abitrary rectangle.

So, you will need to do one of:
*) pass the CWnd* of the View ... or
*) Create a new window at the desired location and pass its CWnd*

-- Dan
0
 
LVL 3

Author Comment

by:GlennDean
ID: 6306926
I'm not sure how to, as you said,

*) Create a new window at the desired location and pass its CWnd*

I created a child window of the view at the desired coordinates and size.  Unfortunately, Direct3D didn't draw anything to that window.  That doesn't mean the idea doesn't work (i.e. create a window at the desired location), but I'm not sure if the child window I created is "acceptable to Direct3D".  

  Glenn  
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6306986
Make sure the window is fully created and valid:  Can you do other things with the window, such as TextOut, etc?

When you call pObj->SetHWnd( m_hWnd ), what is the return code?

-- Dan
0
Independent Software Vendors: 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!

 
LVL 3

Author Comment

by:GlennDean
ID: 6306995
When I create the child window at the desired coordinates, I verify the m_hWnd is non-zero.  When I call SetHWnd the return code is D3D_OK (i.e. everything worked fine).
   
   Glenn
0
 
LVL 3

Author Comment

by:GlennDean
ID: 6306999
Oops, didn't finish my comment.  I will have to get back to you later on whether TextOut works on my child window.
0
 
LVL 3

Author Comment

by:GlennDean
ID: 6307005
After creating the child window, I called GetDC on that window and it was non-null.  I then went
pDC->TextOut(0,0,"Hi")
but I did not see that text on the view window.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6307020
That text would *not* appear on the view window.  

It should appear on the child window.  Make sure that the child window that you created is visible and at the expected location (floating above the View window.

Anyway, why don't you just pass the hWnd of the View? I don't get it.

-- Dan
0
 
LVL 3

Author Comment

by:GlennDean
ID: 6308442
The reason I can't pass the hWnd of the View is because Direct3D uses that window for its drawing.  What I'm trying to do is display some graphics on a view (but eventually I want to display 3D graphics on things like a button or a dialog box) and I can't have Direct3D drawing on the entire window.  I need to specify a subportion of the window (so, for example, I want Direct3D to draw graphics on the upper right of the view).

   Glenn
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6309873
I don't have any Direct3D experience.  Perhaps you can instruct Direct3D to write on just a certain portion of the window while leaving the rest untouched.  Otherwize, you will need to float a window over the View and write to that window.  It can be a borderless windoe, like a tooltip.

You might be able to keep the target window hidden, then just blit from it onto the view surface when you need to update the view.

-- Dan
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

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 (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

596 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