(***********************************************)
(*                                             *)
(* Hello World!                                *)
(* Copyright (c) 1999 by TMT Development Corp. *)
(* Author: Vadim Bodrov, TMT Development Corp. *)
(*                                             *)
(* Targets:                                    *)
(*   WIN32 GUI application                     *)
(*                                             *)
(***********************************************)

program HelloW32;

{$ifndef __WIN32__}
{$define INVALID_TARGET}
{$endif}
{$ifndef __GUI__}
{$define INVALID_TARGET}
{$endif}
{$ifdef INVALID_TARGET}
  This program must be compiled as Win32 GUI application only
{$endif}

uses Windows, Messages;

function MyWndProc conv arg_stdcall (Window: HWND; Mess: UINT; Wp: WParam; Lp: LParam): LRESULT;
var
  DC: hDC;
  ps: TPaintStruct;
begin
  Result := 0;
  case Mess of
    WM_PAINT:
      begin
        DC := BeginPaint(Window, ps);
        TextOut(DC, 0, 0, 'Hello World!', 12);
        EndPaint(Window, ps);
      end;
    WM_DESTROY:
      PostQuitMessage(0);
   else
      Result := DefWindowProc(Window, Mess, Wp, Lp);
  end;
end;

var
  wc : TWndClass;
  wnd: HWnd;
  Msg: TMsg;
begin
  FillChar(wc, SizeOf(wc), 0);
  with wc do begin
    style:=CS_HREDRAW + CS_VREDRAW;
    lpfnWndProc := @MyWndProc;
    cbClsExtra := 0;
    cbWndExtra := 0;
    hInstance := System.hInstance;
    hIcon := LoadIcon(THandle(NIL), IDI_EXCLAMATION);
    hCursor := LoadCursor(THandle(NIL), IDC_ARROW);
    hbrBackGround := COLOR_WINDOW + 1;
    lpszMenuName := nil;
    lpszClassName := 'Hello_World';
  end;
  if RegisterClass(wc) = 0 then
  begin
    Exit;
  end;

  wnd := CreateWindow(wc.lpszClassName, 'GUI Application Demo', WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0, 0, HInstance, nil);

  ShowWindow(wnd, SW_RESTORE);
  UpdateWindow(wnd);

  while GetMessage(Msg,0,0,0) do

  begin
    TranslateMessage(Msg);
    DispatchMessage(Msg);
  end;

end.