Thread: How can I add to TextBox??(MFC)

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    43

    How can I add to TextBox??(MFC)

    -
    If I have a dialog box that contain textbox and botton .. I want the botton, when I press it, add letter to the textbox.

    If you saw the Windows Calculator . When you press [1] botton it add '1' to the text box... How can I make this..

    --------------------------------
    this is the (OnBottonPress) function that I made:

    CMyDialog dlg;
    dlg.TextBox=dlgTextbox+'1';
    ---------------------------------------
    But no thing happen?!

  2. #2
    Registered User
    Join Date
    Aug 2002
    Posts
    57
    in your resource file

    Code:
    #include "Resource.rc"
    #define IDC_STATIC
    
    IDI_DIALOG DIALOG DISCARDABLE 0, 0, 100, 100
    STYLE DS_MODALFRAME | WS_SYSMENU | WS_POPUP | WS_CAPTION
    CAPTION "Sample Dialog"
    FONT 9, "Book Antiqua"
    BEGIN
        GROUPBOX           "Hey......", IDC_STATIC, 3, 3, 90, 90 
        PUSHBUTTON        "Press OK!", IDOK, 7, 7, 50, 50
        CTEXT                   "This is probably the text you were trying to do!!!", IDC_STATIC, 7, 53, 50, 20
    END
    You were trying to do that right?

  3. #3
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Read the existing text from the edit box with GetDlgItemText(), (or similar), use strcat() to append the new character, then SetDlgItemText() to put the new string back.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  4. #4
    Registered User
    Join Date
    Aug 2002
    Posts
    57
    yea, what he said......
    "A Programmer being told to 'go to' hell sees the 'go to' part of the sentence as the worst part." - Master Foto

  5. #5
    Registered User
    Join Date
    Dec 2001
    Posts
    43

    Smile thank you very much!

    thank you all.. the problem have been solved ...

    I used the GetDlgItem() and the SetWindowText() Functions to do.

    thank you again

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I Can Add!
    By digdug4life in forum C++ Programming
    Replies: 9
    Last Post: 02-07-2005, 03:36 PM
  2. Add a dialog box to a tab
    By axr0284 in forum Windows Programming
    Replies: 0
    Last Post: 01-10-2005, 08:38 AM
  3. can not add member error
    By WaterNut in forum Windows Programming
    Replies: 4
    Last Post: 12-02-2004, 01:18 PM
  4. VC++ Resources - Add Existing Item
    By EliMcGowan in forum Windows Programming
    Replies: 1
    Last Post: 08-30-2004, 02:51 PM
  5. Add user without interacting.
    By zahid in forum Linux Programming
    Replies: 3
    Last Post: 12-21-2002, 11:36 PM