From: Z.K. on
I know this should be easy, but I can't seem to figure it out. I need
access to some of my variables and methods of my CFormView class from a
MFC derived class to access several of the CFormView's controls. How do
I pass a this pointer to another MFC class.

void MyTest::Test3(CFormView* form)
{

}

m_pMyTest = new CMyTest;


m_pMyTest->Test3(this);


Why does this not work? When I try to access the form pointer, I do not
have access to the member variables or methods like I thought I should
even though I purposely made some of them public. The only things in
the pointer list is the functions and variables related to CFormView and
not to the changes I made in my View class from which the this pointer
is passed.

Z.K.
From: Igor Tandetnik on
Z.K. <nospam(a)nospam.net> wrote:
> I know this should be easy, but I can't seem to figure it out. I need
> access to some of my variables and methods of my CFormView class from
> a MFC derived class to access several of the CFormView's controls.

I'm pretty sure your class is not called CFormView. Rather, you have a
class derived from CFormView. You should declare MyTest::Test3 to take a
pointer to your class, not to CFormView.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


From: Z.K. on
Igor Tandetnik wrote:
> Z.K. <nospam(a)nospam.net> wrote:
>> I know this should be easy, but I can't seem to figure it out. I need
>> access to some of my variables and methods of my CFormView class from
>> a MFC derived class to access several of the CFormView's controls.
>
> I'm pretty sure your class is not called CFormView. Rather, you have a
> class derived from CFormView. You should declare MyTest::Test3 to take a
> pointer to your class, not to CFormView.

Yea, I had thought about that, but when I include the header file to the
class which is a CFormView, I get a huge amount of compiler errors.
From: Igor Tandetnik on
"Z.K." <nospam(a)nospam.net> wrote in message
news:OYMUcCzpIHA.4888(a)TK2MSFTNGP04.phx.gbl
> Igor Tandetnik wrote:
>> Z.K. <nospam(a)nospam.net> wrote:
>>> I know this should be easy, but I can't seem to figure it out. I
>>> need access to some of my variables and methods of my CFormView
>>> class from a MFC derived class to access several of the CFormView's
>>> controls.
>>
>> I'm pretty sure your class is not called CFormView. Rather, you have
>> a class derived from CFormView. You should declare MyTest::Test3 to
>> take a pointer to your class, not to CFormView.
>
> Yea, I had thought about that, but when I include the header file to
> the class which is a CFormView, I get a huge amount of compiler
> errors.

My crystal ball is a little bit cloudy today - hard to read the small
font on your screen. Perhaps you could show what you've done, and the
text of a few error messages?
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


From: Z.K. on
Igor Tandetnik wrote:
> "Z.K." <nospam(a)nospam.net> wrote in message
> news:OYMUcCzpIHA.4888(a)TK2MSFTNGP04.phx.gbl
>> Igor Tandetnik wrote:
>>> Z.K. <nospam(a)nospam.net> wrote:
>>>> I know this should be easy, but I can't seem to figure it out. I
>>>> need access to some of my variables and methods of my CFormView
>>>> class from a MFC derived class to access several of the CFormView's
>>>> controls.
>>> I'm pretty sure your class is not called CFormView. Rather, you have
>>> a class derived from CFormView. You should declare MyTest::Test3 to
>>> take a pointer to your class, not to CFormView.
>> Yea, I had thought about that, but when I include the header file to
>> the class which is a CFormView, I get a huge amount of compiler
>> errors.
>
> My crystal ball is a little bit cloudy today - hard to read the small
> font on your screen. Perhaps you could show what you've done, and the
> text of a few error messages?

Perhaps you need a new crystal ball. :)

Seriously though, I created a SDI FormView program lets call it Test.
The main dialog type file is called TestView.cpp and its class name is
CTestView. Then I added a MFC class to the project called CMyTest (CWnd
base class). Now if I add CTestView.h to CMyTest.cpp and do nothing else
I get these errors before I even attempt to try and pass the class pointer.

errors:
c:\Documents and Settings\#########\My Documents\Visual Studio
Projects\Test\TestView.h(19): error C2143: syntax error : missing ';'
before '*'
c:\Documents and Settings\#########\My Documents\Visual Studio
Projects\Test\TestView.h(19): error C2501: 'CTestView::CTestDoc' :
missing storage-class or type specifiers
c:\Documents and Settings\#########\My Documents\Visual Studio
Projects\Test\TestView.h(19): error C2501: 'CTestView::GetDocument' :
missing storage-class or type specifiers
c:\Documents and Settings\#########\My Documents\Visual Studio
Projects\Test\TestView.h(19): warning C4183: 'GetDocument': missing
return type; assumed to be a member function returning 'int'