Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying String Output in a Window using C (in WIN32 API)

I want a proper way in which I can output a character string and display it on a Window created. I had been using textout() function, but since it only paints the window, once the window is minimized and restored back, the data displayed on the window disappears. Also when the data to be displayed is exceeds the size of Window, only the data equal to window size is displayed and other data is truncated. Is there any other way to output data on a Window?

like image 515
Ayse Avatar asked Mar 15 '13 10:03

Ayse


1 Answers

You can put a Static or an Edit control (Label and a text box) on your window to show the data.

Call one of these during WM_CREATE:

HWND hWndExample = CreateWindow("STATIC", "Text Goes Here", WS_VISIBLE | WS_CHILD | SS_LEFT, 10,10,100,100, hWnd, NULL, hInstance, NULL);

Or

HWND hWndExample = CreateWindow("EDIT", "Text Goes Here", WS_VISIBLE | WS_CHILD | ES_LEFT, 10,10,100,100, hWnd, NULL, hInstance, NULL);

If you use an Edit then the user will also be able to scroll, and copy and paste the text.

In both cases, the text can be updated using SetWindowText():

SetWindowText(hWndExample, TEXT("Control string"));

(Courtesy of Daboyzuk)

like image 124
Deanna Avatar answered Sep 30 '22 17:09

Deanna