basicpm.pas 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1993-2001 by Free Pascal team
  5. The most basic Presentation Mode example.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. program BasicPM;
  13. uses
  14. Os2Def, PMWin;
  15. function ClientWindowProc (Window, Msg: cardinal; MP1, MP2: pointer): pointer;
  16. cdecl; export;
  17. var
  18. Li: longint;
  19. Ps: cardinal;
  20. R: TRectL;
  21. P: TPointL;
  22. Rgn: cardinal;
  23. begin
  24. ClientWindowProc := nil;
  25. case Msg of
  26. wm_Paint: begin
  27. PS := WinBeginPaint (Window, 0, @R);
  28. WinFillRect (PS, @R, SYSCLR_WINDOW);
  29. WinEndPaint (PS);
  30. end;
  31. else ClientWindowProc := WinDefWindowProc (Window, Msg, MP1, MP2);
  32. end;
  33. end;
  34. const
  35. idClientWindow = 11000;
  36. WinFlags: cardinal = fcf_TitleBar + fcf_SysMenu + fcf_SizeBorder +
  37. fcf_MinMax + fcf_TaskList + fcf_NoByteAlign;
  38. ClassName = 'MYVIEW';
  39. var
  40. Anchor, MsgQue: cardinal;
  41. Message: TQMsg;
  42. Frame, Client: cardinal;
  43. begin
  44. Anchor := WinInitialize(0);
  45. { It might be beneficial to set the second parameter of the following }
  46. { call to something large, such as 1000. The OS/2 documentation does }
  47. { not recommend this, however } MsgQue := WinCreateMsgQueue (Anchor, 0);
  48. if MsgQue = 0 then Halt (254);
  49. WinMessageBox (HWND_DESKTOP, HWND_DESKTOP, 'FPC test', 'Basic PM', 0,
  50. MB_OK or MB_INFORMATION);
  51. WinRegisterClass (Anchor, ClassName, proc (@ClientWindowProc), cs_SizeRedraw,
  52. SizeOf (pointer));
  53. Frame := WinCreateStdWindow (hwnd_Desktop, 0, WinFlags, ClassName,
  54. 'BASIC PM', 0, 0, idClientWindow, Client);
  55. if (Frame <> 0) then
  56. begin
  57. WinSetWindowPos (Frame, 0, 0, WinQuerySysValue (hwnd_Desktop,
  58. sv_CyScreen) - 200, 200, 200, swp_Move + swp_Size + swp_Activate +
  59. swp_Show);
  60. while WinGetMsg (Anchor, Message, 0, 0, 0) do
  61. WinDispatchMsg (Anchor, Message);
  62. WinDestroyWindow (Frame);
  63. end;
  64. WinDestroyMsgQueue (MsgQue);
  65. WinTerminate (Anchor);
  66. end.
  67. {
  68. $Log$
  69. Revision 1.1 2001-01-14 19:02:14 hajny
  70. + OS/2 demos added
  71. }