Click here to Skip to main content
15,924,039 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: I'm curious.... Pin
Masaaki Onishi18-Apr-01 16:08
Masaaki Onishi18-Apr-01 16:08 
GeneralRe: I'm curious.... Pin
18-Apr-01 19:11
suss18-Apr-01 19:11 
GeneralRe: I'm curious.... Pin
18-Apr-01 23:26
suss18-Apr-01 23:26 
GeneralHelp: DLL thread Pin
18-Apr-01 6:12
suss18-Apr-01 6:12 
GeneralRe: Help: DLL thread Pin
18-Apr-01 10:40
suss18-Apr-01 10:40 
GeneralRe: Help: DLL thread Pin
Michael Dunn18-Apr-01 15:05
sitebuilderMichael Dunn18-Apr-01 15:05 
GeneralGet string without CSDIFormView ... Pin
Hadi Rezaee18-Apr-01 5:09
Hadi Rezaee18-Apr-01 5:09 
GeneralRe: Get string without CSDIFormView ... Pin
Masaaki Onishi18-Apr-01 15:58
Masaaki Onishi18-Apr-01 15:58 
Hello, the codegurus around the world.;)

There are a couple of ways to do your wish.

One is to use static function to get CWnd of FormView.
In MSDN help, you will find the followings.
HOWTO: Get Current CDocument or CView from Anywhere
Last reviewed: July 31, 1997
Article ID: Q108587


In detail,
For SDI application,
// View implementation file
CMyView * CMyView::GetView()
{
    CFrameWnd * pFrame = (CFrameWnd *)(AfxGetApp()->m_pMainWnd);
    CView * pView = pFrame->GetActiveView();

    if ( !pView )
      return NULL;

    // Fail if view is of wrong kind
    // (this could occur with splitter windows, or additional
    // views on a single document
    if ( ! pView->IsKindOf( RUNTIME_CLASS(CMyView) ) )
       return NULL;

    return (CMyView *) pView;
}

For an MDI application, the CMyView::GetView() code should be the following:
// MDI view implementation file
CMyView * CMyView::GetView()
{
    CMDIChildWnd * pChild =
    ((CMDIFrameWnd*)(AfxGetApp()->m_pMainWnd))->MDIGetActive();

    if ( !pChild )
       return NULL;

    CView * pView = pChild->GetActiveView();

    if ( !pView )
    return NULL;

    // Fail if view is of wrong kind
    if ( ! pView->IsKindOf( RUNTIME_CLASS(CMyView) ) )
    return NULL;

    return (CMyView *) pView;
}

Now, from anywhere in your program, where the document or view header files have been included, you can call:
CMyView::GetView();


After you get CWnd of FormView, you can access CWnd of Edit control on CYourFormView.
You had better change from CMyView to CMyFormView.Roll eyes | :rolleyes:

Have a nice day!
-Masaaki Onishi-
GeneralRe: Get string without CSDIFormView ... Pin
Hadi Rezaee19-Apr-01 0:12
Hadi Rezaee19-Apr-01 0:12 
QuestionHow to send a 'refresh' message to MS-Dev from an another MFC application Pin
EiSl18-Apr-01 3:14
EiSl18-Apr-01 3:14 
GeneralCListCtrl Sorting Pin
Mustafa Demirhan18-Apr-01 3:07
Mustafa Demirhan18-Apr-01 3:07 
GeneralRe: CListCtrl Sorting Pin
18-Apr-01 19:14
suss18-Apr-01 19:14 
GeneralRe: CListCtrl Sorting Pin
Ammar18-Apr-01 19:33
Ammar18-Apr-01 19:33 
GeneralRe: CListCtrl Sorting Pin
19-Apr-01 5:11
suss19-Apr-01 5:11 
GeneralrtWhy the bitmap just don't show?! Pin
hike18-Apr-01 1:25
hike18-Apr-01 1:25 
GeneralRe: rtWhy the bitmap just don't show?! Pin
Istvan Eperjesy23-Apr-01 1:16
Istvan Eperjesy23-Apr-01 1:16 
GeneralProblem, help !! Pin
VitSoft18-Apr-01 0:50
VitSoft18-Apr-01 0:50 
GeneralRe: Problem, help !! Pin
NormDroid18-Apr-01 0:58
professionalNormDroid18-Apr-01 0:58 
GeneralRe: Problem, help !! Pin
VitSoft18-Apr-01 1:12
VitSoft18-Apr-01 1:12 
GeneralRe: Problem, help !! Pin
Michael Dunn18-Apr-01 8:05
sitebuilderMichael Dunn18-Apr-01 8:05 
GeneralChanging security attributes in Access Pin
Ammar17-Apr-01 23:08
Ammar17-Apr-01 23:08 
GeneralDay Light Savings Time ( is it on) Pin
Colin J Davies17-Apr-01 19:47
Colin J Davies17-Apr-01 19:47 
GeneralRe: Day Light Savings Time ( is it on) Pin
Michael Dunn17-Apr-01 20:03
sitebuilderMichael Dunn17-Apr-01 20:03 
GeneralRe: Day Light Savings Time ( is it on) Pin
Colin J Davies17-Apr-01 21:00
Colin J Davies17-Apr-01 21:00 
GeneralFast Algorithm needed for Co-odinates along Ellipse Pin
Wolfram Steinke17-Apr-01 19:39
Wolfram Steinke17-Apr-01 19:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.