C ++ win32 prints text

im using visual studio C ++ 2008, I created a project that contains the full window code. I do not know how to display text in a window. I mean, I have a full functional window with a menu bar, and under the menu bar there is a body trying to display text in the body, but how?

+3
source share
2 answers

This page has an example of how to do this in Win32:
http://www.rohitab.com/discuss/index.php?showtopic=11454

Below is the Window code for the window, if you notice WM_PAINT (this is a message that tells the window to draw it), the code simply draws text in the Device Context, which is the client area of ​​the window.

LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
        HDC hdc;
        PAINTSTRUCT ps;
        LPSTR szMessage = "darkblue 0wNz j00!";
        switch(Message) {
                case WM_PAINT:
                        hdc = BeginPaint(hwnd, &ps);
                        TextOut(hdc, 70, 50, szMessage, strlen(szMessage));
                        EndPaint(hwnd, &ps);
                        break;
                case WM_CLOSE:
                        DestroyWindow(hwnd);
                        break;
                case WM_DESTROY:
                        PostQuitMessage(0);
                        break;
                default:
                        return DefWindowProc(hwnd, Message, wParam, lParam);
        }
        return 0;
}
+4

, , . wxWidgets, .

+1

Source: https://habr.com/ru/post/1758567/


All Articles