CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    85

    Can UpdateData(true) be called for only 1 var?

    To redefine an earlier problem.... I have a GUI with multiple edit boxes and a TreeControl. When the user clicks from the Editbox(s) to the TreeControl I need the updated info from the EditBox but someof the "pre-click" or old data from the TreeControl. Can I call UpdateData(true) on a specific EditBox?

  2. #2
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656
    No, you can not call UpdateData() on individual controls. You could create DataExchange object and call one control's DDX_... method, but that is too much work.
    Simply call GetWindowText() for your edit box.
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  3. #3
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    85
    Originally posted by VladimirF
    No, you can not call UpdateData() on individual controls. You could create DataExchange object and call one control's DDX_... method, but that is too much work.
    Simply call GetWindowText() for your edit box.
    I would but the editbox is a float and not a string. I just need to grab the data in one editbox before the focus changes and when calling UpdateData(true) in OnKillFocus for the edit box I get stuck getting ALL the data exchanged...

  4. #4
    Join Date
    May 2002
    Location
    Germany
    Posts
    487
    AFAIK every edit box contains a string. Maybe there is a filter to only allow numerical values to be entered, but everything is a string. Do not confuse your edit box with an attached member-variable, which might be float.
    Nomally DDX is doing the conversion for you. Using GetWindowText() should not call the DDX.

    Marc

  5. #5
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637
    Originally posted by VladimirF
    No, you can not call UpdateData() on individual controls. You could create DataExchange object and call one control's DDX_... method, but that is too much work.
    Simply call GetWindowText() for your edit box.
    Too much work??? It's 2 lines of code.

    CDataExchange DX(TRUE, this);
    DDX_Text(&DX, IDC_MY_CONTROL, m_FloatValue);

  6. #6
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656
    Originally posted by GCDEF
    Too much work??? It's 2 lines of code.
    Everyone has his own threshold for work...
    Of course, you are right.
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  7. #7
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815
    Originally posted by VladimirF
    Everyone has his own threshold for work...
    Threshold? Well, calling DDX_Text actually requires only two lines of code. The equivalent code amount for using GetWindowText() is not below or near that threshold, but goes somewhat like this (even without taking into account the (formerly unknown) fact that the control maps to a float variable):
    Code:
    CWnd* pEdit = GetDlgItem(IDC_MY_CONTROL);
    if(pEdit->GetSafeHwnd())
    {
      pEdit->GetWindowText(m_myValue);
    }
    With the float, you have to add another two lines for the CString declaration and the atof() call...

    Just kidding and being picky, of course...

  8. #8
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656
    Originally posted by gstercken
    Just kidding and being picky, of course...
    I was kidding too. I simply misjudged the effort in my first post, probably thinking that it would involve actually creating a custom DDX_... function. I WAS WRONG.

    Hey, give me some credit too - I suggested the possibility of using DataExchange object in my first post!
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  9. #9
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815
    Originally posted by VladimirF
    Hey, give me some credit too - I suggested the possibility of using DataExchange object in my first post!
    Yeah, the Oscar for the most innovative, revolutionary technique of calling DDX_Text directly goes to... VladimirFFFFFFFFFF...
    Last edited by gstercken; February 5th, 2004 at 08:35 PM.

  10. #10
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656
    Originally posted by gstercken
    Yeah, the Oscar for the most innovative technique of calling DDX_Text directly goes to... VladimirFFFFFFFFFF...
    Thank you! That all I've asked for...
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

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