source: trunk/include/helpers/winh.h@ 243

Last change on this file since 243 was 243, checked in by umoeller, 23 years ago

New build system, multimedia, other misc fixes.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 42.9 KB
Line 
1
2/*
3 *@@sourcefile winh.h:
4 * header file for winh.c (PM helper funcs). See remarks there.
5 *
6 * Special #define's which this thing reacts to:
7 *
8 * -- If WINH_STANDARDWRAPPERS is defined to anything, this include
9 * file maps a number of freqently API calls (such as WinSendMsg)
10 * to winh* equivalents to reduce the amount of fixup records
11 * in the final executable.
12 *
13 * Note: Version numbering in this file relates to XWorkplace version
14 * numbering.
15 */
16
17/* Copyright (C) 1997-2000 Ulrich M”ller.
18 * This file is part of the "XWorkplace helpers" source package.
19 * This is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published
21 * by the Free Software Foundation, in version 2 as it comes in the
22 * "COPYING" file of the XWorkplace main distribution.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 *@@include #define INCL_WINWINDOWMGR
29 *@@include #define INCL_WINMESSAGEMGR
30 *@@include #define INCL_WINSYS // for winhStorePresParam
31 *@@include #define INCL_WINDIALOGS
32 *@@include #define INCL_WINMENUS // for menu helpers
33 *@@include #define INCL_WINENTRYFIELDS // for entry field helpers
34 *@@include #define INCL_WINBUTTONS // for button/check box helpers
35 *@@include #define INCL_WINLISTBOXES // for list box helpers
36 *@@include #define INCL_WINSTDSPIN // for spin button helpers
37 *@@include #define INCL_WINSTDSLIDER // for slider helpers
38 *@@include #define INCL_WININPUT
39 *@@include #define INCL_WINSYS
40 *@@include #define INCL_WINSHELLDATA
41 *@@include #define INCL_WINSWITCHLIST // for winhQuerySwitchList
42 *@@include #define INCL_WINPROGRAMLIST // for appStartApp
43 *@@include #define INCL_WINHELP // for help manager helpers
44 *@@include #include <os2.h>
45 *@@include #include "helpers\winh.h"
46 */
47
48#if __cplusplus
49extern "C" {
50#endif
51
52#ifndef WINH_HEADER_INCLUDED
53 #define WINH_HEADER_INCLUDED
54
55 #ifndef XWPENTRY
56 #error You must define XWPENTRY to contain the standard linkage for the XWPHelpers.
57 #endif
58
59 /* ******************************************************************
60 *
61 * Declarations
62 *
63 ********************************************************************/
64
65 #define MPNULL (MPFROMP(NULL))
66 #define MPZERO (MPFROMSHORT(0))
67 #define MRTRUE (MRFROMSHORT((SHORT) TRUE))
68 #define MRFALSE (MRFROMSHORT((SHORT) FALSE))
69 #define BM_UNCHECKED 0 // for checkboxes: disabled
70 #define BM_CHECKED 1 // for checkboses: enabled
71 #define BM_INDETERMINATE 2 // for tri-state checkboxes: indeterminate
72
73 // these undocumented msgs are posted whenever the mouse
74 // enters or leaves a window V1.0.1 (2002-11-30) [umoeller]
75 #ifndef WM_MOUSEENTER
76 #define WM_MOUSEENTER 0x041E
77 #define WM_MOUSELEAVE 0x041F
78 #endif
79
80 /* ******************************************************************
81 *
82 * Wrappers
83 *
84 ********************************************************************/
85
86 // if WINH_STANDARDWRAPPERS is #define'd before including winh.h,
87 // all the following Win* API calls are redirected to the winh*
88 // counterparts
89
90 #ifdef WINH_STANDARDWRAPPERS
91
92 MRESULT XWPENTRY winhSendMsg(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
93 #define WinSendMsg(a,b,c,d) winhSendMsg((a),(b),(c),(d))
94
95 MRESULT XWPENTRY winhSendDlgItemMsg(HWND hwnd, ULONG id, ULONG msg, MPARAM mp1, MPARAM mp2);
96 #define WinSendDlgItemMsg(a,b,c,d,e) winhSendDlgItemMsg((a),(b),(c),(d),(e))
97
98 BOOL XWPENTRY winhPostMsg(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
99 #define WinPostMsg(a,b,c,d) winhPostMsg((a),(b),(c),(d))
100
101 HWND XWPENTRY winhWindowFromID(HWND hwnd, ULONG id);
102 #define WinWindowFromID(a,b) winhWindowFromID((a),(b))
103
104 HWND XWPENTRY winhQueryWindow(HWND hwnd, LONG lCode);
105 #define WinQueryWindow(a,b) winhQueryWindow((a),(b))
106
107 PVOID XWPENTRY winhQueryWindowPtr(HWND hwnd, LONG index);
108 #define WinQueryWindowPtr(a,b) winhQueryWindowPtr((a),(b))
109
110 BOOL XWPENTRY winhSetWindowText2(HWND hwnd, const char *pcsz);
111 #define WinSetWindowText(a,b) winhSetWindowText2((a),(b))
112
113 BOOL XWPENTRY winhSetDlgItemText(HWND hwnd, ULONG id, const char *pcsz);
114 #define WinSetDlgItemText(a,b,c) winhSetDlgItemText((a),(b),(c))
115
116 // pmwin.h defines the WinEnableControl macro; turn this into our function call
117 #ifdef WinEnableControl
118 #undef WinEnableControl
119 #endif
120 #define WinEnableControl(hwndDlg, id, fEnable) winhEnableDlgItem((hwndDlg), (id), (fEnable))
121
122 #ifdef INCL_WINMESSAGEMGR
123 APIRET XWPENTRY winhRequestMutexSem(HMTX hmtx, ULONG ulTimeout);
124 #define WinRequestMutexSem(a, b) winhRequestMutexSem((a), (b))
125 #endif
126 #endif
127
128 /* ******************************************************************
129 *
130 * Macros
131 *
132 ********************************************************************/
133
134 /*
135 * Here come some monster macros for
136 * frequently needed functions.
137 */
138
139 #define winhDebugBox(hwndOwner, title, text) \
140 WinMessageBox(HWND_DESKTOP, hwndOwner, ((PSZ)text), ((PSZ)title), 0, MB_OK | MB_ICONEXCLAMATION | MB_MOVEABLE)
141
142 #define winhYesNoBox(title, text) \
143 WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, ((PSZ)text), ((PSZ)title), 0, MB_YESNO | MB_ICONQUESTION | MB_MOVEABLE)
144
145 #define winhSetDlgItemChecked(hwnd, id, bCheck) \
146 WinSendDlgItemMsg((hwnd), (id), BM_SETCHECK, MPFROMSHORT(bCheck), MPNULL)
147 #define winhIsDlgItemChecked(hwnd, id) \
148 (SHORT1FROMMR(WinSendDlgItemMsg((hwnd), (id), BM_QUERYCHECK, MPNULL, MPNULL)))
149
150 #define winhSetMenuItemChecked(hwndMenu, usId, bCheck) \
151 WinSendMsg(hwndMenu, MM_SETITEMATTR, MPFROM2SHORT(usId, TRUE), \
152 MPFROM2SHORT(MIA_CHECKED, (((bCheck)) ? MIA_CHECKED : FALSE)))
153
154 #define winhShowDlgItem(hwnd, id, show) \
155 WinShowWindow(WinWindowFromID(hwnd, id), show)
156
157 // made these functions V0.9.12 (2001-05-18) [umoeller]
158 /* #define winhEnableDlgItem(hwndDlg, ulId, Enable) \
159 WinEnableWindow(WinWindowFromID(hwndDlg, ulId), Enable)
160 #define winhIsDlgItemEnabled(hwndDlg, ulId) \
161 WinIsWindowEnabled(WinWindowFromID(hwndDlg, ulId))
162 */
163
164 #define winhSetDlgItemFocus(hwndDlg, ulId) \
165 WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwndDlg, ulId))
166
167 /* ******************************************************************
168 *
169 * Rectangle helpers
170 *
171 ********************************************************************/
172
173 VOID XWPENTRY winhOffsetRect(PRECTL prcl, LONG lx, LONG ly);
174
175 /* ******************************************************************
176 *
177 * Generics
178 *
179 ********************************************************************/
180
181 extern LONG G_cxScreen,
182 G_cyScreen,
183 G_cxIcon,
184 G_cyIcon,
185 G_lcol3DDark,
186 G_lcol3DLight;
187
188 VOID XWPENTRY winhInitGlobals(VOID);
189
190 ULONG XWPENTRY winhQueryWindowStyle(HWND hwnd);
191
192 BOOL XWPENTRY winhEnableDlgItem(HWND hwndDlg, SHORT id, BOOL fEnable);
193
194 BOOL XWPENTRY winhIsDlgItemEnabled(HWND hwndDlg, SHORT id);
195
196 BOOL winhDestroyWindow(HWND *phwnd);
197
198 /* ******************************************************************
199 *
200 * Menu helpers
201 *
202 ********************************************************************/
203
204 // now including all this only with INCL_WINMENUS
205 // V1.0.1 (2002-11-30) [umoeller]
206 #ifdef INCL_WINMENUS
207
208 #ifndef MM_QUERYITEMBYPOS16
209 #define MM_QUERYITEMBYPOS16 0x01f3
210 // this undocumented message is sent to retrieve the definition
211 // of a menu item by its position. This message will only query
212 // an item in the specified menu.
213 //
214 // Parameters:
215 // SHORT1FROMMP(mp1) = position of item in the menu
216 // SHORT2FROMMP(mp1) = reserved, set to 0
217 // mp2 = (16 bit pointer) points to a MENUITEM structure
218 // to be filled in.
219 #endif
220 #ifndef MAKE_16BIT_POINTER
221 #define MAKE_16BIT_POINTER(p) \
222 ((PVOID)MAKEULONG(LOUSHORT(p),(HIUSHORT(p) << 3) | 7))
223 // converts a flat 32bit pointer to its 16bit offset/selector form
224 #endif
225
226 /*
227 * winhCreateEmptyMenu:
228 * this macro creates an empty menu, which can
229 * be used with winhInsertMenuItem etc. later.
230 * Useful for creating popup menus on the fly.
231 * Note that even though HWND_DESKTOP is specified
232 * here as both the parent and the owner, the
233 * actual owner and parent are specified later
234 * with WinPopupMenu.
235 */
236
237 #define winhCreateEmptyMenu() \
238 WinCreateWindow(HWND_DESKTOP, WC_MENU, "", 0, 0, 0, 0, 0, \
239 HWND_DESKTOP, HWND_TOP, 0, 0, 0)
240
241 BOOL XWPENTRY winhQueryMenuItem(HWND hwndMenu,
242 USHORT usItemID,
243 BOOL fSearchSubmenus,
244 PMENUITEM pmi);
245
246 HWND XWPENTRY winhQuerySubmenu(HWND hMenu, SHORT sID);
247
248 SHORT XWPENTRY winhInsertMenuItem(HWND hwndMenu,
249 SHORT iPosition,
250 SHORT sItemId,
251 const char *pcszItemTitle,
252 SHORT afStyle,
253 SHORT afAttr);
254 typedef SHORT XWPENTRY WINHINSERTMENUITEM(HWND hwndMenu,
255 SHORT iPosition,
256 SHORT sItemId,
257 const char *pcszItemTitle,
258 SHORT afStyle,
259 SHORT afAttr);
260 typedef WINHINSERTMENUITEM *PWINHINSERTMENUITEM;
261
262 HWND XWPENTRY winhInsertSubmenu(HWND hwndMenu,
263 ULONG iPosition,
264 SHORT sMenuId,
265 const char *pcszSubmenuTitle,
266 USHORT afMenuStyle,
267 SHORT sItemId,
268 const char *pcszItemTitle,
269 USHORT afItemStyle,
270 USHORT afAttribute);
271 typedef HWND XWPENTRY WINHINSERTSUBMENU(HWND hwndMenu,
272 ULONG iPosition,
273 SHORT sMenuId,
274 const char *pcszSubmenuTitle,
275 USHORT afMenuStyle,
276 SHORT sItemId,
277 const char *pcszItemTitle,
278 USHORT afItemStyle,
279 USHORT afAttribute);
280 typedef WINHINSERTSUBMENU *PWINHINSERTSUBMENU;
281
282 BOOL XWPENTRY winhSetMenuCondCascade(HWND hwndMenu,
283 LONG lDefaultItem);
284
285 /*
286 *@@ winhRemoveMenuItem:
287 * removes a menu item (SHORT) from the
288 * given menu (HWND). Returns the no. of
289 * remaining menu items (SHORT).
290 *
291 * This works for whole submenus too.
292 */
293
294 #define winhRemoveMenuItem(hwndMenu, sItemID) \
295 SHORT1FROMMR(WinSendMsg(hwndMenu, MM_REMOVEITEM, MPFROM2SHORT(sItemID, FALSE), 0))
296
297 BOOL XWPENTRY winhRemoveMenuItems(HWND hwndMenu,
298 const SHORT *asItemIDs,
299 ULONG cItemIDs);
300
301 /*
302 *@@ winhDeleteMenuItem:
303 * deleted a menu item (SHORT) from the
304 * given menu (HWND). Returns the no. of
305 * remaining menu items (SHORT).
306 *
307 * As opposed to MM_REMOVEITEM, MM_DELETEITEM
308 * frees submenus and bitmaps also.
309 *
310 * This works for whole submenus too.
311 */
312
313 #define winhDeleteMenuItem(hwndMenu, sItemId) \
314 (SHORT)WinSendMsg(hwndMenu, MM_DELETEITEM, MPFROM2SHORT(sItemId, FALSE), 0)
315
316 SHORT XWPENTRY winhInsertMenuSeparator(HWND hMenu,
317 SHORT iPosition,
318 SHORT sId);
319
320 #define COPYFL_STRIPTABS 0x0001
321
322 BOOL XWPENTRY winhCopyMenuItem2(HWND hmenuTarget,
323 HWND hmenuSource,
324 USHORT usID,
325 SHORT sTargetPosition,
326 ULONG fl);
327
328 BOOL XWPENTRY winhCopyMenuItem(HWND hmenuTarget,
329 HWND hmenuSource,
330 USHORT usID,
331 SHORT sTargetPosition);
332 typedef BOOL XWPENTRY WINHCOPYMENUITEM(HWND hmenuTarget,
333 HWND hmenuSource,
334 USHORT usID,
335 SHORT sTargetPosition);
336 typedef WINHCOPYMENUITEM *PWINHCOPYMENUITEM;
337
338 HWND XWPENTRY winhMergeIntoSubMenu(HWND hmenuTarget,
339 SHORT sTargetPosition,
340 const char *pcszTitle,
341 SHORT sID,
342 HWND hmenuSource);
343 typedef HWND XWPENTRY WINHMERGEINTOSUBMENU(HWND hmenuTarget,
344 SHORT sTargetPosition,
345 const char *pcszTitle,
346 SHORT sID,
347 HWND hmenuSource);
348 typedef WINHMERGEINTOSUBMENU *PWINHMERGEINTOSUBMENU;
349
350 ULONG XWPENTRY winhMergeMenus(HWND hmenuTarget,
351 SHORT sTargetPosition,
352 HWND hmenuSource,
353 ULONG fl);
354 typedef ULONG XWPENTRY WINHMERGEMENUS(HWND hmenuTarget,
355 SHORT sTargetPosition,
356 HWND hmenuSource,
357 ULONG fl);
358 typedef WINHMERGEMENUS *PWINHMERGEMENUS;
359
360 ULONG XWPENTRY winhClearMenu(HWND hwndMenu);
361
362 PSZ XWPENTRY winhQueryMenuItemText(HWND hwndMenu,
363 USHORT usItemID);
364
365 BOOL XWPENTRY winhAppend2MenuItemText(HWND hwndMenu,
366 USHORT usItemID,
367 const char *pcszAppend,
368 BOOL fTab);
369
370 VOID XWPENTRY winhMenuRemoveEllipse(HWND hwndMenu,
371 USHORT usItemId);
372
373 SHORT XWPENTRY winhQueryItemUnderMouse(HWND hwndMenu, POINTL *pptlMouse, RECTL *prtlItem);
374
375 #endif
376
377 /* ******************************************************************
378 *
379 * Slider helpers
380 *
381 ********************************************************************/
382
383 HWND XWPENTRY winhReplaceWithLinearSlider(HWND hwndParent,
384 HWND hwndOwner,
385 HWND hwndInsertAfter,
386 ULONG ulID,
387 ULONG ulSliderStyle,
388 ULONG ulTickCount);
389
390 BOOL XWPENTRY winhSetSliderTicks(HWND hwndSlider,
391 MPARAM mpEveryOther1,
392 ULONG ulPixels1,
393 MPARAM mpEveryOther2,
394 ULONG ulPixels2);
395 typedef BOOL XWPENTRY WINHSETSLIDERTICKS(HWND hwndSlider,
396 MPARAM mpEveryOther1,
397 ULONG ulPixels1,
398 MPARAM mpEveryOther2,
399 ULONG ulPixels2);
400 typedef WINHSETSLIDERTICKS *PWINHSETSLIDERTICKS;
401
402 /*
403 * winhSetSliderArmPosition:
404 * this moves the slider arm in a given
405 * linear slider.
406 *
407 * usMode can be one of the following:
408 * -- SMA_RANGEVALUE: usOffset is in pixels
409 * from the slider's home position.
410 * -- SMA_INCREMENTVALUE: usOffset is in
411 * units of the slider's primary scale.
412 */
413
414 #define winhSetSliderArmPosition(hwndSlider, usMode, usOffset) \
415 WinSendMsg(hwndSlider, SLM_SETSLIDERINFO, \
416 MPFROM2SHORT(SMA_SLIDERARMPOSITION, \
417 usMode), \
418 MPFROMSHORT(usOffset))
419
420 /*
421 * winhQuerySliderArmPosition:
422 * reverse to the previous, this returns a
423 * slider arm position (as a LONG value).
424 */
425
426 #define winhQuerySliderArmPosition(hwndSlider, usMode) \
427 (LONG)(WinSendMsg(hwndSlider, \
428 SLM_QUERYSLIDERINFO, \
429 MPFROM2SHORT(SMA_SLIDERARMPOSITION, \
430 usMode), \
431 0))
432
433 HWND XWPENTRY winhReplaceWithCircularSlider(HWND hwndParent,
434 HWND hwndOwner,
435 HWND hwndInsertAfter,
436 ULONG ulID,
437 ULONG ulSliderStyle,
438 SHORT sMin,
439 SHORT sMax,
440 USHORT usIncrement,
441 USHORT usTicksEvery);
442
443 /* ******************************************************************
444 *
445 * Spin button helpers
446 *
447 ********************************************************************/
448
449 VOID XWPENTRY winhSetDlgItemSpinData(HWND hwndDlg,
450 ULONG idSpinButton,
451 ULONG min,
452 ULONG max,
453 ULONG current);
454 typedef VOID XWPENTRY WINHSETDLGITEMSPINDATA(HWND hwndDlg,
455 ULONG idSpinButton,
456 ULONG min,
457 ULONG max,
458 ULONG current);
459 typedef WINHSETDLGITEMSPINDATA *PWINHSETDLGITEMSPINDATA;
460
461 LONG XWPENTRY winhAdjustDlgItemSpinData(HWND hwndDlg,
462 USHORT usItemID,
463 LONG lGrid,
464 USHORT usNotifyCode);
465 typedef LONG XWPENTRY WINHADJUSTDLGITEMSPINDATA(HWND hwndDlg,
466 USHORT usItemID,
467 LONG lGrid,
468 USHORT usNotifyCode);
469 typedef WINHADJUSTDLGITEMSPINDATA *PWINHADJUSTDLGITEMSPINDATA;
470
471 /* ******************************************************************
472 *
473 * Entry field helpers
474 *
475 ********************************************************************/
476
477 /*
478 * winhSetEntryFieldLimit:
479 * sets the maximum length for the entry field
480 * (EM_SETTEXTLIMIT message).
481 *
482 * PMREF doesn't say this, but the limit does
483 * _not_ include the null-terminator. That is,
484 * if you specify "12" characters here, you can
485 * really enter 12 characters.
486 *
487 * The default length is 30 characters, I think.
488 */
489
490 #define winhSetEntryFieldLimit(hwndEntryField, usLength) \
491 WinSendMsg(hwndEntryField, EM_SETTEXTLIMIT, (MPARAM)(usLength), (MPARAM)0)
492
493 /*
494 *@@ winhEntryFieldSelectAll:
495 * this selects the entire text in the entry field.
496 * Useful when the thing gets the focus.
497 */
498
499 #define winhEntryFieldSelectAll(hwndEntryField) \
500 WinSendMsg(hwndEntryField, EM_SETSEL, MPFROM2SHORT(0, 10000), MPNULL)
501
502 /*
503 *@@ winhHasEntryFieldChanged:
504 * this queries whether the entry field's contents
505 * have changed (EM_QUERYCHANGED message).
506 *
507 * This returns TRUE if changes have occured since
508 * the last time this message or WM_QUERYWINDOWPARAMS
509 * (WinQueryWindowText) was received.
510 */
511
512 #define winhHasEntryFieldChanged(hwndEntryField) \
513 (BOOL)WinSendMsg(hwndEntryField, EM_QUERYCHANGED, (MPARAM)0, (MPARAM)0)
514
515 /* ******************************************************************
516 *
517 * List box helpers
518 *
519 ********************************************************************/
520
521 /* The following macros are defined in the OS/2 headers for
522 list boxes:
523
524 LONG WinQueryLboxCount(HWND hwndLbox);
525 // wrapper around LM_QUERYITEMCOUNT;
526 // list box item count
527
528 SHORT WinQueryLboxItemTextLength(HWND hwndLbox,
529 SHORT index); // item index, starting from 0
530 // wrapper around LM_QUERYITEMTEXTLENGTH;
531 // returns length of item text, excluding NULL character
532
533 LONG WinQueryLboxItemText(HWND hwndLbox,
534 SHORT index, // item index, starting from 0
535 PSZ psz, // buffer
536 PSZ cchMax); // size of buffer, incl. null
537 // wrapper around LM_QUERYITEMTEXT;
538 // returns length of item text, excluding NULL character
539
540 BOOL WinSetLboxItemText(HWND hwndLbox,
541 LONG index,
542 PSZ psz);
543 // wrapper around LM_SETITEMTEXT
544
545 LONG WinInsertLboxItem(HWND hwndLbox,
546 LONG index, // new item index, starting from 0
547 // or LIT_END
548 // or LIT_SORTASCENDING
549 // or LIT_SORTDESCENDING
550 PSZ psz)
551 // wrapper around LM_INSERTITEM;
552 // returns LIT_MEMERROR, LIT_ERROR, or zero-based index
553
554 LONG WinDeleteLboxItem(HWND hwndLbox,
555 LONG index); // item index, starting from 0
556
557 LONG WinQueryLboxSelectedItem(HWND hwndLbox);
558 // wrapper around LM_QUERYSELECTION;
559 // works with single selection only,
560 // use winhQueryLboxSelectedItem instead
561 */
562
563 /*
564 * winhQueryLboxItemCount:
565 * returns the no. of items in the listbox
566 * as a SHORT.
567 *
568 *added V0.9.1 (99-12-14) [umoeller]
569 */
570
571 // #define winhQueryLboxItemCount(hwndListBox)
572 // (SHORT)WinSendMsg(hwndListBox, LM_QUERYITEMCOUNT, 0, 0)
573
574 // removed, use WinQueryLboxCount
575
576 /*
577 *@@ winhDeleteAllItems:
578 * deletes all list box items. Returns
579 * a BOOL.
580 *
581 *@@added V0.9.1 (99-12-14) [umoeller]
582 */
583
584 #define winhDeleteAllItems(hwndListBox) \
585 (BOOL)WinSendMsg(hwndListBox, \
586 LM_DELETEALL, 0, 0)
587 /*
588 *@@ winhQueryLboxSelectedItem:
589 * this queries the next selected list box item.
590 * For the first call, set sItemStart to LIT_FIRST;
591 * then repeat the call with sItemStart set to
592 * the previous return value until this returns
593 * LIT_NONE.
594 *
595 * Example:
596 + SHORT sItemStart = LIT_FIRST;
597 + while (TRUE)
598 + {
599 + sItemStart = winhQueryLboxSelectedItem(hwndListBox,
600 + sItemStart)
601 + if (sItemStart == LIT_NONE)
602 + break;
603 + ...
604 + }
605 *
606 * To have the cursored item returned, use LIT_CURSOR.
607 *
608 * For single selection, you can also use
609 * WinQueryLboxSelectedItem from the OS/2 PM headers.
610 */
611
612 #define winhQueryLboxSelectedItem(hwndListBox, sItemStart) \
613 SHORT1FROMMR(WinSendMsg(hwndListBox, \
614 LM_QUERYSELECTION, \
615 (MPARAM)(sItemStart), \
616 MPNULL))
617
618 /*
619 *@@ winhSetLboxSelectedItem:
620 * selects a list box item.
621 * This works for both single-selection and
622 * multiple-selection listboxes.
623 * In single-selection listboxes, if an item
624 * is selected (fSelect == TRUE), the previous
625 * item is automatically deselected.
626 * Note that (BOOL)fSelect is ignored if
627 * sItemIndex == LIT_NONE.
628 */
629
630 #define winhSetLboxSelectedItem(hwndListBox, sItemIndex, fSelect) \
631 (BOOL)(WinSendMsg(hwndListBox, \
632 LM_SELECTITEM, \
633 (MPARAM)(sItemIndex), \
634 (MPARAM)(fSelect)))
635
636 ULONG XWPENTRY winhLboxSelectAll(HWND hwndListBox, BOOL fSelect);
637
638 /*
639 * winhSetLboxItemHandle:
640 * sets the "item handle" for the specified sItemIndex.
641 * See LM_SETITEMHANDLE in PMREF for details.
642 */
643
644 #define winhSetLboxItemHandle(hwndListBox, sItemIndex, ulHandle) \
645 (BOOL)(WinSendMsg(hwndListBox, LM_SETITEMHANDLE, \
646 (MPARAM)(sItemIndex), \
647 (MPARAM)ulHandle))
648
649 /*
650 * winhQueryLboxItemHandle:
651 * the reverse to the previous. Returns a ULONG.
652 */
653
654 #define winhQueryLboxItemHandle(hwndListBox, sItemIndex) \
655 (ULONG)WinSendMsg(hwndListBox, LM_QUERYITEMHANDLE, \
656 MPFROMSHORT(sItemIndex), (MPARAM)NULL)
657
658 PSZ XWPENTRY winhQueryLboxItemText(HWND hwndListbox, SHORT sIndex);
659
660 BOOL XWPENTRY winhMoveLboxItem(HWND hwndSource,
661 SHORT sSourceIndex,
662 HWND hwndTarget,
663 SHORT sTargetIndex,
664 BOOL fSelectTarget);
665
666 ULONG XWPENTRY winhLboxFindItemFromHandle(HWND hwndListBox,
667 ULONG ulHandle);
668
669 /* ******************************************************************
670 *
671 * Scroll bar helpers
672 *
673 ********************************************************************/
674
675 BOOL XWPENTRY winhUpdateScrollBar(HWND hwndScrollBar,
676 ULONG ulWinPels,
677 ULONG ulViewportPels,
678 ULONG ulCurUnitOfs,
679 BOOL fAutoHide);
680
681 LONG XWPENTRY winhHandleScrollMsg(HWND hwndScrollBar,
682 PLONG plCurPelsOfs,
683 LONG lWindowPels,
684 LONG lWorkareaPels,
685 USHORT usLineStepPels,
686 ULONG msg,
687 MPARAM mp2);
688
689 BOOL XWPENTRY winhScrollWindow(HWND hwnd2Scroll,
690 PRECTL prclClip,
691 PPOINTL pptlScroll);
692
693 BOOL XWPENTRY winhProcessScrollChars(HWND hwndClient,
694 HWND hwndVScroll,
695 HWND hwndHScroll,
696 MPARAM mp1,
697 MPARAM mp2,
698 ULONG ulVertMax,
699 ULONG ulHorzMax);
700
701 /*
702 *@@ SCROLLABLEWINDOW:
703 * scroll data struct for use with winhHandleScrollerMsgs.
704 *
705 *@@added V1.0.1 (2003-01-25) [umoeller]
706 */
707
708 typedef struct _SCROLLABLEWINDOW
709 {
710 LONG cxScrollBar,
711 cyScrollBar;
712 HWND hwndVScroll, // vertical scroll bar
713 hwndHScroll; // horizontal scroll bar
714 ULONG idVScroll,
715 idHScroll;
716 SIZEL szlWorkarea; // workarea dimensions (over which window scrolls)
717 POINTL ptlScrollOfs; // current scroll offset; positive x means right,
718 // positive y means down
719 } SCROLLABLEWINDOW, *PSCROLLABLEWINDOW;
720
721 #define ID_VSCROLL 100
722 #define ID_HSCROLL 101
723
724 BOOL XWPENTRY winhCreateScroller(HWND hwndParent,
725 PSCROLLABLEWINDOW pscrw,
726 ULONG idVScroll,
727 ULONG idHScroll);
728
729 MRESULT XWPENTRY winhHandleScrollerMsgs(HWND hwnd2Scroll,
730 PSCROLLABLEWINDOW pscrw,
731 PSIZEL pszlWin,
732 ULONG msg,
733 MPARAM mp1,
734 MPARAM mp2);
735
736 /* ******************************************************************
737 *
738 * Window positioning helpers
739 *
740 ********************************************************************/
741
742 BOOL XWPENTRY winhSaveWindowPos(HWND hwnd, HINI hIni, const char *pcszApp, const char *pcszKey);
743
744 BOOL XWPENTRY winhRestoreWindowPos(HWND hwnd, HINI hIni, const char *pcszApp, const char *pcszKey, ULONG fl);
745
746 #define XAC_MOVEX 0x0001
747 #define XAC_MOVEY 0x0002
748 #define XAC_SIZEX 0x0004
749 #define XAC_SIZEY 0x0008
750
751 /*
752 *@@ XADJUSTCTRLS:
753 *
754 */
755
756 typedef struct _XADJUSTCTRLS
757 {
758 BOOL fInitialized;
759 SWP swpMain; // SWP for main window
760 SWP *paswp; // pointer to array of control SWP structs
761 } XADJUSTCTRLS, *PXADJUSTCTRLS;
762
763 BOOL XWPENTRY winhAdjustControls(HWND hwndDlg,
764 const MPARAM *pmpFlags,
765 ULONG ulCount,
766 PSWP pswpNew,
767 PXADJUSTCTRLS pxac);
768
769 void XWPENTRY winhCenterWindow(HWND hwnd);
770 typedef void XWPENTRY WINHCENTERWINDOW(HWND hwnd);
771 typedef WINHCENTERWINDOW *PWINHCENTERWINDOW;
772
773 #define PLF_SMART 0x0001
774
775 BOOL winhPlaceBesides(HWND hwnd,
776 HWND hwndRelative,
777 ULONG fl);
778
779 HWND XWPENTRY winhFindWindowBelow(HWND hwndFind);
780
781 /* ******************************************************************
782 *
783 * Presparams helpers
784 *
785 ********************************************************************/
786
787 PSZ XWPENTRY winhQueryWindowFont(HWND hwnd);
788 typedef PSZ XWPENTRY WINHQUERYWINDOWFONT(HWND hwnd);
789 typedef WINHQUERYWINDOWFONT *PWINHQUERYWINDOWFONT;
790
791 PCSZ XWPENTRY winhQueryDefaultFont(VOID);
792
793 PSZ XWPENTRY winhQueryMenuSysFont(VOID);
794
795 BOOL XWPENTRY winhSetWindowFont(HWND hwnd, const char *pcszFont);
796 typedef BOOL XWPENTRY WINHSETWINDOWFONT(HWND hwnd, const char *pcszFont);
797 typedef WINHSETWINDOWFONT *PWINHSETWINDOWFONT;
798
799 /*
800 *@@ winhSetDlgItemFont:
801 * invokes winhSetWindowFont on a dialog
802 * item.
803 *
804 * Returns TRUE if successful or FALSE otherwise.
805 *
806 *@@added V0.9.0
807 */
808
809 #define winhSetDlgItemFont(hwnd, usId, pszFont) \
810 (winhSetWindowFont(WinWindowFromID(hwnd, usId), pszFont))
811
812 ULONG XWPENTRY winhSetControlsFont(HWND hwndDlg, SHORT usIDMin, SHORT usIDMax, const char *pcszFont);
813
814 #ifdef INCL_WINSYS
815 BOOL XWPENTRY winhStorePresParam(PPRESPARAMS *pppp,
816 ULONG ulAttrType,
817 ULONG cbData,
818 PVOID pData);
819
820 PPRESPARAMS XWPENTRY winhCreateDefaultPresparams(VOID);
821 #endif
822
823 LONG XWPENTRY winhQueryPresColor(HWND hwnd, ULONG ulPP, BOOL fInherit, LONG lSysColor);
824 typedef LONG XWPENTRY WINHQUERYPRESCOLOR(HWND hwnd, ULONG ulPP, BOOL fInherit, LONG lSysColor);
825 typedef WINHQUERYPRESCOLOR *PWINHQUERYPRESCOLOR;
826
827 LONG XWPENTRY winhQueryPresColor2(HWND hwnd,
828 ULONG ulppRGB,
829 ULONG ulppIndex,
830 BOOL fInherit,
831 LONG lSysColor);
832
833 BOOL XWPENTRY winhSetPresColor(HWND hwnd, ULONG ulIndex, LONG lColor);
834
835 /* ******************************************************************
836 *
837 * Help instance helpers
838 *
839 ********************************************************************/
840
841 #ifdef INCL_WINHELP
842 HWND XWPENTRY winhCreateHelp(HWND hwndFrame,
843 const char *pcszFileName,
844 HMODULE hmod,
845 PHELPTABLE pHelpTable,
846 const char *pcszWindowTitle);
847
848 ULONG winhDisplayHelpPanel(HWND hwndHelpInstance,
849 ULONG ulHelpPanel);
850
851 void XWPENTRY winhDestroyHelp(HWND hwndHelp, HWND hwndFrame);
852 #endif
853
854 /* ******************************************************************
855 *
856 * Application control
857 *
858 ********************************************************************/
859
860 BOOL XWPENTRY winhAnotherInstance(const char *pcszSemName, BOOL fSwitch);
861
862 HSWITCH XWPENTRY winhAddToTasklist(HWND hwnd, HPOINTER hIcon);
863
864 BOOL XWPENTRY winhUpdateTasklist(HWND hwnd, PCSZ pcszNewTitle);
865
866 /* ******************************************************************
867 *
868 * Miscellaneous
869 *
870 ********************************************************************/
871
872 VOID XWPENTRY winhFree(PVOID p);
873 typedef VOID XWPENTRY WINHFREE(PVOID p);
874 typedef WINHFREE *PWINHFREE;
875
876 /*
877 *@@ winhMyAnchorBlock:
878 * returns the HAB of the current thread.
879 *
880 * Many Win* functions require an HAB to be
881 * passed in. While many of them will work
882 * when passing in NULLHANDLE, some (such as
883 * WinGetMsg) won't. If you don't know the
884 * anchor block of the calling thread, use
885 * this function.
886 *
887 * The HAB is simply a LONG whose hiword has
888 * the current PID and the lowword has the
889 * current TID. The previous function that
890 * created a temporary window to figure this
891 * out has been replaced with this macro, since
892 * WinQueryAnchorBlock(HWND_DESKTOP) yields the
893 * same result.
894 *
895 *@@added V1.0.1 (2002-11-30) [umoeller]
896 */
897
898 #define winhMyAnchorBlock() WinQueryAnchorBlock(HWND_DESKTOP)
899
900 /*
901 HAB XWPENTRY winhMyAnchorBlock(VOID);
902 typedef HAB XWPENTRY WINHMYANCHORBLOCK(VOID);
903 typedef WINHMYANCHORBLOCK *PWINHMYANCHORBLOCK;
904 */
905
906 VOID XWPENTRY winhSleep(ULONG ulSleep);
907
908 #define WINH_FOD_SAVEDLG 0x0001
909 #define WINH_FOD_INILOADDIR 0x0010
910 #define WINH_FOD_INISAVEDIR 0x0020
911
912 BOOL XWPENTRY winhFileDlg(HWND hwndOwner,
913 PSZ pszFile,
914 ULONG flFlags,
915 HINI hini,
916 const char *pcszApplication,
917 const char *pcszKey);
918
919 HPOINTER XWPENTRY winhQueryWaitPointer(VOID);
920
921 HPOINTER XWPENTRY winhSetWaitPointer(VOID);
922
923 PSZ XWPENTRY winhQueryWindowText2(HWND hwnd,
924 PULONG pulExtra);
925
926 PSZ XWPENTRY winhQueryWindowText(HWND hwnd);
927
928 BOOL XWPENTRY winhSetWindowText(HWND hwnd,
929 const char *pcszFormat,
930 ...);
931
932 PSZ XWPENTRY winhQueryDlgItemText2(HWND hwnd,
933 USHORT usItemID,
934 PULONG pulExtra);
935
936 /*
937 *@@ winhQueryDlgItemText:
938 * like winhQueryWindowText, but for the dialog item
939 * in hwnd which has the ID usItemID.
940 *
941 *@@changed V1.0.1 (2003-01-05) [umoeller]: now using winhQueryDlgItemText2
942 */
943
944 #define winhQueryDlgItemText(hwnd, usItemID) winhQueryDlgItemText2(hwnd, usItemID, NULL)
945
946 BOOL XWPENTRY winhAppendWindowEllipseText(HWND hwnd);
947
948 BOOL XWPENTRY winhAppendDlgItemEllipseText(HWND hwnd,
949 USHORT usItemID);
950
951 BOOL XWPENTRY winhReplaceWindowText(HWND hwnd,
952 const char *pcszSearch,
953 const char *pcszReplaceWith);
954
955 ULONG XWPENTRY winhCenteredDlgBox(HWND hwndParent, HWND hwndOwner,
956 PFNWP pfnDlgProc, HMODULE hmod, ULONG idDlg, PVOID pCreateParams);
957 typedef ULONG XWPENTRY WINHCENTEREDDLGBOX(HWND hwndParent, HWND hwndOwner,
958 PFNWP pfnDlgProc, HMODULE hmod, ULONG idDlg, PVOID pCreateParams);
959 typedef WINHCENTEREDDLGBOX *PWINHCENTEREDDLGBOX;
960
961 ULONG XWPENTRY winhEnableControls(HWND hwndDlg,
962 USHORT usIDFirst,
963 USHORT usIDLast,
964 BOOL fEnable);
965
966 ULONG winhEnableControls2(HWND hwndDlg,
967 const ULONG *paulIDs,
968 ULONG cIDs,
969 BOOL fEnable);
970
971 HWND XWPENTRY winhCreateStdWindow(HWND hwndFrameParent,
972 PSWP pswpFrame,
973 ULONG flFrameCreateFlags,
974 ULONG ulFrameStyle,
975 const char *pcszFrameTitle,
976 ULONG ulResourcesID,
977 const char *pcszClassClient,
978 ULONG flStyleClient,
979 ULONG ulID,
980 PVOID pClientCtlData,
981 PHWND phwndClient);
982
983 HWND XWPENTRY winhCreateObjectWindow(const char *pcszWindowClass,
984 PVOID pvCreateParam);
985
986 HWND XWPENTRY winhCreateControl(HWND hwndParent,
987 HWND hwndOwner,
988 const char *pcszClass,
989 const char *pcszText,
990 ULONG ulStyle,
991 ULONG ulID);
992
993 BOOL XWPENTRY winhSetParentAndOwner(HWND hwnd,
994 HWND hwndNewParent,
995 BOOL fRedraw);
996
997 VOID XWPENTRY winhRepaintWindows(HWND hwndParent);
998
999 HMQ XWPENTRY winhFindMsgQueue(PID pid, TID tid, HAB* phab);
1000
1001 VOID XWPENTRY winhFindPMErrorWindows(HWND *phwndHardError, HWND *phwndSysError);
1002
1003 HWND XWPENTRY winhCreateFakeDesktop(HWND hwndSibling);
1004
1005 // Warp 4 notebook button style
1006 #ifndef BS_NOTEBOOKBUTTON
1007 #define BS_NOTEBOOKBUTTON 8L
1008 #endif
1009
1010 BOOL XWPENTRY winhAssertWarp4Notebook(HWND hwndDlg,
1011 USHORT usIdThreshold);
1012
1013 ULONG XWPENTRY winhDrawFormattedText(HPS hps, PRECTL prcl, const char *pcszText, ULONG flCmd);
1014
1015 #ifdef INCL_WINSWITCHLIST
1016 PSWBLOCK XWPENTRY winhQuerySwitchList(HAB hab);
1017 typedef PSWBLOCK XWPENTRY WINHQUERYSWITCHLIST(HAB hab);
1018 typedef WINHQUERYSWITCHLIST *PWINHQUERYSWITCHLIST;
1019
1020 HSWITCH XWPENTRY winhHSWITCHfromHAPP(HAPP happ);
1021 #endif
1022
1023 HWND XWPENTRY winhQueryTasklistWindow(VOID);
1024 typedef HWND XWPENTRY WINHQUERYTASKLISTWINDOW(VOID);
1025 typedef WINHQUERYTASKLISTWINDOW *PWINHQUERYTASKLISTWINDOW;
1026
1027 VOID XWPENTRY winhKillTasklist(VOID);
1028
1029 ULONG XWPENTRY winhQueryPendingSpoolJobs(VOID);
1030
1031 VOID XWPENTRY winhSetNumLock(BOOL fState);
1032
1033 BOOL XWPENTRY winhSetClipboardText(HAB hab,
1034 PCSZ pcsz,
1035 ULONG cbSize);
1036
1037 /* ******************************************************************
1038 *
1039 * WPS Class List helpers
1040 *
1041 ********************************************************************/
1042
1043 PBYTE XWPENTRY winhQueryWPSClassList(VOID);
1044
1045 PBYTE XWPENTRY winhQueryWPSClass(PBYTE pObjClass, const char *pszClass);
1046
1047 APIRET XWPENTRY winhRegisterClass(const char* pcszClassName,
1048 const char* pcszModule,
1049 PSZ pszBuf,
1050 ULONG cbBuf);
1051
1052 BOOL XWPENTRY winhIsClassRegistered(const char *pcszClass);
1053
1054 ULONG XWPENTRY winhResetWPS(HAB hab);
1055
1056#endif
1057
1058#if __cplusplus
1059}
1060#endif
1061
Note: See TracBrowser for help on using the repository browser.