Thread: Problems with buttons!! (Help Help)

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