By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,221 Members | 1,214 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,221 IT Pros & Developers. It's quick & easy.

classes in VC++

P: n/a
Hi

I have 3 classes:
- CMainFrame
- CPitApp
- CPitView

In class CPitApp i create object CMainFrame* pMainFrame = new
CMainFrame
and in class CMainFrame there is:
public:
int nIndex

And now the question

How can I refer in method OnPrint in class CPitView, that is
CPitView::OnPrint,
to a value of variable nIndex from class CMainFrame??

Is there a way of doing this without creating an object of class
CMainFrame or do i have to create it, and if so how to create it that
it will contains the same data that have object pMainFrame from
CPitApp??

I'm using MF. CMainFrame contains toolbar:
protected: CStyleBar m_wndStyleBar;
and CStyleBar have:
public:
CComboBox m_comboBox;

I simply want to use value returned by
m_wndStyleBar.m_comboBox.GetCurSel()
in method
void CPitView::OnPrint(CDC* pDC, CPrintInfo* pInfo)

Thanks.
Jul 22 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"Piotr Getka" <ro*******@wp.pl> wrote in message
news:d8**************************@posting.google.c om...
Hi

I have 3 classes:
- CMainFrame
- CPitApp
- CPitView

In class CPitApp i create object CMainFrame* pMainFrame = new
CMainFrame
and in class CMainFrame there is:
public:
int nIndex

And now the question

How can I refer in method OnPrint in class CPitView, that is
CPitView::OnPrint,
to a value of variable nIndex from class CMainFrame??

Is there a way of doing this without creating an object of class
CMainFrame or do i have to create it, and if so how to create it that
it will contains the same data that have object pMainFrame from
CPitApp??

I'm using MF. CMainFrame contains toolbar:
protected: CStyleBar m_wndStyleBar;
and CStyleBar have:
public:
CComboBox m_comboBox;

I simply want to use value returned by
m_wndStyleBar.m_comboBox.GetCurSel()
in method
void CPitView::OnPrint(CDC* pDC, CPrintInfo* pInfo)

Thanks.


Inappropriate newsgroup, try "microsoft.public.vc.mfc"

--
Elias
Jul 22 '05 #2

P: n/a

"Piotr Getka" <ro*******@wp.pl> wrote in message
news:d8**************************@posting.google.c om...
Hi

I have 3 classes:
- CMainFrame
- CPitApp
- CPitView

In class CPitApp i create object CMainFrame* pMainFrame = new
CMainFrame
and in class CMainFrame there is:
public:
int nIndex

And now the question

How can I refer in method OnPrint in class CPitView, that is
CPitView::OnPrint,
to a value of variable nIndex from class CMainFrame??
Is there a way of doing this without creating an object of class
CMainFrame or do i have to create it, and if so how to create it that
it will contains the same data that have object pMainFrame from
CPitApp??


I would not create it. CPitApp and CPitView have to have a way of
communicating with each other. Are they related in any way right now? Does
one inherit from the other? Does one include the other? If not, then you
need to give one of them a pointer to the other one, or you need to do it
from some main() or other function that has both of them in it. Then you
can add functions to them so that you can get pMainFrame from CPitApp and
pass it to CPitView.
Jul 22 '05 #3

P: n/a

"lallous" <la*****@lgwm.org> wrote in message
news:bu************@ID-161723.news.uni-berlin.de...

Inappropriate newsgroup, try "microsoft.public.vc.mfc"


<bzzzzzt> Knee-jerk response, and wrong answer. The real question doesn't
have anything to do with MFC.
Jul 22 '05 #4

P: n/a
jeffc wrote:

"lallous" <la*****@lgwm.org> wrote in message
news:bu************@ID-161723.news.uni-berlin.de...

Inappropriate newsgroup, try "microsoft.public.vc.mfc"


<bzzzzzt> Knee-jerk response, and wrong answer. The real question doesn't
have anything to do with MFC.


If we are nitpicking then it has everything to do with MFC
(The name of the classes are a strong indication that the OP is
using MFC. If on the other hand he built the classes on his own,
he wouldn't have that problem) and how the object hierarchy of MFC
works. The only thing the OP is missing are the functions AfxGetApp()
and AfxGetMainWnd() which open up the door to what the OP wants to do.
--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #5

P: n/a
"lallous" <la*****@lgwm.org> wrote in message news:<bu************@ID-161723.news.uni-berlin.de>...
"Piotr Getka" <ro*******@wp.pl> wrote in message
news:d8**************************@posting.google.c om...
Hi

I have 3 classes:
- CMainFrame
- CPitApp
- CPitView

In class CPitApp i create object CMainFrame* pMainFrame = new
CMainFrame
and in class CMainFrame there is:
public:
int nIndex

And now the question

How can I refer in method OnPrint in class CPitView, that is
CPitView::OnPrint,
to a value of variable nIndex from class CMainFrame??

Is there a way of doing this without creating an object of class
CMainFrame or do i have to create it, and if so how to create it that
it will contains the same data that have object pMainFrame from
CPitApp??

I'm using MF. CMainFrame contains toolbar:
protected: CStyleBar m_wndStyleBar;
and CStyleBar have:
public:
CComboBox m_comboBox;

I simply want to use value returned by
m_wndStyleBar.m_comboBox.GetCurSel()
in method
void CPitView::OnPrint(CDC* pDC, CPrintInfo* pInfo)

Thanks.


Inappropriate newsgroup, try "microsoft.public.vc.mfc"


Thanks. I'll try.
Jul 22 '05 #6

P: n/a

"Karl Heinz Buchegger" <kb******@gascad.at> wrote in message
news:40***************@gascad.at...
jeffc wrote:

"lallous" <la*****@lgwm.org> wrote in message
news:bu************@ID-161723.news.uni-berlin.de...

Inappropriate newsgroup, try "microsoft.public.vc.mfc"


<bzzzzzt> Knee-jerk response, and wrong answer. The real question doesn't have anything to do with MFC.


If we are nitpicking then it has everything to do with MFC
(The name of the classes are a strong indication that the OP is
using MFC. If on the other hand he built the classes on his own,
he wouldn't have that problem) and how the object hierarchy of MFC
works.


Only superficially. You would need to know the hierarchy regardless of
whether those are MFC classes. The fact that they are MFC classes are
incidental. The problem would be exactly the same if I inserted my made up
class names in there. It doesn't matter if he's using third party software
or his own - a valid response might be that we need to see the rest of the
code, but his question is still an OO C++ question, not an MFC question.
It's unnecessarily off-putting when people read little more than the subject
line and immediately decide to play net-nanny.
Jul 22 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.