classes in VC++

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Piotr Getka

    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.
  • lallous

    #2
    Re: classes in VC++

    "Piotr Getka" <romeo_007@wp.p l> wrote in message
    news:d8a4ea63.0 401202321.7b4e6 9fc@posting.goo gle.com...[color=blue]
    > 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.[/color]

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

    --
    Elias


    Comment

    • jeffc

      #3
      Re: classes in VC++


      "Piotr Getka" <romeo_007@wp.p l> wrote in message
      news:d8a4ea63.0 401202321.7b4e6 9fc@posting.goo gle.com...[color=blue]
      > 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??[/color]

      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.


      Comment

      • jeffc

        #4
        Re: classes in VC++


        "lallous" <lallous@lgwm.o rg> wrote in message
        news:bulfkj$j27 p3$1@ID-161723.news.uni-berlin.de...[color=blue]
        >
        > Inappropriate newsgroup, try "microsoft.publ ic.vc.mfc"[/color]

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


        Comment

        • Karl Heinz Buchegger

          #5
          Re: classes in VC++

          jeffc wrote:[color=blue]
          >
          > "lallous" <lallous@lgwm.o rg> wrote in message
          > news:bulfkj$j27 p3$1@ID-161723.news.uni-berlin.de...[color=green]
          > >
          > > Inappropriate newsgroup, try "microsoft.publ ic.vc.mfc"[/color]
          >
          > <bzzzzzt> Knee-jerk response, and wrong answer. The real question doesn't
          > have anything to do with MFC.[/color]

          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
          kbuchegg@gascad .at

          Comment

          • Piotr Getka

            #6
            Re: classes in VC++

            "lallous" <lallous@lgwm.o rg> wrote in message news:<bulfkj$j2 7p3$1@ID-161723.news.uni-berlin.de>...[color=blue]
            > "Piotr Getka" <romeo_007@wp.p l> wrote in message
            > news:d8a4ea63.0 401202321.7b4e6 9fc@posting.goo gle.com...[color=green]
            > > 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.[/color]
            >
            > Inappropriate newsgroup, try "microsoft.publ ic.vc.mfc"[/color]

            Thanks. I'll try.

            Comment

            • jeffc

              #7
              Re: classes in VC++


              "Karl Heinz Buchegger" <kbuchegg@gasca d.at> wrote in message
              news:400EAAA1.5 4EEAD7A@gascad. at...[color=blue]
              > jeffc wrote:[color=green]
              > >
              > > "lallous" <lallous@lgwm.o rg> wrote in message
              > > news:bulfkj$j27 p3$1@ID-161723.news.uni-berlin.de...[color=darkred]
              > > >
              > > > Inappropriate newsgroup, try "microsoft.publ ic.vc.mfc"[/color]
              > >
              > > <bzzzzzt> Knee-jerk response, and wrong answer. The real question[/color][/color]
              doesn't[color=blue][color=green]
              > > have anything to do with MFC.[/color]
              >
              > 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.[/color]

              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.


              Comment

              Working...