#include <windows.h>
#ifdef __BORLANDC__
  #pragma argsused
#endif
extern HINSTANCE _hInstance; // variable created by the startup code
 static const char tytul[] = "Okno glówne aplikacji";

 LRESULT CALLBACK GlownaFunkcja(HWND hwnd, UINT msge, WPARAM wParam, LPARAM lParam)
   {

   switch (msge)
     {
     case WM_PAINT :
       {
       PAINTSTRUCT ps; // info structure filled in by BeginPaint

       BeginPaint(hwnd, &ps);
       TextOut(ps.hdc, 0, 0, "Test Test Test", lstrlen("Test Test Test"));
       EndPaint(hwnd, &ps);
       return 0;
       }

     // when it's closed, we want to discard the window
     case WM_CLOSE : { DestroyWindow(hwnd); break; }

     // send message to main loop ordering the program to end
     case WM_DESTROY : { PostQuitMessage(0); return 0; }
     }
   return DefWindowProc(hwnd, msge, wParam, lParam);
   }

int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
  MSG msg;
HWND main_hwnd;
WNDCLASS glowne_okno;

 glowne_okno.style = CS_HREDRAW | CS_VREDRAW;
 glowne_okno.lpfnWndProc = GlownaFunkcja;
 glowne_okno.cbClsExtra = glowne_okno.cbWndExtra = 0;
 glowne_okno.hInstance = _hInstance;
 glowne_okno.hIcon = LoadIcon(NULL, IDI_APPLICATION);
 glowne_okno.hCursor = LoadCursor(NULL, IDC_ARROW);
 glowne_okno.hbrBackground = (HBRUSH)COLOR_WINDOW;
 glowne_okno.lpszMenuName = NULL;
 glowne_okno.lpszClassName = tytul;

 if (RegisterClass(&glowne_okno))
   {
   main_hwnd = CreateWindow(tytul, tytul,
                WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
                CW_USEDEFAULT, CW_USEDEFAULT,
                CW_USEDEFAULT, CW_USEDEFAULT,
                HWND_DESKTOP, NULL, _hInstance, NULL);
   }
 else
   main_hwnd = NULL;
   CreateWindow("button", "Przycisk", WS_CHILD | WS_VISIBLE,
   10,10,60,30, main_hwnd, (HMENU)1, hInstance, NULL);
if (main_hwnd)
  {
  ShowWindow(main_hwnd, nCmdShow);
  UpdateWindow(main_hwnd);

  while (GetMessage(&msg, NULL, 0, 0) > 0)
    {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
  }

return msg.message;
}
