CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Guest

    Which Control to disply a variable(s)

    Wondering which control I would use to disply a variable ( char. or num.) And how is it done.... Please help if you can...
    I have tried using a static text box in VC++ 5. and I just get errors..


  2. #2
    Join Date
    May 1999
    Location
    Atlanta, GA, USA
    Posts
    443

    Re: Which Control to disply a variable(s)

    Hi.

    I often use CStaic, CEdit and CListBox to display my data.
    I assume that a static text box means CStatic control?
    You must change its ID from IDC_STATIC to IDC_MYSTATIC, for example.

    When you put label by CStatic control, its id is always IDC_STATIC.
    So you must differentiate it.

    GetDlgItem(IDC_MYSTATIC)->SetWidnowText("Test");
    or
    CStatic* ptrCtl = (CStatic*)GetDlgItem(IDC_MYSTATIC);
    ptrCtl->SetWindowText("Test");

    or make control the member control by class wizard
    and m_ctl.SetWindowText("Test");

    Hope for help.
    -Masaaki Onishi-




  3. #3
    Guest

    Re: Which Control to disply a variable(s)

    ok,
    GetDlgItem(IDC_MYSTATIC)->SetWidnowText("Test");
    Would '("Test")' be replaced with ("VarriableName") ???? ..
    ex... Dialog based program.. click this button and it increasses value X
    by value Y... show the new varriable called VarriableName...
    ??
    or am I lost


  4. #4
    Join Date
    May 1999
    Location
    Atlanta, GA, USA
    Posts
    443

    Re: Which Control to disply a variable(s)

    Hi.
    I don't know your approach and code, so can't point out a idea which you want.
    Basically, you need some conversion function. For example,
    int -> string : itoa() function
    or
    string -> int: atoi() function and so on.

    If you enter the data in Edit box, how this edit box deal with this data as int or string.
    This is your choice. But if you deal with the data by plus, you had better use int format.
    After this, in order to convert it from int to string in order to use SetWindowText() to CStatic control,
    you use conversion function above.

    Hope for help.
    -Masaaki Onishi-


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