home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / wunderki.zip / HELLOPM.PAS < prev    next >
Pascal/Delphi Source File  |  1993-09-30  |  4KB  |  139 lines

  1. Program HelloPresentationManager; {$F+}
  2. {--- 1993 Matthias Withopf / c't ---}
  3.  
  4. Type
  5.   MResult = Pointer;
  6.   HWnd      = Pointer;
  7.   MParam  = Pointer;
  8.   HPS      = Pointer;
  9.   HAB      = Pointer;
  10.   HMQ      = Pointer;
  11.   PointL  = Record
  12.           x,y : LongInt;
  13.         End;
  14.   PRectL  = ^RectL;
  15.   RectL   = Record
  16.           xLeft,yBottom,xRight,yTop : LongInt;
  17.         End;
  18.   QMsg      = Record
  19.           Window  : HWND;
  20.           Msg     : Word;
  21.           mp1,mp2 : MParam;
  22.           Time    : LongInt;
  23.           Ptl     : PointL;
  24.         End;
  25. Const
  26.   WM_CREATE         = $0001;
  27.   WM_DESTROY         = $0002;
  28.   WM_COMMAND         = $0020;
  29.   WM_PAINT         = $0023;
  30.   WM_QUIT         = $002A;
  31.   WS_VISIBLE         = $80000000;
  32.   FCF_TITLEBAR         = $0001;
  33.   FCF_SYSMENU         = $0002;
  34.   FCF_MENU         = $0004;
  35.   FCF_SIZEBORDER     = $0008;
  36.   FCF_MINBUTTON      = $0010;
  37.   FCF_MAXBUTTON      = $0020;
  38.   FCF_SHELLPOSITION  = $0400;
  39.   FCF_TASKLIST         = $0800;
  40.   MB_ICONEXCLAMATION = $0020;
  41.   MB_MOVEABLE         = $4000;
  42.  
  43.   Function DosBeep(Freq,Duration : Word) : Word;
  44.     External 'DOSCALLS' Index 50;
  45.   Function WinRegisterClass(ab : HAB;ClassName : PChar;WndProc : Pointer;
  46.                 Style : LongInt;WinData : Word) : Boolean;
  47.     External 'PMWIN' Index 3;
  48.   Function WinDestroyWindow(Window : HWND) : Boolean;
  49.     External 'PMWIN' Index 7;
  50.   Function WinQueryWindowRect(Window : HWND;R : PRECTL) : Boolean;
  51.     External 'PMWIN' Index 26;
  52.   Function WinBeginPaint(Window : HWND;PS : HPS;R : PRECTL) : HPS;
  53.     External 'PMWIN' Index 45;
  54.   Function WinEndPaint(PS : HPS) : Boolean;
  55.     External 'PMWIN' Index 46;
  56.   Function WinCreateMsgQueue(ab : HAB;Size : Word) : HMQ;
  57.     External 'PMWIN' Index 58;
  58.   Function WinDestroyMsgQueue(mq : HMQ) : Boolean;
  59.     External 'PMWIN' Index 59;
  60.   Function WinGetMsg(ab : HAB;Var Msg : QMsg;Filter : HWND;
  61.              Fist,Last : Word) : Boolean;
  62.     External 'PMWIN' Index 65;
  63.   Function WinDispatchMsg(ab : HAB;Var Msg : QMsg) : LongInt;
  64.     External 'PMWIN' Index 68;
  65.   Function WinPostMsg(hWnd : HWND;Msg : Word;mp1,mp2 : MParam) : Word;
  66.     External 'PMWIN' Index 69;
  67.   Function WinMessageBox(Parent,Owner : HWND;Text,Caption : PChar;
  68.              WindowID,Style : Word) : Word;
  69.     External 'PMWIN' Index 139;
  70.   Function WinCreateStdWindow(Parent : HWND;Style : LongInt;
  71.                   Var CreateFlags : LongInt;
  72.                   ClassName : PChar;Title : PChar;
  73.                   ClientStyle : LongInt;
  74.                   Module : Word;Res : Word;
  75.                   Var ClientWnd : HWND) : HWND;
  76.     External 'PMWIN' Index 140;
  77.   Function WinDefWindowProc(Window : HWND;Msg : Word;
  78.                 mp1,mp2 : MParam) : MResult;
  79.     External 'PMWIN' Index 178;
  80.   Function WinInitialize(Option : Word) : HAB;
  81.     External 'PMWIN' Index 246;
  82.   Function WinTerminate(ab : HAB) : Boolean;
  83.     External 'PMWIN' Index 247;
  84.   Function WinDrawText(PS : HPS;StrLen : Integer;Str : PChar;R : PRECTL;
  85.                FG,BG : LongInt;Cmd : Word) : HPS;
  86.     External 'PMWIN' Index 267;
  87.  
  88. Var
  89.   Frame,Client : HWND;
  90.   ab           : HAB;
  91.   mq           : HMQ;
  92.   Msg           : QMSG;
  93. Const
  94.   FrameFlags   : LongInt = FCF_TITLEBAR+FCF_SYSMENU+FCF_MENU+
  95.                FCF_SIZEBORDER+FCF_MINBUTTON+FCF_MAXBUTTON+
  96.                FCF_SHELLPOSITION+FCF_TASKLIST;
  97.  
  98.   Function ClientWndProc(Window : HWND;Msg : Word;
  99.              mp1,mp2 : MParam) : MResult; Export;
  100.   Const
  101.     Text = 'Hello, OS/2 Presentation Manager !';
  102.   Var
  103.     ps    : HPS;
  104.     rcl : RECTL;
  105.   Begin
  106.      ClientWndProc := Nil;
  107.      Case Msg of
  108.        WM_CREATE : DosBeep(200,10);
  109.     WM_PAINT : Begin
  110.              ps := WinBeginPaint(Window,Nil,Nil);
  111.              WinQueryWindowRect(Window,@rcl);
  112.              WinDrawText(ps,-1,Text,@rcl,0,7,$8500);
  113.              WinEndPaint(ps);
  114.            End;
  115.       WM_COMMAND : Case Word(mp1) of
  116.              101 : DosBeep(4500,40);
  117.              109 : WinPostMsg(Nil,WM_QUIT,Nil,Nil);
  118.              201 : WinMessageBox(Frame,Window,
  119.                 'HelloPM by Matthias Withopf / c''t',
  120.                 'About...',0,MB_ICONEXCLAMATION+MB_MOVEABLE);
  121.            End;
  122.       WM_DESTROY : DosBeep(500,10);
  123.          else
  124.            ClientWndProc := WinDefWindowProc(Window,Msg,mp1,mp2);
  125.      End;
  126.   End;
  127.  
  128. Begin
  129.   ab := WinInitialize(0);
  130.   mq := WinCreateMsgQueue(ab,0);
  131.   WinRegisterClass(ab,'HELLOPM',@ClientWndProc,4,0);
  132.   Frame := WinCreateStdWindow(HWND(1),WS_VISIBLE,FrameFlags,'HELLOPM',
  133.                   Nil,0,0,1,Client);
  134.   While (WinGetMsg(ab,Msg,Nil,0,0)) do WinDispatchMsg(ab,Msg);
  135.   WinDestroyWindow(Frame);
  136.   WinDestroyMsgQueue(mq);
  137.   WinTerminate(ab);
  138. End.
  139.