VS C++ converting int to char (string)

Wojciech Sobiesiak 101 Reputation points
2023-01-28T11:40:41.69+00:00

Hello.

I have a problem with such thing.

Output is as show at the bottom of page.

Can anyone know how to show text inside the edit window as number? (and how to get a number from window as text)

Help pages on the internet are not readable.

The output is something like "˙ĚĚĚĚĚĚĚĚĚĚĚĚ"

111111

int cxScreen, cyScreen;
            cxScreen = GetSystemMetrics(SM_CXSCREEN);
            char str_ll[20];// = std::to_string(cxScreen);
           
            
            IntToChar(cxScreen,&str_ll[0]);
            
                SetWindowTextA(hText,str_ll);
Windows development Windows API - Win32
Developer technologies C++
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Viorel 122.5K Reputation points
    2023-01-28T12:25:18.37+00:00

    If your edit control has an ID, then consider the SetDlgItemInt function.

    Or try this: SetWindowTextA( hText, std::to_string( cxScreen ).c_str( ) ).

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.