Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GetSafeOwner 1

Status
Not open for further replies.

Captrick458

Programmer
Mar 27, 2005
37
US
If I run GetSafeOwner(NULL,NULL) in a dialog, it returns a value. If from that dialog, I call a DLL with

someclass.myfunction(this,dialog), and in that DLL I call

where pParent is the value of "this"

pParent->GetSafeOwner(NULL,NULL); it returns a totally different value. I can fix it by using

pParent->GetSafeOwner(pParent,NULL);

It is not a problem to do this, I just want to understand why it is so.

I am using the value to disable the parent window for a modal dialog box. I can't use domodal because the entire contents of the modal dialog change based on what has come before.

If someone can explain this, I would really appreciate it.

Thanks in advance, Rick
 
If you pass NULL for the first argument to GetSafeOwner, the function finds the parent window by calling AfxGetMainWnd(), which returns the m_pMainWnd from the application object.

The thing is, the DLL has its own application object that is separate from the main program's application object. So it will end up looking at the wrong application object and not finding the same parent window. This is why you have to explicitly pass pParent when calling GetSafeOwner from the DLL when looking up the owner of a window created from the main program.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top