Constructor help – getting data from CListView to dialog.
-
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
-
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
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] -
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] -
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] -
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]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
-
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
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] -
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_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
-
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
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
-
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
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