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
Solved

Getting the coordinates of a picture control

Posted on 2000-04-06
8
371 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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
VB.NET how to use the Vertical ScrollBar 5 114
Expand LInux Boot partition remotly 3 96
Perl Awk Need Help 3 128
difference between String.subString() and String.subSequence() 6 235
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…
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

838 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