sw.pas 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. {
  2. Copyright (c) 1990-1991 International Business Machines Corporation
  3. Copyright (c) 2003 by Yuri Prokushev ([email protected])
  4. This is the multimedia unit file that has the typedefs, defines and
  5. function prototypes for Multimedia Applets.
  6. This program is free software; you can redistribute it and/or modify it
  7. under the terms of the GNU Library General Public License (LGPL) as
  8. published by the Free Software Foundation; either version 2 of the
  9. License, or (at your option) any later version. This program is
  10. distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. FITNESS FOR A PARTICULAR PURPOSE.
  13. See the GNU Library General Public License for more details. You should
  14. have received a copy of the GNU Library General Public License along
  15. with this program; if not, write to the Free Software Foundation, Inc.,
  16. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. **********************************************************************}
  18. {
  19. @abstract(OS/2 Multimedia Applets)
  20. @author(Yuri Prokushev ([email protected]))
  21. @created(19 Jan 2003)
  22. @lastmod(23 Jan 2003)
  23. This is the multimedia unit file that has the typedefs, defines and
  24. function prototypes for Multimedia Applets.
  25. Warning: This code is alfa. Future versions of this unit will propably
  26. not be compatible.
  27. }
  28. {$IFNDEF FPC_DOTTEDUNITS}
  29. Unit SW;
  30. {$ENDIF FPC_DOTTEDUNITS}
  31. Interface
  32. {$IFDEF FPC_DOTTEDUNITS}
  33. Uses
  34. OS2Api.os2def,
  35. OS2Api.pmwin;
  36. {$ELSE FPC_DOTTEDUNITS}
  37. Uses
  38. Os2Def,
  39. PmWin;
  40. {$ENDIF FPC_DOTTEDUNITS}
  41. Const
  42. MAX_SMBDTEXT=35;
  43. MB_ICONCUSTOM=$0001;
  44. SC_DEFAULTSIZE=$c000; // WM_COMMAND from SysMenu
  45. WM_INITSECONDARYWINDOW=$0519; // MP1: NULL, MP2: CreateParams
  46. QS_FRAME=$1; // Flag set to query frame
  47. QS_DIALOG=$2; // Flag set to query dialog
  48. // #pragma pack(4)
  49. Type
  50. TSMBD=record
  51. achText: Array[0..MAX_SMBDTEXT + 1] of AnsiChar; // Text of the button. eg. "~Cancel"
  52. idButton: Cardinal; // Button ID returned when user chooses
  53. flStyle: Longint; // Button style or'ed with internal
  54. end;
  55. PSMBD=^TSMBD;
  56. TSMBINFO=record
  57. hIcon: Cardinal; // Icon handle
  58. cButtons: Cardinal; // Number of buttons
  59. flStyle: Cardinal; // Icon style flags (MB_ICONQUESTION, etc...)
  60. hwndNotify: HWND; // Reserved
  61. smbd: PSMBD; // Array of button definitions
  62. end;
  63. PSMBINFO=^TSMBINFO;
  64. // #pragma pack()
  65. // Analogous to WinDlgBox
  66. function WinSecondaryWindow(hwndParent: hwnd; hwndOwner: hwnd;
  67. pfnDlgProc: proc; hmod: Cardinal; idDlg: Cardinal; pCreateParams: Pointer): Cardinal; cdecl;
  68. // Analogous to WinLoadDlg
  69. function WinLoadSecondaryWindow(hwndParent: hwnd; hwndOwner: hwnd;
  70. pfnDlgProc: proc; hmod: Cardinal; idDlg: Cardinal; pCreateParams: Cardinal): hwnd; cdecl;
  71. // Analogous to WinProcessDlg
  72. function WinProcessSecondaryWindow(hwndSW: hwnd): Cardinal; cdecl;
  73. // Analogous to WinCreateDlg
  74. function WinCreateSecondaryWindow(hwndParent: hwnd; hwndOwner: hwnd;
  75. pfnDlgProc: proc; idDlg: Cardinal; pCreateParams: Pointer): hwnd; cdecl;
  76. function WinDefaultSize(Wnd: hwnd): Longbool; cdecl;
  77. function WinInsertDefaultSize(Wnd: hwnd; pszDefaultSize: PAnsiChar): Longbool; cdecl;
  78. function WinQuerySecondaryhwnd(Wnd: hwnd; ulFlag: Cardinal): hwnd; cdecl;
  79. //************************************************************************/
  80. //* WinSecondaryMessageBox */
  81. //* */
  82. //* Parameters: HWND hwndParent - handle of the parent window. */
  83. //* HWND hwndOwner - handle of the owner window. */
  84. //* PSZ pszText - message text. */
  85. //* PSZ pszCaption - title of the message box. */
  86. //* ULONG idWindow - Message box id */
  87. //* PSMBINFO psmbinfo - pointer to button/icon info */
  88. //************************************************************************/
  89. function WinSecondaryMessageBox(hwndParent: hwnd; hwndOwner: hwnd;
  90. pszText: PAnsiChar; pszCaption: PAnsiChar; idWindow: Cardinal; smb: psmbinfo): Cardinal; cdecl;
  91. //************************************************************************/
  92. //* WinDismissSecondaryWindow */
  93. //* */
  94. //* This function should be called from within the dlg proc. The hwnd */
  95. //* passed in MUST be the handle to the actual dialog. */
  96. //************************************************************************/
  97. function WinDismissSecondaryWindow(hwndDlg: hwnd; ulResult: Cardinal): Longbool; cdecl;
  98. //************************************************************************/
  99. //* The parameter hwnd can be either the secondary window or the actual */
  100. //* dialog. */
  101. //************************************************************************/
  102. function WinDestroySecondaryWindow(Wnd: hwnd): Longbool; cdecl;
  103. function WinDefSecondaryWindowProc(Wnd: hwnd; msg: Cardinal;
  104. mp1: mParam; mp2: mParam): mResult; cdecl;
  105. //************************************************************************/
  106. //* Graphic Buttons */
  107. //************************************************************************/
  108. //************************************************************************/
  109. //* Notes on Using GraphicButtons */
  110. //* */
  111. //* GraphicButton CONTROL DATA */
  112. //* */
  113. //* The format of the control data for GraphicButtons is */
  114. //* "button Text, number of bitmaps, bitmap resource id's ..." */
  115. //* */
  116. //* */
  117. //* Following are two example window templates of GraphicButtons: */
  118. //* */
  119. //* 1) CONTROL "", IDD_MP_REV, 120, 10, TS_PB_WIDTH, TS_PB_HEIGHT,*/
  120. //* WC_GRAPHICBUTTON, */
  121. //* GBS_TWOSTATE | GBS_HILITEBITMAP | */
  122. //* WS_VISIBLE | WS_TABSTOP */
  123. //* CTLDATA GB_RESOURCE,"~REV", 2, ID_MP_REV1, ID_MP_REV0*/
  124. //* */
  125. //* The above graphicbutton has id IDD_MP_REV and is of type */
  126. //* GBS_TWOSTATE and GBS_HILITEBITMAP. The GBS_HILITEBITMAP allows */
  127. //* a different bitmap to be displayed when the button is in the */
  128. //* hilite state. The graphicbutton will be displayed with text */
  129. //* "REV" and has "R" as the mnemonic. It has 2 bitmaps associated */
  130. //* with it. Their resource id are ID_MP_REV1 and ID_MP_REV0. */
  131. //* */
  132. //* */
  133. //* 2) CONTROL "", IDD_MP_PLAY, 175, 10, TS_PB_WIDTH, */
  134. //* TS_PB_HEIGHT, WC_GRAPHICBUTTON, */
  135. //* GBS_AUTOTWOSTATE | GBS_AUTOANIMATION | */
  136. //* WS_VISIBLE | WS_TABSTOP */
  137. //* CTLDATA GB_RESOURCE, "~PLAY", 9, */
  138. //* ID_MP_STOP0, ID_MP_PLAY1, ID_MP_PLAY2,*/
  139. //* ID_MP_PLAY3, ID_MP_PLAY4, ID_MP_PLAY5,*/
  140. //* ID_MP_PLAY6, ID_MP_PLAY7, ID_MP_REV1 */
  141. //* */
  142. //* The above graphicbutton has id IDD_MP_PLAY and is of type */
  143. //* GBS_AUTOTWOSTATE and GBS_AUTOANIMATE. When clicked upon, */
  144. //* the button will automatically toggle the state and animation. */
  145. //* The graphicbutton will be displayed with text "PLAY" */
  146. //* and mnemonic "P". It has 9 bitmaps associated with it. */
  147. //* */
  148. //* */
  149. //* */
  150. //* GraphicButton Painting */
  151. //* */
  152. //* Due to the PM design, whenever a graphicbutton is clicked, */
  153. //* it is sent a BN_PAINT (to paint a non-hilite state) and then */
  154. //* BN_CLICKED. Thus, for GBS_AUTO* style graphicbuttons, a paint */
  155. //* request is generated before the button has a chance to change */
  156. //* its state (BN_CLICKED). To avoid this premature painting, */
  157. //* code was inserted to delay the painting of graphicbuttons */
  158. //* GB_PAINT_RESOLUTION milliseconds whenever the button is switching */
  159. //* FROM the hilite paint state. */
  160. //* */
  161. //************************************************************************/
  162. Function WinRegisterGraphicButton: Longbool; cdecl;
  163. Const
  164. WC_GRAPHICBUTTON=PAnsiChar($ffff0040);
  165. //************************************************************************/
  166. //* GraphicButton Animation/TwoState constants */
  167. //************************************************************************/
  168. //************************************************************************/
  169. //* Graphic Button Style bits */
  170. //************************************************************************/
  171. GBS_TWOSTATE = $1000; // indicates TwoState button
  172. GBS_AUTOTWOSTATE = $2000; // will auto toggle state up/down
  173. GBS_ANIMATION = $4000; // indicates Animatable button
  174. GBS_AUTOANIMATION = $8000; // will auto toggle anim. on/off
  175. GBS_DISABLEBITMAP = $0010; // allows a diff. bitmap when disabled
  176. GBS_HILITEBITMAP = $0020; // allows a diff. bitmap when hilited
  177. GBS_3D_TEXTRECESSED = $0040; // display text in 3-D recessed
  178. GBS_3D_TEXTRAISED = $0080; // display text in 3-D raised
  179. GBS_MINIBUTTON = $0001; // mini button style
  180. //************************************************************************/
  181. //* Graphic Button User Constants */
  182. //************************************************************************/
  183. //************************************************************************/
  184. //* Codes to reference allowed GraphicButton states (or paint states) */
  185. //************************************************************************/
  186. GB_ERROR = -1; // GraphicButton Error
  187. GB_UP = 1; // GraphicButton up (and paint) state
  188. GB_DOWN = 2; // GraphicButton down (and paint) state
  189. GB_DISABLE = 3; // GraphicButton disabled state
  190. GB_HILITE = 4; // GraphicButton paint state only
  191. GB_OUTOFHILITE = 5; // Changing out of hilite paint state
  192. //************************************************************************/
  193. //* Codes for various GraphicButton message function parameters */
  194. //************************************************************************/
  195. GB_TOGGLE = 10; // GraphicButton toggle
  196. GB_CURRENTSTATE = 11; // GraphicButton's current state
  197. GB_ANIMATIONBEGIN = 12; // when refering to index of anim start
  198. GB_ANIMATIONEND = 13; // when refering to index of anim end
  199. GB_MAXINDEX = 14; // GraphicButton max. index
  200. //************************************************************************/
  201. //* Codes to set/query text position relative to the bitmap */
  202. //************************************************************************/
  203. GB_TEXTBELOW = 1; // place text below bitmap
  204. GB_TEXTABOVE = 2; // place text above bitmap
  205. //************************************************************************/
  206. //* Codes used to set the animation frame with message GBM_SETBITMAPINDEX*/
  207. //************************************************************************/
  208. GB_INDEX_FORWARD = -1; // advance one frame foward
  209. GB_INDEX_BACKWARD = -2; // advance one frame backwards
  210. GB_INDEX_FIRST = -3; // set to first frame of sequence
  211. GB_INDEX_LAST = -4; // set to last frame of sequence
  212. // #pragma pack(1)
  213. type
  214. TgbtnCdata = packed record
  215. usReserved: Word;
  216. pszText: PAnsiChar;
  217. hmod: Cardinal;
  218. cBitmaps: Word;
  219. aidBitmap: Array[0..1] of Word;
  220. end;
  221. pgbtnCdata = ^TgbtnCdata;
  222. //#pragma pack()
  223. const
  224. GB_RESOURCE = 1;
  225. GB_STRUCTURE = 0;
  226. //************************************************************************/
  227. //* Notification Messages received by GraphicButton Parent */
  228. //***********************************************************************/
  229. //************************************************************************/
  230. //* GBN_BUTTONDOWN, GBN_BUTTONUP, and GBN_BUTTONHILITE */
  231. //* */
  232. //* The notification messages are passed as part of the WM_CONTROL */
  233. //* message. */
  234. //* */
  235. //* msg = WM_CONTROL */
  236. //* mp1 = MPFROM2SHORT(gpb_id, button_state) */
  237. //* gpd_id = identity of the displayed graphic pushbutton */
  238. //* button_state = GBN_BUTTONUP, GBN_BUTTONDOWN, or */
  239. //* GBN_BUTTONHILITE */
  240. //* */
  241. //************************************************************************/
  242. GBN_BUTTONUP = $0524;
  243. GBN_BUTTONDOWN = $0525;
  244. GBN_BUTTONHILITE = $0526;
  245. GBN_SETFOCUS = $0527; // mp2 TRUE for gaining focus
  246. //************************************************************************/
  247. //* Messages to GraphicButton Windows */
  248. //************************************************************************/
  249. //************************************************************************/
  250. //* GBM_SETGRAPHICDATA */
  251. //************************************************************************/
  252. //* mp1 = MPFROMP((PGBTNCDATA)&gbtncdata); Graphic button control data*/
  253. //* mp2 = NULL; not used */
  254. //* */
  255. //* WARNING: This message resets all button parameters. */
  256. //* */
  257. //************************************************************************/
  258. GBM_SETGRAPHICDATA = $052A;
  259. //************************************************************************/
  260. //* GBM_ANIMATE */
  261. //************************************************************************/
  262. //* mp1 = MPFROMSHORT(fStart) TRUE to start animation, FALSE to stop*/
  263. //* mp2 = MPFROMSHORT(fContinue) TRUE continue anim. at currently */
  264. //* displayed bitmap, FALSE restart at */
  265. //* the beginning. */
  266. //* */
  267. //* Returns TRUE on Success */
  268. //* FALSE on Failure */
  269. //* */
  270. //************************************************************************/
  271. GBM_ANIMATE = $052B;
  272. //************************************************************************/
  273. //* GBM_SETANIMATIONRATE */
  274. //************************************************************************/
  275. //* mp1 = MPFROMSHORT(ULmIL); Animation rate in milliseconds */
  276. //* mp2 = NULL not used */
  277. //* */
  278. //* */
  279. //* Returns TRUE on Success */
  280. //* FALSE on Failure */
  281. //* */
  282. //************************************************************************/
  283. GBM_SETANIMATIONRATE = $052C;
  284. //************************************************************************/
  285. //* GBM_QUERYANIMATIONACTIVE */
  286. //************************************************************************/
  287. //* mp1 = NULL; not used */
  288. //* mp2 = NULL; not used */
  289. //* */
  290. //* */
  291. //* Returns TRUE if animation is active, else GB_ERROR */
  292. //* */
  293. //* */
  294. //************************************************************************/
  295. GBM_QUERYANIMATIONACTIVE = $052D;
  296. //************************************************************************/
  297. //* GBM_QUERYANIMATIONRATE */
  298. //************************************************************************/
  299. //* mp1 = NULL; not used */
  300. //* mp2 = NULL; not used */
  301. //* */
  302. //* */
  303. //* Returns ULONG sepcifying animation rate in milliseconds */
  304. //* */
  305. //* */
  306. //************************************************************************/
  307. GBM_QUERYANIMATIONRATE = $052E;
  308. //************************************************************************/
  309. //* GBM_SETBITMAPINDEX */
  310. //************************************************************************/
  311. //* mp1 = MPFROMSHORT(usGB_State) Bitmap index to change */
  312. //* GB_UP, */
  313. //* GB_DOWN, */
  314. //* GB_DISABLE, */
  315. //* GB_HILITE, */
  316. //* GB_ANIMATIONBEGIN, */
  317. //* GB_ANIMATIONEND, */
  318. //* or GB_CURRENTSTATE chng current state (up or down) bitmap*/
  319. //* mp2 = MPFROMSHORT(sFrameCode) Set according to code or frame desire */
  320. //* GB_INDEX_FORWARD, chng to next bitmap in circular array */
  321. //* GB_INDEX_BACKWARD, " " prev " " " " */
  322. //* GB_INDEX_FIRST, " " first " " " " */
  323. //* GB_INDEX_LAST, " " last " " " " */
  324. //* or desired_bitmap otherwise desired bmp index specified */
  325. //* */
  326. //* Returns TRUE on Success, otherwise FALSE */
  327. //* */
  328. //************************************************************************/
  329. GBM_SETBITMAPINDEX = $052F;
  330. //************************************************************************/
  331. //* GBM_QUERYBITMAPINDEX */
  332. //************************************************************************/
  333. //* mp1 = MPFROMSHORT(usGB_State) Query bitmap index */
  334. //* GB_UP, */
  335. //* GB_DOWN, */
  336. //* GB_DISABLE, */
  337. //* GB_HILITE, */
  338. //* GB_ANIMATIONBEGIN, */
  339. //* GB_ANIMATIONEND, */
  340. //* or GB_CURRENTSTATE query current state (up or down) bitmap */
  341. //* mp2 = NULL; not used */
  342. //* */
  343. //* Returns USHORT specifying the index */
  344. //* */
  345. //* */
  346. //************************************************************************/
  347. GBM_QUERYBITMAPINDEX = $0530;
  348. //************************************************************************/
  349. //* GBM_SETSTATE */
  350. //************************************************************************/
  351. //* mp1 = MPFROMSHORT(usStateCode) Set twostate button to specified */
  352. //* state */
  353. //* GB_UP, */
  354. //* GB_DOWN, */
  355. //* or GB_TOGGLE toggle (up/down) to (down/up) */
  356. //* mp2 = MPFROMBOOL(fRepaint) TRUE - state changed and displayed */
  357. //* FALSE - state changed, not displayed */
  358. //* */
  359. //* Returns TRUE on Success */
  360. //* FALSE on Failure */
  361. //* */
  362. //* */
  363. //************************************************************************/
  364. GBM_SETSTATE = $0531;
  365. //************************************************************************/
  366. //* GBM_QUERYSTATE */
  367. //************************************************************************/
  368. //* */
  369. //* mp1 = NULL not used */
  370. //* mp2 = NULL not used */
  371. //* */
  372. //* Returns the state (GB_UP or GB_DOWN) else GB_ERROR. */
  373. //* */
  374. //* */
  375. //************************************************************************/
  376. GBM_QUERYSTATE = $0532;
  377. //************************************************************************/
  378. //* GBM_SETTEXTPOSITION */
  379. //************************************************************************/
  380. //* mp1 = MPFROMSHORT(usTextPos) How to position text relative to */
  381. //* bitmap */
  382. //* GB_TEXTBELOW, */
  383. //* or GB_TEXTABOVE */
  384. //* mp2 = NULL not used */
  385. //* */
  386. //* Returns TRUE on Success, otherwise FALSE */
  387. //* */
  388. //************************************************************************/
  389. GBM_SETTEXTPOSITION = $0533;
  390. //************************************************************************/
  391. //* GBM_QUERYTEXTPOSITION */
  392. //************************************************************************/
  393. //* */
  394. //* mp1 = NULL not used */
  395. //* mp2 = NULL not used */
  396. //* */
  397. //* Returns GB_TEXTBELOW, GB_TEXTABOVE, GB_TEXTRIGHT, GB_TEXTLEFT */
  398. //* on success, otherwise FALSE */
  399. //* */
  400. //************************************************************************/
  401. GBM_QUERYTEXTPOSITION = $0534;
  402. //************************************************************************/
  403. //* GraphicButton END */
  404. //************************************************************************/
  405. MM_TABHELP = $054C;
  406. Implementation
  407. function WinSecondaryWindow(hwndParent: hwnd; hwndOwner: hwnd;
  408. pfnDlgProc: proc; hmod: Cardinal; idDlg: Cardinal; pCreateParams: Pointer): Cardinal; cdecl;
  409. external 'SW' index 1;
  410. function WinLoadSecondaryWindow(hwndParent: hwnd; hwndOwner: hwnd;
  411. pfnDlgProc: proc; hmod: Cardinal; idDlg: Cardinal; pCreateParams: Cardinal): hwnd; cdecl;
  412. external 'SW' index 2;
  413. function WinProcessSecondaryWindow(hwndSW: hwnd): Cardinal; cdecl;
  414. external 'SW' index 3;
  415. function WinCreateSecondaryWindow(hwndParent: hwnd; hwndOwner: hwnd;
  416. pfnDlgProc: proc; idDlg: Cardinal; pCreateParams: Pointer): hwnd; cdecl;
  417. external 'SW' index 4;
  418. function WinDefaultSize(Wnd: hwnd): Longbool; cdecl;
  419. external 'SW' index 11;
  420. function WinInsertDefaultSize(Wnd: hwnd; pszDefaultSize: PAnsiChar): Longbool; cdecl;
  421. external 'SW' index 12;
  422. function WinQuerySecondaryhwnd(Wnd: hwnd; ulFlag: Cardinal): hwnd; cdecl;
  423. external 'SW' index 52;
  424. function WinSecondaryMessageBox(hwndParent: hwnd; hwndOwner: hwnd;
  425. pszText: PAnsiChar; pszCaption: PAnsiChar; idWindow: Cardinal; smb: psmbinfo): Cardinal; cdecl;
  426. external 'SW' index 5;
  427. function WinDismissSecondaryWindow(hwndDlg: hwnd; ulResult: Cardinal): Longbool; cdecl;
  428. external 'SW' index 6;
  429. function WinDestroySecondaryWindow(Wnd: hwnd): Longbool; cdecl;
  430. external 'SW' index 7;
  431. function WinDefSecondaryWindowProc(Wnd: hwnd; msg: Cardinal;
  432. mp1: mParam; mp2: mParam): mResult; cdecl;
  433. external 'SW' index 8;
  434. Function WinRegisterGraphicButton: Longbool; cdecl;
  435. external 'SW' index 14;
  436. End.