Solved

Defining a child CWnd object from a CRect

Posted on 2001-07-22
9
400 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
  • 5
  • 4
9 Comments
 
LVL 49

Accepted Solution

by:
DanRollins earned 150 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
 
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
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.

 
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

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: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

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

16 Experts available now in Live!

Get 1:1 Help Now