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

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

Misc fixes.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 41.2 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 BOOL XWPENTRY winhHandleScrollMsg(HWND hwnd2Scroll,
682 HWND hwndScrollBar,
683 PULONG pulCurPelsOfs,
684 PRECTL prcl2Scroll,
685 LONG ulViewportPels,
686 USHORT usLineStepUnits,
687 ULONG msg,
688 MPARAM mp2);
689
690 BOOL XWPENTRY winhProcessScrollChars(HWND hwndClient,
691 HWND hwndVScroll,
692 HWND hwndHScroll,
693 MPARAM mp1,
694 MPARAM mp2,
695 ULONG ulVertMax,
696 ULONG ulHorzMax);
697
698 /* ******************************************************************
699 *
700 * Window positioning helpers
701 *
702 ********************************************************************/
703
704 BOOL XWPENTRY winhSaveWindowPos(HWND hwnd, HINI hIni, const char *pcszApp, const char *pcszKey);
705
706 BOOL XWPENTRY winhRestoreWindowPos(HWND hwnd, HINI hIni, const char *pcszApp, const char *pcszKey, ULONG fl);
707
708 #define XAC_MOVEX 0x0001
709 #define XAC_MOVEY 0x0002
710 #define XAC_SIZEX 0x0004
711 #define XAC_SIZEY 0x0008
712
713 /*
714 *@@ XADJUSTCTRLS:
715 *
716 */
717
718 typedef struct _XADJUSTCTRLS
719 {
720 BOOL fInitialized;
721 SWP swpMain; // SWP for main window
722 SWP *paswp; // pointer to array of control SWP structs
723 } XADJUSTCTRLS, *PXADJUSTCTRLS;
724
725 BOOL XWPENTRY winhAdjustControls(HWND hwndDlg,
726 const MPARAM *pmpFlags,
727 ULONG ulCount,
728 PSWP pswpNew,
729 PXADJUSTCTRLS pxac);
730
731 void XWPENTRY winhCenterWindow(HWND hwnd);
732 typedef void XWPENTRY WINHCENTERWINDOW(HWND hwnd);
733 typedef WINHCENTERWINDOW *PWINHCENTERWINDOW;
734
735 #define PLF_SMART 0x0001
736
737 BOOL winhPlaceBesides(HWND hwnd,
738 HWND hwndRelative,
739 ULONG fl);
740
741 HWND XWPENTRY winhFindWindowBelow(HWND hwndFind);
742
743 /* ******************************************************************
744 *
745 * Presparams helpers
746 *
747 ********************************************************************/
748
749 PSZ XWPENTRY winhQueryWindowFont(HWND hwnd);
750 typedef PSZ XWPENTRY WINHQUERYWINDOWFONT(HWND hwnd);
751 typedef WINHQUERYWINDOWFONT *PWINHQUERYWINDOWFONT;
752
753 PCSZ XWPENTRY winhQueryDefaultFont(VOID);
754
755 PSZ XWPENTRY winhQueryMenuSysFont(VOID);
756
757 BOOL XWPENTRY winhSetWindowFont(HWND hwnd, const char *pcszFont);
758 typedef BOOL XWPENTRY WINHSETWINDOWFONT(HWND hwnd, const char *pcszFont);
759 typedef WINHSETWINDOWFONT *PWINHSETWINDOWFONT;
760
761 /*
762 *@@ winhSetDlgItemFont:
763 * invokes winhSetWindowFont on a dialog
764 * item.
765 *
766 * Returns TRUE if successful or FALSE otherwise.
767 *
768 *@@added V0.9.0
769 */
770
771 #define winhSetDlgItemFont(hwnd, usId, pszFont) \
772 (winhSetWindowFont(WinWindowFromID(hwnd, usId), pszFont))
773
774 ULONG XWPENTRY winhSetControlsFont(HWND hwndDlg, SHORT usIDMin, SHORT usIDMax, const char *pcszFont);
775
776 #ifdef INCL_WINSYS
777 BOOL XWPENTRY winhStorePresParam(PPRESPARAMS *pppp,
778 ULONG ulAttrType,
779 ULONG cbData,
780 PVOID pData);
781
782 PPRESPARAMS XWPENTRY winhCreateDefaultPresparams(VOID);
783 #endif
784
785 LONG XWPENTRY winhQueryPresColor(HWND hwnd, ULONG ulPP, BOOL fInherit, LONG lSysColor);
786 typedef LONG XWPENTRY WINHQUERYPRESCOLOR(HWND hwnd, ULONG ulPP, BOOL fInherit, LONG lSysColor);
787 typedef WINHQUERYPRESCOLOR *PWINHQUERYPRESCOLOR;
788
789 LONG XWPENTRY winhQueryPresColor2(HWND hwnd,
790 ULONG ulppRGB,
791 ULONG ulppIndex,
792 BOOL fInherit,
793 LONG lSysColor);
794
795 BOOL XWPENTRY winhSetPresColor(HWND hwnd, ULONG ulIndex, LONG lColor);
796
797 /* ******************************************************************
798 *
799 * Help instance helpers
800 *
801 ********************************************************************/
802
803 #ifdef INCL_WINHELP
804 HWND XWPENTRY winhCreateHelp(HWND hwndFrame,
805 const char *pcszFileName,
806 HMODULE hmod,
807 PHELPTABLE pHelpTable,
808 const char *pcszWindowTitle);
809
810 ULONG winhDisplayHelpPanel(HWND hwndHelpInstance,
811 ULONG ulHelpPanel);
812
813 void XWPENTRY winhDestroyHelp(HWND hwndHelp, HWND hwndFrame);
814 #endif
815
816 /* ******************************************************************
817 *
818 * Application control
819 *
820 ********************************************************************/
821
822 BOOL XWPENTRY winhAnotherInstance(const char *pcszSemName, BOOL fSwitch);
823
824 HSWITCH XWPENTRY winhAddToTasklist(HWND hwnd, HPOINTER hIcon);
825
826 /* ******************************************************************
827 *
828 * Miscellaneous
829 *
830 ********************************************************************/
831
832 VOID XWPENTRY winhFree(PVOID p);
833 typedef VOID XWPENTRY WINHFREE(PVOID p);
834 typedef WINHFREE *PWINHFREE;
835
836 /*
837 *@@ winhMyAnchorBlock:
838 * returns the HAB of the current thread.
839 *
840 * Many Win* functions require an HAB to be
841 * passed in. While many of them will work
842 * when passing in NULLHANDLE, some (such as
843 * WinGetMsg) won't. If you don't know the
844 * anchor block of the calling thread, use
845 * this function.
846 *
847 * The HAB is simply a LONG whose hiword has
848 * the current PID and the lowword has the
849 * current TID. The previous function that
850 * created a temporary window to figure this
851 * out has been replaced with this macro, since
852 * WinQueryAnchorBlock(HWND_DESKTOP) yields the
853 * same result.
854 *
855 *@@added V1.0.1 (2002-11-30) [umoeller]
856 */
857
858 #define winhMyAnchorBlock() WinQueryAnchorBlock(HWND_DESKTOP)
859
860 /*
861 HAB XWPENTRY winhMyAnchorBlock(VOID);
862 typedef HAB XWPENTRY WINHMYANCHORBLOCK(VOID);
863 typedef WINHMYANCHORBLOCK *PWINHMYANCHORBLOCK;
864 */
865
866 VOID XWPENTRY winhSleep(ULONG ulSleep);
867
868 #define WINH_FOD_SAVEDLG 0x0001
869 #define WINH_FOD_INILOADDIR 0x0010
870 #define WINH_FOD_INISAVEDIR 0x0020
871
872 BOOL XWPENTRY winhFileDlg(HWND hwndOwner,
873 PSZ pszFile,
874 ULONG flFlags,
875 HINI hini,
876 const char *pcszApplication,
877 const char *pcszKey);
878
879 HPOINTER XWPENTRY winhQueryWaitPointer(VOID);
880
881 HPOINTER XWPENTRY winhSetWaitPointer(VOID);
882
883 PSZ XWPENTRY winhQueryWindowText2(HWND hwnd,
884 PULONG pulExtra);
885
886 PSZ XWPENTRY winhQueryWindowText(HWND hwnd);
887
888 BOOL XWPENTRY winhSetWindowText(HWND hwnd,
889 const char *pcszFormat,
890 ...);
891
892 PSZ XWPENTRY winhQueryDlgItemText2(HWND hwnd,
893 USHORT usItemID,
894 PULONG pulExtra);
895
896 /*
897 *@@ winhQueryDlgItemText:
898 * like winhQueryWindowText, but for the dialog item
899 * in hwnd which has the ID usItemID.
900 *
901 *@@changed V1.0.1 (2003-01-05) [umoeller]: now using winhQueryDlgItemText2
902 */
903
904 #define winhQueryDlgItemText(hwnd, usItemID) winhQueryDlgItemText2(hwnd, usItemID, NULL)
905
906 BOOL XWPENTRY winhAppendWindowEllipseText(HWND hwnd);
907
908 BOOL XWPENTRY winhAppendDlgItemEllipseText(HWND hwnd,
909 USHORT usItemID);
910
911 BOOL XWPENTRY winhReplaceWindowText(HWND hwnd,
912 const char *pcszSearch,
913 const char *pcszReplaceWith);
914
915 ULONG XWPENTRY winhCenteredDlgBox(HWND hwndParent, HWND hwndOwner,
916 PFNWP pfnDlgProc, HMODULE hmod, ULONG idDlg, PVOID pCreateParams);
917 typedef ULONG XWPENTRY WINHCENTEREDDLGBOX(HWND hwndParent, HWND hwndOwner,
918 PFNWP pfnDlgProc, HMODULE hmod, ULONG idDlg, PVOID pCreateParams);
919 typedef WINHCENTEREDDLGBOX *PWINHCENTEREDDLGBOX;
920
921 ULONG XWPENTRY winhEnableControls(HWND hwndDlg,
922 USHORT usIDFirst,
923 USHORT usIDLast,
924 BOOL fEnable);
925
926 ULONG winhEnableControls2(HWND hwndDlg,
927 const ULONG *paulIDs,
928 ULONG cIDs,
929 BOOL fEnable);
930
931 HWND XWPENTRY winhCreateStdWindow(HWND hwndFrameParent,
932 PSWP pswpFrame,
933 ULONG flFrameCreateFlags,
934 ULONG ulFrameStyle,
935 const char *pcszFrameTitle,
936 ULONG ulResourcesID,
937 const char *pcszClassClient,
938 ULONG flStyleClient,
939 ULONG ulID,
940 PVOID pClientCtlData,
941 PHWND phwndClient);
942
943 HWND XWPENTRY winhCreateObjectWindow(const char *pcszWindowClass,
944 PVOID pvCreateParam);
945
946 HWND XWPENTRY winhCreateControl(HWND hwndParent,
947 HWND hwndOwner,
948 const char *pcszClass,
949 const char *pcszText,
950 ULONG ulStyle,
951 ULONG ulID);
952
953 VOID XWPENTRY winhRepaintWindows(HWND hwndParent);
954
955 HMQ XWPENTRY winhFindMsgQueue(PID pid, TID tid, HAB* phab);
956
957 VOID XWPENTRY winhFindPMErrorWindows(HWND *phwndHardError, HWND *phwndSysError);
958
959 HWND XWPENTRY winhCreateFakeDesktop(HWND hwndSibling);
960
961 // Warp 4 notebook button style
962 #ifndef BS_NOTEBOOKBUTTON
963 #define BS_NOTEBOOKBUTTON 8L
964 #endif
965
966 BOOL XWPENTRY winhAssertWarp4Notebook(HWND hwndDlg,
967 USHORT usIdThreshold);
968
969 ULONG XWPENTRY winhDrawFormattedText(HPS hps, PRECTL prcl, const char *pcszText, ULONG flCmd);
970
971 #ifdef INCL_WINSWITCHLIST
972 PSWBLOCK XWPENTRY winhQuerySwitchList(HAB hab);
973 typedef PSWBLOCK XWPENTRY WINHQUERYSWITCHLIST(HAB hab);
974 typedef WINHQUERYSWITCHLIST *PWINHQUERYSWITCHLIST;
975
976 HSWITCH XWPENTRY winhHSWITCHfromHAPP(HAPP happ);
977 #endif
978
979 HWND XWPENTRY winhQueryTasklistWindow(VOID);
980 typedef HWND XWPENTRY WINHQUERYTASKLISTWINDOW(VOID);
981 typedef WINHQUERYTASKLISTWINDOW *PWINHQUERYTASKLISTWINDOW;
982
983 VOID XWPENTRY winhKillTasklist(VOID);
984
985 ULONG XWPENTRY winhQueryPendingSpoolJobs(VOID);
986
987 VOID XWPENTRY winhSetNumLock(BOOL fState);
988
989 BOOL XWPENTRY winhSetClipboardText(HAB hab,
990 PCSZ pcsz,
991 ULONG cbSize);
992
993 /* ******************************************************************
994 *
995 * WPS Class List helpers
996 *
997 ********************************************************************/
998
999 PBYTE XWPENTRY winhQueryWPSClassList(VOID);
1000
1001 PBYTE XWPENTRY winhQueryWPSClass(PBYTE pObjClass, const char *pszClass);
1002
1003 APIRET XWPENTRY winhRegisterClass(const char* pcszClassName,
1004 const char* pcszModule,
1005 PSZ pszBuf,
1006 ULONG cbBuf);
1007
1008 BOOL XWPENTRY winhIsClassRegistered(const char *pcszClass);
1009
1010 ULONG XWPENTRY winhResetWPS(HAB hab);
1011
1012#endif
1013
1014#if __cplusplus
1015}
1016#endif
1017
Note: See TracBrowser for help on using the repository browser.