home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / APPS / PROG / PASCAL / SPEED2 / SAMPLES / HALLO1 / HALLO1.PAS < prev   
Pascal/Delphi Source File  |  1994-10-11  |  3KB  |  94 lines

  1. PROGRAM Hallo1;
  2.  
  3. {***************************************************************************
  4. *                                                                          *
  5. *                Speed-Pascal/2 Sample program "Hallo1"                    *
  6. *                                                                          *
  7. *           (C) 1993,94 Rene Nürnberger. All rights reserved.              *
  8. *                                                                          *
  9. *                                                                          *
  10. *  This program puts out the text "Hrllo world" into a PM window.          *
  11. *                                                                          *
  12. *                                                                          *
  13. ****************************************************************************}
  14.  
  15.  
  16. USES Crt,API,PmTypes;  {bind Units used}
  17.  
  18.  
  19. VAR
  20.     HalloClass:STRING; {Window class for main window}
  21.     WindowStyle:ULONG; {Style of the main window}
  22.     Frame,Win:HWND;    {Handles of the main window}
  23.     Title:STRING;      {Title of the main window}
  24.     _qmsg:QMSG;        {Message Queue}
  25.  
  26.  
  27. {Window procedure for the Window-Class "Hallo". Handles messages.
  28.  Messages not processed will be given to the Standard Window-Procedure
  29.  (WinDefWndProc).
  30.  This function must be CDECL because PM calls this in C-Manner}
  31. FUNCTION WindowProc(Win:HWND;Msg:ULONG;Para1,Para2:POINTER):ULONG;CDECL;
  32. VAR Handled:BOOLEAN;
  33.     result:ULONG;
  34.     _hps:HPS;
  35.     rec:RECTL;
  36.     point:POINTL;
  37.     s:STRING;
  38. BEGIN
  39.      Handled:=TRUE;
  40.      result:=0;
  41.      CASE Msg OF
  42.          WM_ERASEBACKGROUND:result:=1;
  43.          WM_PAINT:
  44.          BEGIN
  45.               _hps:=WinBeginPaint(rec,0,Win);
  46.               GpiSetBackColor(CLR_BACKGROUND,_hps);
  47.               GpiSetColor(CLR_NEUTRAL,_hps);
  48.               GpiSetBackMix(BM_OVERPAINT,_hps);
  49.               point.x:=50;
  50.               point.y:=100;
  51.               s:='Hello world...';
  52.               GpiCharStringAt(s[1],length(s),point,_hps);
  53.               WinEndPaint(_hps);
  54.          END;
  55.          WM_CLOSE:WinPostMsg(NIL,NIL,WM_QUIT,Win);
  56.          ELSE Handled:=FALSE;
  57.      END; {Case}
  58.      IF not Handled THEN result:=WinDefWindowProc(Para2,Para1,Msg,Win);
  59.      WindowProc:=result;
  60. END;
  61.  
  62. BEGIN {Main}
  63.      {Initialize PM}
  64.      AppHandle:=WinInitialize(0);
  65.      AppQueueHandle:=WinCreateMsgQueue(0,AppHandle);
  66.  
  67.      {register Window-Class}
  68.      HalloClass:='Hallo';
  69.      WinRegisterClass(0,CS_SIZEREDRAW,@WindowProc,HalloClass,AppHandle);
  70.  
  71.      {define main application window}
  72.      WindowStyle:=FCF_TITLEBAR OR FCF_SYSMENU OR FCF_MINMAX OR FCF_TASKLIST
  73.                   OR FCF_SIZEBORDER;
  74.       Title:='Hallo1 Sample Application';
  75.      Frame:=WinCreateStdWindow(Win,0,0,0,Title,HalloClass,WindowStyle,0,
  76.                                HWND_DESKTOP);
  77.  
  78.      {Set position and show main window}
  79.      WinSetWindowPos(SWP_SHOW OR SWP_ACTIVATE OR SWP_MOVE OR SWP_SIZE,
  80.                      200,300,100,100,HWND_TOP,Frame);
  81.  
  82.      {Handle message queue}
  83.      WHILE WinGetMsg(0,0,0,_qmsg,Apphandle)<>0 DO
  84.        WinDispatchMsg(_qmsg,Apphandle);
  85.  
  86.      {Delete main window}
  87.      WinDestroyWindow(Frame);
  88.  
  89.      {Shut down PM}
  90.      WinDestroyMsgQueue(AppQueueHandle);
  91.      WinTerminate(AppHandle);
  92. END.
  93.