Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Constructor help – getting data from CListView to dialog.

Constructor help – getting data from CListView to dialog.

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestiontutorial
9 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vaclav_
    wrote on last edited by
    #1

    Could someone explain to me how to solve this ? I am editing CListView using modal dialog – pretty much “standard” operation. In this “main” dialog I open another dialog. In this “sub dialog” I want to change text and bacground colors of CEdit controls. These COOLOREFs variables are initialized in the CListView. Obviously I need the CList View data in my dialog – so I use parameterized constructor and pass my CListView “this” pointer to it. Here is the code snippet: m_clrText = RGB( 0, 0, 0 ); m_clrBkgnd = RGB( 255, 255, 0 ); C_Dialog_Edit_Color_Weight dlg(this); int nRet = -1; nRet = dlg.DoModal(); .... So far so good. The “problem” is that I do not fully undestand the syntax of the C_Dialog_Edit_Color_Weight parametrized constructor. Therefore I do not know how include C_Edit_ parameters to pass the correct pareameters to the C_Edit_. C_Dialog_Edit_Color_Weight::C_Dialog_Edit_Color_Weight(C_Dialog_Block *pDialog , CWnd* pParent /*=NULL*/) : CDialog(C_Dialog_Edit_Color_Weight::IDD, pParent) {… With this constructor I can only get to the C_Edit_ default constructor. So, how do I include parametrized C_Edit_ in this C_Dialog_Edit_Color_Weight constructor ? Thanks for reading. Cheers Vaclav

    C V 2 Replies Last reply
    0
    • V Vaclav_

      Could someone explain to me how to solve this ? I am editing CListView using modal dialog – pretty much “standard” operation. In this “main” dialog I open another dialog. In this “sub dialog” I want to change text and bacground colors of CEdit controls. These COOLOREFs variables are initialized in the CListView. Obviously I need the CList View data in my dialog – so I use parameterized constructor and pass my CListView “this” pointer to it. Here is the code snippet: m_clrText = RGB( 0, 0, 0 ); m_clrBkgnd = RGB( 255, 255, 0 ); C_Dialog_Edit_Color_Weight dlg(this); int nRet = -1; nRet = dlg.DoModal(); .... So far so good. The “problem” is that I do not fully undestand the syntax of the C_Dialog_Edit_Color_Weight parametrized constructor. Therefore I do not know how include C_Edit_ parameters to pass the correct pareameters to the C_Edit_. C_Dialog_Edit_Color_Weight::C_Dialog_Edit_Color_Weight(C_Dialog_Block *pDialog , CWnd* pParent /*=NULL*/) : CDialog(C_Dialog_Edit_Color_Weight::IDD, pParent) {… With this constructor I can only get to the C_Edit_ default constructor. So, how do I include parametrized C_Edit_ in this C_Dialog_Edit_Color_Weight constructor ? Thanks for reading. Cheers Vaclav

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      Vaclav_Sal wrote:

      C_Dialog_Edit_Color_Weight

      :confused: Is this a class that you defined or is it a third party library class?

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      [my articles]

      V 1 Reply Last reply
      0
      • C CPallini

        Vaclav_Sal wrote:

        C_Dialog_Edit_Color_Weight

        :confused: Is this a class that you defined or is it a third party library class?

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        [my articles]

        V Offline
        V Offline
        Vaclav_
        wrote on last edited by
        #3

        It is MFC CDialog derived class

        C 1 Reply Last reply
        0
        • V Vaclav_

          It is MFC CDialog derived class

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #4

          I know (there's a call to base class contructor in your code) but, I ask again, is it your own defined class or is it a third party library class? I mean, can you change its code or not? Moreover, could you please detail more what you need? :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          [my articles]

          V 1 Reply Last reply
          0
          • C CPallini

            I know (there's a call to base class contructor in your code) but, I ask again, is it your own defined class or is it a third party library class? I mean, can you change its code or not? Moreover, could you please detail more what you need? :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            [my articles]

            V Offline
            V Offline
            Vaclav_
            wrote on last edited by
            #5

            Now I am confused. I don't undestand what are you askig. Here is my real code (with some exras) // C_Dialog_Edit_Color_Weight dialog class C_Dialog_Edit_Color_Weight : public CDialog { // Construction public: C_Edit_ *m_C_Edit_; C_Dialog_Block *m_C_Dialog_Block; C_Dialog_Edit_Color_Weight(CWnd* pParent = NULL); // standard constructor C_Dialog_Edit_Color_Weight(C_Dialog_Block *pDialog, CWnd* pParent = NULL); // my dialog constructor This constructor has no code to use C_Edit_ class ( derived from MFC CEdit) constructor with paramaters - I do not know how to code it! But my code does work with C_Edit_ default constructor where I redefine the needed COLORREF variables - until I figure how to get the parametrized constructor in my code. What I need: 1. Define COLORREF variable in class derived from CListView 2. Open modal dialog with list control containing CLIstView data 3. Modify list control subitems value (int) "Weight" - open another modal dialog 4. Change subitems "Text" to selected color. What I have - the color assigment is currently retrived from the default C_Edit_ constructor where it is "hardcoded". Thanks for helping me. Cheers Vaclav

            C V 2 Replies Last reply
            0
            • V Vaclav_

              Now I am confused. I don't undestand what are you askig. Here is my real code (with some exras) // C_Dialog_Edit_Color_Weight dialog class C_Dialog_Edit_Color_Weight : public CDialog { // Construction public: C_Edit_ *m_C_Edit_; C_Dialog_Block *m_C_Dialog_Block; C_Dialog_Edit_Color_Weight(CWnd* pParent = NULL); // standard constructor C_Dialog_Edit_Color_Weight(C_Dialog_Block *pDialog, CWnd* pParent = NULL); // my dialog constructor This constructor has no code to use C_Edit_ class ( derived from MFC CEdit) constructor with paramaters - I do not know how to code it! But my code does work with C_Edit_ default constructor where I redefine the needed COLORREF variables - until I figure how to get the parametrized constructor in my code. What I need: 1. Define COLORREF variable in class derived from CListView 2. Open modal dialog with list control containing CLIstView data 3. Modify list control subitems value (int) "Weight" - open another modal dialog 4. Change subitems "Text" to selected color. What I have - the color assigment is currently retrived from the default C_Edit_ constructor where it is "hardcoded". Thanks for helping me. Cheers Vaclav

              C Offline
              C Offline
              CPallini
              wrote on last edited by
              #6

              Vaclav_Sal wrote:

              This constructor has no code to use C_Edit_ class ( derived from MFC CEdit) constructor with paramaters - I do not know how to code it!

              something like

              class C_Edit_ public CEdit
              {
              //...
              public:
              C_Edit_(COLORREF cr):CEdit()
              {
              //...
              }
              //...
              };

              does help?

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              [my articles]

              1 Reply Last reply
              0
              • V Vaclav_

                Now I am confused. I don't undestand what are you askig. Here is my real code (with some exras) // C_Dialog_Edit_Color_Weight dialog class C_Dialog_Edit_Color_Weight : public CDialog { // Construction public: C_Edit_ *m_C_Edit_; C_Dialog_Block *m_C_Dialog_Block; C_Dialog_Edit_Color_Weight(CWnd* pParent = NULL); // standard constructor C_Dialog_Edit_Color_Weight(C_Dialog_Block *pDialog, CWnd* pParent = NULL); // my dialog constructor This constructor has no code to use C_Edit_ class ( derived from MFC CEdit) constructor with paramaters - I do not know how to code it! But my code does work with C_Edit_ default constructor where I redefine the needed COLORREF variables - until I figure how to get the parametrized constructor in my code. What I need: 1. Define COLORREF variable in class derived from CListView 2. Open modal dialog with list control containing CLIstView data 3. Modify list control subitems value (int) "Weight" - open another modal dialog 4. Change subitems "Text" to selected color. What I have - the color assigment is currently retrived from the default C_Edit_ constructor where it is "hardcoded". Thanks for helping me. Cheers Vaclav

                V Offline
                V Offline
                Vaclav_
                wrote on last edited by
                #7

                " C_Dialog_Edit_Color_Weight(C_Dialog_Block *pDialog, CWnd* pParent = NULL); // my dialog constructor This constructor has no code to use C_Edit_ class ( derived from MFC CEdit) constructor with paramaters - I do not know how to code it! " I was not clear with this. I do have a C_Edit_ parametrized constructor but I cannot "get to it" from C_Dialog_Edit_Color_Weight constructor because I am missing something. This C_Dialog_Edit_Color_Weight constructor executes the dialog fine than it "calls" C_Edit_ default constructor. That is the step I am missing - I do not know how to get to the C_Edit_ parametrized constructor instead of the default. Cheers Vaclav

                1 Reply Last reply
                0
                • V Vaclav_

                  Could someone explain to me how to solve this ? I am editing CListView using modal dialog – pretty much “standard” operation. In this “main” dialog I open another dialog. In this “sub dialog” I want to change text and bacground colors of CEdit controls. These COOLOREFs variables are initialized in the CListView. Obviously I need the CList View data in my dialog – so I use parameterized constructor and pass my CListView “this” pointer to it. Here is the code snippet: m_clrText = RGB( 0, 0, 0 ); m_clrBkgnd = RGB( 255, 255, 0 ); C_Dialog_Edit_Color_Weight dlg(this); int nRet = -1; nRet = dlg.DoModal(); .... So far so good. The “problem” is that I do not fully undestand the syntax of the C_Dialog_Edit_Color_Weight parametrized constructor. Therefore I do not know how include C_Edit_ parameters to pass the correct pareameters to the C_Edit_. C_Dialog_Edit_Color_Weight::C_Dialog_Edit_Color_Weight(C_Dialog_Block *pDialog , CWnd* pParent /*=NULL*/) : CDialog(C_Dialog_Edit_Color_Weight::IDD, pParent) {… With this constructor I can only get to the C_Edit_ default constructor. So, how do I include parametrized C_Edit_ in this C_Dialog_Edit_Color_Weight constructor ? Thanks for reading. Cheers Vaclav

                  V Offline
                  V Offline
                  Vaclav_
                  wrote on last edited by
                  #8

                  After several failures to force main CDialog constructor to use parameterized CEdit "child" constructor I came up with this shameless hack! I use global COLORREF variables and assign them to local variables in the default constructor. I could just use them but it keeps the rest of the code intact and somewhat sane. So, is usage of globals in “OOP” on same level as GoTo? :(( Vaclav

                  M 1 Reply Last reply
                  0
                  • V Vaclav_

                    After several failures to force main CDialog constructor to use parameterized CEdit "child" constructor I came up with this shameless hack! I use global COLORREF variables and assign them to local variables in the default constructor. I could just use them but it keeps the rest of the code intact and somewhat sane. So, is usage of globals in “OOP” on same level as GoTo? :(( Vaclav

                    M Offline
                    M Offline
                    Mike Danberg
                    wrote on last edited by
                    #9

                    Couldn't you just change the colors to your desired COLOREF values in the dialog's OnInitDialog() function? Maybe it's not as nice as setting it through the constructor, but it's better than using global variables. Mike

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups