I want to print on thw window with a button

hello my problem is that i cant print this on the screen im nwew on this and dont know hot it works, so i will apreciate any help, i want to print a message on the screen when a i press a button and i dont know why dont work

#define button1 1

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{


switch (message) /* handle the messages */
{
case WM_CREATE:{ CreateWindow(TEXT("button"),
TEXT("Button1"),WS_VISIBLE | WS_CHILD,
HMENU) button1,NULL,NULL);



break;


}

case WM_COMMAND:{

if(LOWORD(wParam) == button1){

PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd,&ps);
TextOut(hdc,120,10,"Hola mundo ventana",20);
Beep(200,200)
EndPaint(hwnd,&ps);

}

break;

}
}

You're all messed up. Can't use BeginPaint() except in WM_PAINT handlers. You can use GetDC() to paint, but it won't persist (its an extremely poor practice to get into).
Oh thank! it works but your right when i close the window the message dissapear, u know a way to fix this?
Last edited on
Well if your using the exact message handler as shown above. Then your not handling your close calls properly.

All basic C++ message handlers have this:
1
2
3
case WM_DESTROY:
  PostQuitMessage(0);
  return 0;
i just put the part i want to know how it works, im using the basic format that give my compiler when i execute the program, i just add that code
Topic archived. No new replies allowed.