Results 1 to 2 of 2

Thread: Set Text on WM_KEYDOWN

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Resolved Set Text on WM_KEYDOWN

    On WM_KEYDOWN I am setting the text of a label like so:
    Code:
    case WM_KEYDOWN:
         setText((int)wParam);
         break;
    
    void setText(int x){
    	LPTSTR ItemText;
    	ItemText = new TCHAR[50];
    	GetWindowText(hwndStatic, ItemText, 50);
    	char c = (char)x;
    	char* a = new char[2];
    	a[0] = c;
    	a[1] = '\0';
    	strcat(ItemText, a);
    	SetWindowText(hwndStatic, ItemText);
    	delete[] ItemText;
    	delete[] a;	
    }
    This seems to work well for digits and letters but nothing else.
    What is a better way to code this?
    Last edited by wey97; Nov 10th, 2004 at 10:57 AM.

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