Solved

Getting the coordinates of a picture control

Posted on 2000-04-06
8
378 Views
Last Modified: 2013-11-20
I have a picture control (type rectangle) placed on a form view for a SDI application.  I am trying to get the coordinates of this control to render OpenGL at that location.  However, when I use:
CWnd *pwnd = GetDlgItem(IDC_PICT_CONTROL), it always returns NULL ??  Is there something special about the properties of the form (or if I do this on a dialog) that I need to know?

I have used this method successfully before to display bitmaps on dialogs and it worked well.

I'd appreciate any ideas.
0
Comment
Question by:klingej
8 Comments
 

Author Comment

by:klingej
ID: 2689764
// the code looks like this that I am trying to use


RECT rectDest, rectParent;
CWnd pwnd  = GetDlgItem(IDC_STATIC_VIEWPORT);
if(pwnd) {
  pwnd->GetWindowRect(&rectDest);
  GetWindowRect(&rectParent);
  rectDest.left -= rectParent.left;
  rectDest.right -= rectParent.left;
  rectDest.top -= rectParent.top;
  rectDest.bottom -= rectParent.top;
}
0
 
LVL 8

Expert Comment

by:VinExpert
ID: 2689765
Hi,

From where r u calling GetDlgItem(IDC_PICT_CONTROL)?. If U r calling from the child of the window where u have placed the control, then use like

CWnd *pwnd = GetParent()->GetDlgItem(IDC_PICT_CONTROL);
or
CWnd *pwnd = ((UrFormViewClassName *)GetParent())->GetDlgItem(IDC_PICT_CONTROL);

Try it out.

VinExpert
0
 

Author Comment

by:klingej
ID: 2689774
I'm calling it from a function belonging to either the dialog or form view (not a child), so I don't need GetParent().

0
Industry Leaders: 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!

 

Expert Comment

by:degarn
ID: 2689930
How is your image control created klingej ? I've just tried the same code and it works as you want it to work (pWnd has a value!)...
Check that your control already exists when you call the GetDlgItem !
0
 

Author Comment

by:klingej
ID: 2689966
I put it on the form view (or dialog) using the graphical editor.  I place a picture control, set the type to rectangle, and uncheck the visible option.  This has worked for me in the past, so I guess something must be different?
0
 

Accepted Solution

by:
degarn earned 50 total points
ID: 2690021
It still works for me now ...
Something is different in your code !
Where do you call the GetDlgItem() function ?
The only reason I see you could get a NULL pointer is that your control doesn't exists (still not created when getDlgItem is called) or that the ID you use in the call is not correct ...

Perhaps try to call your GetDlgItem() at another place in your class (set a button that execute it when you click for instance and see if pWnd still NULL).

In this case, a call to GetLastError() just after the call to GetDlgItem()could leran you more about the reasons control is not found...
0
 

Expert Comment

by:leowlf
ID: 2690071
trying adding another picture control, rebuild all, see if the GetDlgItem(ID_SECONDCONTROL) returns NULL also.

 
0
 

Author Comment

by:klingej
ID: 2690073
I was calling it in OnSize, but I moved it to OnPaint and it works fine now..  (although this causes other issues to deal with :)


thanks.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Process filename extension 3 208
if loop in java 3 162
sum13 challenge 24 134
Work with App store 7 92
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…
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.

749 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