sw.pas 28 KB

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