basicpm.pas 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. {$APPTYPE GUI}
  14. uses
  15. Os2Def, PMWin;
  16. function ClientWindowProc (Window, Msg: cardinal; MP1, MP2: pointer): pointer;
  17. cdecl; export;
  18. var
  19. Li: longint;
  20. Ps: cardinal;
  21. R: TRectL;
  22. P: TPointL;
  23. Rgn: cardinal;
  24. begin
  25. ClientWindowProc := nil;
  26. case Msg of
  27. wm_Paint: begin
  28. PS := WinBeginPaint (Window, 0, @R);
  29. WinFillRect (PS, @R, SYSCLR_WINDOW);
  30. WinEndPaint (PS);
  31. end;
  32. else ClientWindowProc := WinDefWindowProc (Window, Msg, MP1, MP2);
  33. end;
  34. end;
  35. const
  36. idClientWindow = 11000;
  37. WinFlags: cardinal = fcf_TitleBar + fcf_SysMenu + fcf_SizeBorder +
  38. fcf_MinMax + fcf_TaskList + fcf_NoByteAlign;
  39. ClassName = 'MYVIEW';
  40. var
  41. Anchor, MsgQue: cardinal;
  42. Message: TQMsg;
  43. Frame, Client: cardinal;
  44. begin
  45. Anchor := WinInitialize(0);
  46. { It might be beneficial to set the second parameter of the following }
  47. { call to something large, such as 1000. The OS/2 documentation does }
  48. { not recommend this, however } MsgQue := WinCreateMsgQueue (Anchor, 0);
  49. if MsgQue = 0 then Halt (254);
  50. WinMessageBox (HWND_DESKTOP, HWND_DESKTOP, 'FPC test', 'Basic PM', 0,
  51. MB_OK or MB_INFORMATION);
  52. WinRegisterClass (Anchor, ClassName, proc (@ClientWindowProc), cs_SizeRedraw,
  53. SizeOf (pointer));
  54. Frame := WinCreateStdWindow (hwnd_Desktop, 0, WinFlags, ClassName,
  55. 'BASIC PM', 0, 0, idClientWindow, Client);
  56. if (Frame <> 0) then
  57. begin
  58. WinSetWindowPos (Frame, 0, 0, WinQuerySysValue (hwnd_Desktop,
  59. sv_CyScreen) - 200, 200, 200, swp_Move + swp_Size + swp_Activate +
  60. swp_Show);
  61. while WinGetMsg (Anchor, Message, 0, 0, 0) do
  62. WinDispatchMsg (Anchor, Message);
  63. WinDestroyWindow (Frame);
  64. end;
  65. WinDestroyMsgQueue (MsgQue);
  66. WinTerminate (Anchor);
  67. end.
  68. {
  69. $Log$
  70. Revision 1.2 2002-09-07 15:06:35 peter
  71. * old logs removed and tabs fixed
  72. }