473,587 Members | 2,258 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

classes in VC++

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::OnPri nt,
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.GetCu rSel()
in method
void CPitView::OnPri nt(CDC* pDC, CPrintInfo* pInfo)

Thanks.
Jul 22 '05 #1
6 1596
"Piotr Getka" <ro*******@wp.p l> wrote in message
news:d8******** *************** ***@posting.goo gle.com...
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::OnPri nt,
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.GetCu rSel()
in method
void CPitView::OnPri nt(CDC* pDC, CPrintInfo* pInfo)

Thanks.


Inappropriate newsgroup, try "microsoft.publ ic.vc.mfc"

--
Elias
Jul 22 '05 #2

"Piotr Getka" <ro*******@wp.p l> wrote in message
news:d8******** *************** ***@posting.goo gle.com...
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::OnPri nt,
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

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

Inappropriate newsgroup, try "microsoft.publ ic.vc.mfc"


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

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

Inappropriate newsgroup, try "microsoft.publ ic.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
"lallous" <la*****@lgwm.o rg> wrote in message news:<bu******* *****@ID-161723.news.uni-berlin.de>...
"Piotr Getka" <ro*******@wp.p l> wrote in message
news:d8******** *************** ***@posting.goo gle.com...
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::OnPri nt,
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.GetCu rSel()
in method
void CPitView::OnPri nt(CDC* pDC, CPrintInfo* pInfo)

Thanks.


Inappropriate newsgroup, try "microsoft.publ ic.vc.mfc"


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

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

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

Inappropriate newsgroup, try "microsoft.publ ic.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1440
by: Kevin Grigorenko | last post by:
Hello, I've been working on a little side project of mine in Visual Studio.NET for about the last month. Recently, I wanted a friend of mine to help me out with a problem and so I sent him my files and he tried to compile my project in Visual C++ 6. A slew of random warnings and errors appeared which I managed to solve very easily, but...
2
3116
by: vemulakiran | last post by:
Hi all, I have doubt regarding .NET. I have a tool which was developed on VC++ 6.0(Win32 Application ). The application communicates with library (API) which was developed on VC++ 6.0 called core client. I am planning to develop the tool or Win32 application on .NET platform and I dont' want to migrate the VC++ library (API) to .NET. The...
15
1381
by: Edward Diener | last post by:
Why is it impossible to have a __value class instance variable in a __nogc class when it is possible to have a built-in type instance variable in a __nogc class ? __value class X { int a; }; __nogc class Y { X b; int c;}; // compiler error __nogc class Y { int c;}; // OK
5
1816
by: Anthony Evans | last post by:
Greetings I'm using VC++.NET to create a class library. The class library contains managed classes that wrap legacy unmanaged classes by the same name. I use regasm to register the DLL for COM interop. If I don't include any managed classes in the library, the context help in VB6 lists every single unmanaged class in the class library
3
3082
by: Greg | last post by:
I seek to understand ATL better. When I create a Win32 Project (App or DLL) the option to add support for ATL (or MFC) is not selectable. It is only selectable for a Win32 Console App. However, it seems that ATL-MFC Shared classes, e.g. CString, CStringT, and the new CRect, can be added to the project and work fine. All that is required is to...
1
899
by: Ashutosh | last post by:
Hi, In VC++ 6.0, when we add a Registered ActiveX Control to the project form Project menu\Add to Project\Components and Contorls, then all the classes required for that control is automatically added to the project. Even when we inset ActiveX componenet by right clicking a dialog resource. and then try to add a variable for it, the Class...
4
3139
by: mailcsprasad | last post by:
When to use STL classes and when to use MFC Container classes?
5
3029
by: Gianmaria Iaculo - RPC | last post by:
Hi, a simple question i think. I have some old projects written in C++ (VS6). I want to class and objects from this projects ( I have sources natually) in a C# application (win). Is it possible? How can i do? Regards, Gianmaria
7
2495
by: Amu | last post by:
Hi i am stuck up in a part of project where i have to inherit the VC++ template classes into C#.net. Please provide me the solution for this .
2
1910
by: Amu | last post by:
i have a dll ( template class) ready which is written in VC++6. But presently i need to inherit its classes into my new C#.net project.so if there is some better solution with u then please give me the solution.
0
7915
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7843
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6619
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5712
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3840
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.