CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 32
  1. #16
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: CEdit::Create & GetWindowRect

    Quote Originally Posted by Mybowlcut View Post
    Guys... I know how to change the type of a variable.
    Quote Originally Posted by Mybowlcut View Post
    I don't know how to change their type if they were placed visually with the editor. When I place them with the editor, there are no instances created that I can edit:
    I think at this point you should consider serious focused reading about C++, Windows programming, Visual Studio and resource editor.
    After really focusing on those topics, come back here and read all posts from the beginning of this thread.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  2. #17
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: CEdit::Create & GetWindowRect

    Question to GCDEF:
    Do you fill that we are being played? Like about "Any Key"?
    I do not know about you but I quit here.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  3. #18
    Join Date
    Nov 2006
    Location
    Australia
    Posts
    1,569

    Re: CEdit::Create & GetWindowRect

    Quote Originally Posted by JohnCz View Post
    I think at this point you should consider serious focused reading about C++, Windows programming, Visual Studio and resource editor.
    After really focusing on those topics, come back here and read all posts from the beginning of this thread.
    What does learning C++ have to do with using changing a control type in Visual Studio? If there's one thing I've wanted to know through these two threads, it is how to change the type of a control placed with the visual editor. Quote the post where someone has explained to me how to do this and I will mark the thread as resolved. Oh, and this is not "it":
    In VS 6.0 after deriving class from CEdit (or any other window control) use class wizard to insert variable. Pick your class from the "Variable Type" drop box.
    In later versions of the VS, or if you want to change type of variable after inserting it, simply replace class inserted by wizard with your derived class. Make sure appropriate headers are available.

    That is it.
    That is not what I am trying to, nor is it what I have been trying to do. I am talking about changing the type of a control after placing it with the visual editor, not the class wizard.

    Quote Originally Posted by JohnCz View Post
    Question to GCDEF:
    Do you fill that we are being played? Like about "Any Key"?
    I do not know about you but I quit here.
    Good. Please do. I'd rather receive no help at all than have someone exhibit such a condescending and inconsiderate attitude towards people.
    Good judgment is gained from experience. Experience is gained from bad judgment.
    Cosy Little Game | SDL | GM script | VLD | Syntax Hlt | Can you help me with my homework assignment?

  4. #19
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: CEdit::Create & GetWindowRect

    Quote Originally Posted by JohnCz View Post
    Question to GCDEF:
    Do you fill that we are being played? Like about "Any Key"?
    I do not know about you but I quit here.
    No I don't. But I do think that he's not really taking the time to understand what's being said and went for a convoluted work around when he couldn't understand the simple solution.

  5. #20
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: CEdit::Create & GetWindowRect

    Quote Originally Posted by Mybowlcut View Post
    Quote the post where someone has explained to me how to do this and I will mark the thread as resolved.
    http://www.codeguru.com/forum/showpo...42&postcount=9

  6. #21
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: CEdit::Create & GetWindowRect

    Quote Originally Posted by Mybowlcut View Post
    What does learning C++ have to do with using changing a control type in Visual Studio? If there's one thing I've wanted to know through these two threads, it is how to change the type of a control placed with the visual editor.
    No, you don't change the type of a control.
    And you don't have to change the type of a control.
    What you have to do is the change the type (class) of a control member variable you are to associate with this control (so called subclassing).
    And you was told many times about it.
    Victor Nijegorodov

  7. #22
    Join Date
    Nov 2006
    Location
    Australia
    Posts
    1,569

    Re: CEdit::Create & GetWindowRect

    Quote Originally Posted by GCDEF View Post
    No I don't. But I do think that he's not really taking the time to understand what's being said and went for a convoluted work around when he couldn't understand the simple solution.
    Quite the opposite. I'm really trying to understand what's being said, but it seems that everyone is misunderstanding me or am I really blind.
    Quote Originally Posted by VictorN View Post
    No, you don't change the type of a control.
    And you don't have to change the type of a control.
    What you have to do is the change the type (class) of a control member variable you are to associate with this control (so called subclassing).
    And you was told many times about it.
    You guys are saying to use the add variable wizard to add all the variables. That will set up the instances and do the DDX stuff. I always understood that. It would be something like this:
    Code:
    class WM2000_Simulator : public Simulator_Base
    {
    	DECLARE_DYNAMIC(WM2000_Simulator)
    
    public:
    	WM2000_Simulator(CWnd* pParent = NULL);   // standard constructor
    	virtual ~WM2000_Simulator();
    
    	virtual void Do_Command(CSerial& serial);
    
    	virtual std::string Get_Data() const;
    
    // Dialog Data
    	enum { IDD = IDD_WM2000_SIMULATOR };
    private:
    	static const int WM2000_MAX_CEDIT_DIGITS = 6;
    	WM2000_Data data;
    
        void Set_Data_From_CEdit(int ID, double& data);
    protected:
    	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
    
    	virtual BOOL OnInitDialog();
    	DECLARE_MESSAGE_MAP()
    public:
    	CEdit at_edit; // change to CDecimalEdit at_edit;
    	CEdit ra_edit; // change to CDecimalEdit ra_edit;
    	CEdit rh_edit; // change to CDecimalEdit rh_edit;
    	CEdit sr_edit; // change to CDecimalEdit sr_edit;
    	CEdit wd_edit; // change to CDecimalEdit wd_edit;
    	CEdit ws_edit; // change to CDecimalEdit ws_edit;
    
    	afx_msg void OnEnChangeEditAt();
    	afx_msg void OnEnChangeEditWd();
    	afx_msg void OnEnChangeEditRh();
    	afx_msg void OnEnChangeEditRa();
    	afx_msg void OnEnChangeEditWs();
    	afx_msg void OnEnChangeEditSr();
    };
    I always understood that that is what you meant. But my question was, if I wanted to place the controls visually, then how would I change the type? It has been confirmed that by placing the controls visually, it is easier to position them, they come with the client edge and normal font as default and it's generally a lot easier. But when I click on Edit control in the toolbox and make one, I do not see a way to change its type as there is no instance created in the dialog's code. The link to the post you gave me does not explain this. It tells me to use the add variable wizard, which is not what I wanted to do (see this post).
    Last edited by Mybowlcut; February 19th, 2009 at 07:11 AM.
    Good judgment is gained from experience. Experience is gained from bad judgment.
    Cosy Little Game | SDL | GM script | VLD | Syntax Hlt | Can you help me with my homework assignment?

  8. #23
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: CEdit::Create & GetWindowRect

    Quote Originally Posted by Mybowlcut View Post
    ... it seems that everyone is misunderstanding me or am I really blind.
    Exactly.

    Quote Originally Posted by Mybowlcut View Post
    You guys are saying to use the add variable wizard to add all the variables. That will set up the instances and do the DDX stuff. I always understood that. It would be something like this:
    Code:
    class WM2000_Simulator : public Simulator_Base
    {
    	...
    	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
    
    	virtual BOOL OnInitDialog();
    	DECLARE_MESSAGE_MAP()
    public:
    	CEdit at_edit; // change to CDecimalEdit at_edit;
    	CEdit ra_edit; // change to CDecimalEdit ra_edit;
    	CEdit rh_edit; // change to CDecimalEdit rh_edit;
    	CEdit sr_edit; // change to CDecimalEdit sr_edit;
    	CEdit wd_edit; // change to CDecimalEdit wd_edit;
    	CEdit ws_edit; // change to CDecimalEdit ws_edit;
    	...
    	};
    I always understood that that is what you meant.
    Good! Then do it that way, remove all CEdit declarations and uncomment CDecimalEdit ones.
    And don't forget to #include header file with CDecimalEdit declarations.

    Quote Originally Posted by Mybowlcut View Post
    But my question was, if I wanted to place the controls visually,
    What do you mean by "visually"?
    In the "resource editor"? - You already got a lot of answers: just do it!

    Quote Originally Posted by Mybowlcut View Post
    then how would I change the type? ...
    But when I click on Edit control in the toolbox and make one, I do not see a way to change its type as there is no instance created in the dialog's code. The link to the post you gave me does not explain this. It tells me to use the add variable wizard, which is not what I wanted to do (see this post).
    You was already told then in this case (using VS versions higher than VS6) you just add the control variable of the *standard* type (CEdit), then go to the header file and edit the control declaration (change it from CEdit to your CDecimalEdit or any other type). And again: don't forget to #include header file with the new class declarations.
    Victor Nijegorodov

  9. #24
    Join Date
    Nov 2006
    Location
    Australia
    Posts
    1,569

    Re: CEdit::Create & GetWindowRect

    Quote Originally Posted by VictorN View Post
    Exactly.

    Good! Then do it that way, remove all CEdit declarations and uncomment CDecimalEdit ones.
    And don't forget to #include header file with CDecimalEdit declarations.

    What do you mean by "visually"?
    In the "resource editor"? - You already got a lot of answers: just do it!

    You was already told then in this case (using VS versions higher than VS6) you just add the control variable of the *standard* type (CEdit), then go to the header file and edit the control declaration (change it from CEdit to your CDecimalEdit or any other type). And again: don't forget to #include header file with the new class declarations.
    Yes, the resource editor would be the simplest and easiest way to create the controls because of the reasons I mentioned (I'm really not aiming for a convoluted workaround). Again, you are telling me that I have got a lot of answers and that they are all telling me to change the variable type from CEdit to my derived class.. I would but like I have already said several times, that I can see no variables to edit because they don't exist when I place the controls with the resource editor, as outlined by JohnCz here:
    Resource editor allows visually position controls in a dialog. Windows for controls are created at this time only as a representation of the template contents.
    Once dialog resource is saved, all information is written to a resource file as ASCII script.
    This is my problem... there are no variables for me to edit if I place the controls with the resource editor.
    Last edited by Mybowlcut; February 19th, 2009 at 07:55 AM.
    Good judgment is gained from experience. Experience is gained from bad judgment.
    Cosy Little Game | SDL | GM script | VLD | Syntax Hlt | Can you help me with my homework assignment?

  10. #25
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: CEdit::Create & GetWindowRect

    Quote Originally Posted by Mybowlcut View Post
    ... I can see no variables to edit because they don't exist when I place the controls with the resource editor, as outlined by JohnCz here...
    This is my problem... there are no variables for me to edit if I place the controls with the resource editor.

    But you posted the code snippet with all of the control variable declarations here!
    Victor Nijegorodov

  11. #26
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: CEdit::Create & GetWindowRect

    Quote Originally Posted by Mybowlcut View Post
    Code:
    	CEdit at_edit; // change to CDecimalEdit at_edit;
    	CEdit ra_edit; // change to CDecimalEdit ra_edit;
    	CEdit rh_edit; // change to CDecimalEdit rh_edit;
    	CEdit sr_edit; // change to CDecimalEdit sr_edit;
    	CEdit wd_edit; // change to CDecimalEdit wd_edit;
    	CEdit ws_edit; // change to CDecimalEdit ws_edit;
    
    	afx_msg void OnEnChangeEditAt();
    	afx_msg void OnEnChangeEditWd();
    	afx_msg void OnEnChangeEditRh();
    	afx_msg void OnEnChangeEditRa();
    	afx_msg void OnEnChangeEditWs();
    	afx_msg void OnEnChangeEditSr();
    };
    I always understood that that is what you meant. But my question was, if I wanted to place the controls visually, then how would I change the type? It has been confirmed that by placing the controls visually, it is easier to position them, they come with the client edge and normal font as default and it's generally a lot easier. But when I click on Edit control in the toolbox and make one, I do not see a way to change its type as there is no instance created in the dialog's code. The link to the post you gave me does not explain this. It tells me to use the add variable wizard, which is not what I wanted to do (see this post).
    You don't change the type when adding the variable. As your comments indicate above, you let it create CEdit variables and change it yourself. I've said that at least four times now.

    Change this
    Code:
    	CEdit ws_edit;
    to this
    Code:
    	CDecimalEdit ws_edit;
    That's it. That's all. You're done.

  12. #27
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: CEdit::Create & GetWindowRect

    Quote Originally Posted by Mybowlcut View Post
    This is my problem... there are no variables for me to edit if I place the controls with the resource editor.
    What do you mean there are no variables???? You're showing them all in the code snippet you posted.

  13. #28
    Join Date
    Nov 2006
    Location
    Australia
    Posts
    1,569

    Re: CEdit::Create & GetWindowRect

    Yes they are all there because I added them with the add variable wizard. I did not create them with the resource editor.

    For example, I can create a new project. I can add two Edit controls as pictured in the attachment. But it doesn't give me any instances to work with, as seen here:
    Code:
    // ttttttttttestDlg.h : header file
    //
    
    #pragma once
    
    
    // CttttttttttestDlg dialog
    class CttttttttttestDlg : public CDialog
    {
    // Construction
    public:
    	CttttttttttestDlg(CWnd* pParent = NULL);	// standard constructor
    
    // Dialog Data
    	enum { IDD = IDD_TTTTTTTTTTEST_DIALOG };
    
    	protected:
    	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
    
    
    // Implementation
    protected:
    	HICON m_hIcon;
    
    	// Generated message map functions
    	virtual BOOL OnInitDialog();
    	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
    	afx_msg void OnPaint();
    	afx_msg HCURSOR OnQueryDragIcon();
    	DECLARE_MESSAGE_MAP()
    };
    My whole point is that I want to change the type of these controls, but have no way to... there are no instances from which I can change their type.
    Attached Images Attached Images
    Good judgment is gained from experience. Experience is gained from bad judgment.
    Cosy Little Game | SDL | GM script | VLD | Syntax Hlt | Can you help me with my homework assignment?

  14. #29
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: CEdit::Create & GetWindowRect

    Quote Originally Posted by Mybowlcut View Post
    Yes they are all there because I added them with the add variable wizard. I did not create them with the resource editor.
    Why are you being so stubborn on this. That's what everybody's been telling you. Use the resource editor to draw your controls. Then use the add variable wizard to add CEdit controls. Then go in to your header and change their type from CEdit to your class. Is there some part of that that's still unclear? I don't know how else to put it.

  15. #30
    Join Date
    Nov 2006
    Location
    Australia
    Posts
    1,569

    Re: CEdit::Create & GetWindowRect

    Quote Originally Posted by VictorN View Post
    Exactly.

    Good! Then do it that way, remove all CEdit declarations and uncomment CDecimalEdit ones.
    And don't forget to #include header file with CDecimalEdit declarations.

    What do you mean by "visually"?
    In the "resource editor"? - You already got a lot of answers: just do it!

    You was already told then in this case (using VS versions higher than VS6) you just add the control variable of the *standard* type (CEdit), then go to the header file and edit the control declaration (change it from CEdit to your CDecimalEdit or any other type). And again: don't forget to #include header file with the new class declarations.
    Quote Originally Posted by GCDEF View Post
    Why are you being so stubborn on this. That's what everybody's been telling you. Use the resource editor to draw your controls. Then use the add variable wizard to add CEdit controls. Then go in to your header and change their type from CEdit to your class. Is there some part of that that's still unclear? I don't know how else to put it.
    I really am sorry that you guys are mistaking this as me being stubborn. I have no reason to be stubborn when I am the one asking for help. I have genuinely not understood what you guys were saying, because I honestly believe it was missing an important detail (which was to first place the controls visually but also add the control variables via the add class wizard). From the line you just wrote, I understand what you mean. But nowhere did I see anyone explain it like that. It was always like this (by wizard I assume you meant add variable wizard - I saw no mention of placing the control via the resource editor first, hence my confusion):
    The easiest thing to do here is let the wizards add the CEdit control variable and the DDX mechanism for you. Then with the text editor, change the control type from CEdit to your CEdit derived class and you're done.
    and this:
    you just add the control variable of the *standard* type (CEdit), then go to the header file and edit the control declaration (change it from CEdit to your CDecimalEdit or any other type).
    I hope you can see it from my point of view (especially never having used MFC before)? I saw no mention of first placing the control with the resource editor first, hence my repetitive questions.
    Good judgment is gained from experience. Experience is gained from bad judgment.
    Cosy Little Game | SDL | GM script | VLD | Syntax Hlt | Can you help me with my homework assignment?

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured