Lkaf Temravet
Lkaf Temravet

Reputation: 993

how can I display unsigned char with SetWindowText

I want to display unsigned char value with SetWindowText, but nothing displayed on label

code

DWORD WINAPI fill_matrix(LPVOID lpParameter)
{
    unsigned char a = 'h';

    for (int i = 0; i < 8; i++){
        for (int j = 0; j <8; j++)
        {
            SetWindowText(hWndLabel[i * 8 + j], (LPCTSTR)a);
        }
    }
    return 0;

}

I configured my project proprieties with unicode

Upvotes: 0

Views: 620

Answers (1)

MikeCAT
MikeCAT

Reputation: 75062

  • SetWindowText requires string, not a single charater.
  • You should use SetWindowTextA, which explicitly use ANSI characters.

Fixed code:

DWORD WINAPI fill_matrix(LPVOID lpParameter)
{
    unsigned char a = 'h';

    for (int i = 0; i < 8; i++){
        for (int j = 0; j <8; j++)
        {
            char window_text[2] = {a, '\0'};
            SetWindowTextA(hWndLabel[i * 8 + j], window_text);
        }
    }
    return 0;

}

Upvotes: 1

Related Questions