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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modeless Dialog, connecting it with the rest of the program

Status
Not open for further replies.

redoctober

Programmer
Oct 25, 2000
37
CA
Hi,
I've got question. I have a dialog box which i create as modeless using Create() function. And i have to change some parameters in the Doc object as soon as i click on button on the dialog, but i can find a way to get a hadle to the Doc object. Now i'm curious is there any graceful way to obtain a handle to my Doc or View object from inside of my dialog class? Right now i just rewrote constructor for the dialog class so that when i instantiate it i send a pointer to my Doc object and store it inside the dialog class. It works but i thought that it can be done in better way. Any thoughts on that?
Thanks.
 
This is one way of doing the job, passing the m_pDoc as parameter to the constructor.

Another one you should consider is working with the GetActiveDocument function from your CFrameWnd derived class (ussually CMainFrame) you get a pointer with (CMainFrame*)AfxGetMainWnd()

Or you can pass a pointer to the view (which can can be the parent of your dialog so that you can get it with GetParent) and from that pointer call the GetDocument function.

Hope this helps, s-)

Blessed is he who in the name of justice and good will, shepards the week through the valley of darknees...
 
Thanks a lot, BurtanI.
I tryed AfxGetMainWnd() method that you sugested...
It works, simple and easy. :)
Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top