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!

Changing variables in CMyProgramView

Status
Not open for further replies.

Berras

Programmer
Feb 24, 2002
42
GB
In my program I have made a Dioalog box where the user types in some data and I want to be able to send this data to a variable in the CMyProgramView class. But all the methods I have tried so far do not work. Any suggestions??
 
Use the following functions to navigate between application, View, document and frame objects e.g. AfxGetApp(), AfxGetMainWnd(), GetActiveView(), GetDocument().

1. You can get access to the application object from any other classes using
CmyApp * pApp = (CMyApp*)AfxGetApp(); where CMyApp is your application class dertived from CWinApp.
2. You can access the main window of the application using one of the following depending on SDI or MDI application:
CMyFrame * pFrame = AfxGetApp()->m_pMainWnd;
or
CMyFrame * pFrame = AfxGetMainWnd();

or

CMDIFrameWnd *pFrame =
(CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;

// Get the active MDI child window.
CMDIChildWnd *pChild =
(CMDIChildWnd *) pFrame->GetActiveFrame();

3. To access the active view object from the Dialog class or from other classes:
#include "CMyProgramView.h"
CMyFrame * pFrame = AfxGetApp()->m_pMainWnd;
if (pFrame)
{
CMyProgramView *pView = (CMyProgramView *) pFrame->GetActiveView();
if (pView)
{
// here you access the public members of the CmyProgramView object
}
else
{
// error
}
}

-obislavu-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top