Problems with buttons!! (Help Help)

This is a discussion on Problems with buttons!! (Help Help) within the Windows Programming forums, part of the Platform Specific Boards category; I'm trying to wrote a sort of keyboard on screen, so when an user presses a button, corresponding to a ...

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    45

    Problems with buttons!! (Help Help)

    I'm trying to wrote a sort of keyboard on screen, so when an user presses a button, corresponding to a letter from A to Z, in the edit control included in the main screen under the virtual keyboard, the user could see the letter that he pressed and the entire word!

    I'm able to write an easy way for this:
    Code:
            LPTSTR item = "Q";
    
    	this->SetDlgItemText(IDC_EDIT1,item);
    }
    But when I press another button the previous letter is ovewritten.

    For example:
    1.Button pressed Q->(result in the IDC_EDIT) Q
    2.Button pressed U->(result in the IDC_EDIT) U (instead of QU)
    3.Button pressed E->(result in the IDC_EDIT) E (instead of QUE)
    4.Button pressed U->(result in the IDC_EDIT) U (instead of QUEU)
    5.Button pressed E->(result in the IDC_EDIT) E (instead of QUEUE)

    Does anybody has an hint, helping me with this problem?

  2. #2
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    Yep, You have to retrieve the text that's in it first, then append the letter you want onto the end like so:
    Code:
    char buffer[256];
    ZeroMemory(buffer,256);
    GetDlgItemText(this,IDC_EDIT1,buffer,255);
    strcat(buffer,item);
    SetDlgItemText(this,IDC_EDIT1,buffer);
    I don't think you need to include cstring if you include windows.h.
    Last edited by jmd15; 10-16-2005 at 12:29 PM.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  3. #3
    Registered User
    Join Date
    Jul 2005
    Posts
    45
    Thank you, really thank you, now it works correctly!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 04-09-2009, 03:31 AM
  2. Ownerdraw buttons (2)
    By maes in forum Windows Programming
    Replies: 7
    Last Post: 09-11-2003, 06:50 AM
  3. Radio Buttons in Visual C++ 6
    By Ripper1 in forum Windows Programming
    Replies: 22
    Last Post: 05-16-2003, 08:54 AM
  4. Problems with default buttons
    By pinkcheese in forum Windows Programming
    Replies: 2
    Last Post: 05-24-2002, 02:31 PM
  5. Grouping radio buttons
    By Bazz in forum Windows Programming
    Replies: 1
    Last Post: 08-28-2001, 08:15 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21