function TMiniWin.WinCreate: Boolean;
begin  Result:=false;
if wATM=0 then if not WinRegister then exit;
 hWindow:=CreateWindow({PChar(AppName)}PChar(wATM), PChar('ObjectPascalWindow'),
            ws_OverlappedWindow, cw_UseDefault, cw_UseDefault,
            cw_UseDefault, cw_UseDefault, 0, 0, HInstance, nil);
 Result:=hWindow<>0;
 if Result then begin
 SetWindowLong( hWindow,GWL_WNDPROC ,integer(@WindowProc));
 SetWindowLong( hWindow,GWL_USERDATA  ,integer(self));
 end;
end;

function TMiniWin.Show:boolean;
begin
Result:=False; if hWindow=0 then if not WinCreate then exit;
  Result:= ShowWindow(hWindow, CmdShow);
  Updatewindow(hWindow);
end;

constructor TMiniWin.Create;
begin  inherited
end;

procedure TMiniWin.WMPaint(var Message: TWMPaint);
var h:HDC;
var ps:PAINTSTRUCT;
 procedure textOut(x,y:Integer;s:string);begin Windows.TextOut(h,x,y,PChar(s),Length(s)); end ;
begin
 h:=BeginPaint(hWindow,ps);
  textOut(10,10,'こんにちは');
 EndPaint(hWindow,ps);
end;

procedure RunMessageLoop;
var AMessage: TMsg;
begin
 while GetMessage(AMessage, 0, 0, 0) do
 begin
  TranslateMessage(AMessage);
  DispatchMessage(AMessage);
 end;
end;
///////// main /////////
var MiniWin:TMiniWin;
begin
 MiniWin:=TMiniWin.Create;
 MiniWin.Show;
 RunMessageLoop
end.