views:

78

answers:

2

im using visual studio c++ 2008 i created project that contents the full window code. i don't know how to output text to window. i mean i have full functional window with menu bar and under the menu bar there is the body im trying to ouput the text in the body but how?

+1  A: 

This page has a sample on how to do it in Win32:
http://www.rohitab.com/discuss/index.php?showtopic=11454

The code below is the Window Procedure for the window, if you note the WM_PAINT (That is the message that tells the window to paint itself) the code is simply drawing the text to 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;
}
Romain Hippeau
A: 

As a out of topic note, I suggest you to try some 3rd party library instead, as it can be much more convenient. Take a look to wxWidgets for instance.

nhaa123