PDA

Click to See Complete Forum and Search --> : Set Text on WM_KEYDOWN


wey97
Oct 30th, 2001, 07:57 PM
On WM_KEYDOWN I am setting the text of a label like so:

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?

abdul
Oct 30th, 2001, 08:17 PM
Try putting that under "WM_CHAR" message.