Solved

Defining a child CWnd object from a CRect

Posted on 2001-07-22
9
397 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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 discusses moving either the default database or any database to a new volume.

743 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