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

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

New toolbar control.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 40.6 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 /* ******************************************************************
197 *
198 * Menu helpers
199 *
200 ********************************************************************/
201
202 // now including all this only with INCL_WINMENUS
203 // V1.0.1 (2002-11-30) [umoeller]
204 #ifdef INCL_WINMENUS
205
206 #ifndef MM_QUERYITEMBYPOS16
207 #define MM_QUERYITEMBYPOS16 0x01f3
208 // this undocumented message is sent to retrieve the definition
209 // of a menu item by its position. This message will only query
210 // an item in the specified menu.
211 //
212 // Parameters:
213 // SHORT1FROMMP(mp1) = position of item in the menu
214 // SHORT2FROMMP(mp1) = reserved, set to 0
215 // mp2 = (16 bit pointer) points to a MENUITEM structure
216 // to be filled in.
217 #endif
218 #ifndef MAKE_16BIT_POINTER
219 #define MAKE_16BIT_POINTER(p) \
220 ((PVOID)MAKEULONG(LOUSHORT(p),(HIUSHORT(p) << 3) | 7))
221 // converts a flat 32bit pointer to its 16bit offset/selector form
222 #endif
223
224 BOOL XWPENTRY winhQueryMenuItem(HWND hwndMenu,
225 USHORT usItemID,
226 BOOL fSearchSubmenus,
227 PMENUITEM pmi);
228
229 HWND XWPENTRY winhQuerySubmenu(HWND hMenu, SHORT sID);
230
231 /*
232 * winhCreateEmptyMenu:
233 * this macro creates an empty menu, which can
234 * be used with winhInsertMenuItem etc. later.
235 * Useful for creating popup menus on the fly.
236 * Note that even though HWND_DESKTOP is specified
237 * here as both the parent and the owner, the
238 * actual owner and parent are specified later
239 * with WinPopupMenu.
240 */
241
242 #define winhCreateEmptyMenu() \
243 WinCreateWindow(HWND_DESKTOP, WC_MENU, "", 0, 0, 0, 0, 0, \
244 HWND_DESKTOP, HWND_TOP, 0, 0, 0)
245
246 SHORT XWPENTRY winhInsertMenuItem(HWND hwndMenu,
247 SHORT iPosition,
248 SHORT sItemId,
249 const char *pcszItemTitle,
250 SHORT afStyle,
251 SHORT afAttr);
252 typedef SHORT XWPENTRY WINHINSERTMENUITEM(HWND hwndMenu,
253 SHORT iPosition,
254 SHORT sItemId,
255 const char *pcszItemTitle,
256 SHORT afStyle,
257 SHORT afAttr);
258 typedef WINHINSERTMENUITEM *PWINHINSERTMENUITEM;
259
260 HWND XWPENTRY winhInsertSubmenu(HWND hwndMenu,
261 ULONG iPosition,
262 SHORT sMenuId,
263 const char *pcszSubmenuTitle,
264 USHORT afMenuStyle,
265 SHORT sItemId,
266 const char *pcszItemTitle,
267 USHORT afItemStyle,
268 USHORT afAttribute);
269 typedef HWND XWPENTRY WINHINSERTSUBMENU(HWND hwndMenu,
270 ULONG iPosition,
271 SHORT sMenuId,
272 const char *pcszSubmenuTitle,
273 USHORT afMenuStyle,
274 SHORT sItemId,
275 const char *pcszItemTitle,
276 USHORT afItemStyle,
277 USHORT afAttribute);
278 typedef WINHINSERTSUBMENU *PWINHINSERTSUBMENU;
279
280 BOOL XWPENTRY winhSetMenuCondCascade(HWND hwndMenu,
281 LONG lDefaultItem);
282
283 /*
284 *@@ winhRemoveMenuItem:
285 * removes a menu item (SHORT) from the
286 * given menu (HWND). Returns the no. of
287 * remaining menu items (SHORT).
288 *
289 * This works for whole submenus too.
290 */
291
292 #define winhRemoveMenuItem(hwndMenu, sItemID) \
293 SHORT1FROMMR(WinSendMsg(hwndMenu, MM_REMOVEITEM, MPFROM2SHORT(sItemID, FALSE), 0))
294
295 BOOL XWPENTRY winhRemoveMenuItems(HWND hwndMenu,
296 const SHORT *asItemIDs,
297 ULONG cItemIDs);
298
299 /*
300 *@@ winhDeleteMenuItem:
301 * deleted a menu item (SHORT) from the
302 * given menu (HWND). Returns the no. of
303 * remaining menu items (SHORT).
304 *
305 * As opposed to MM_REMOVEITEM, MM_DELETEITEM
306 * frees submenus and bitmaps also.
307 *
308 * This works for whole submenus too.
309 */
310
311 #define winhDeleteMenuItem(hwndMenu, sItemId) \
312 (SHORT)WinSendMsg(hwndMenu, MM_DELETEITEM, MPFROM2SHORT(sItemId, FALSE), 0)
313
314 SHORT XWPENTRY winhInsertMenuSeparator(HWND hMenu,
315 SHORT iPosition,
316 SHORT sId);
317
318 #define COPYFL_STRIPTABS 0x0001
319
320 BOOL XWPENTRY winhCopyMenuItem2(HWND hmenuTarget,
321 HWND hmenuSource,
322 USHORT usID,
323 SHORT sTargetPosition,
324 ULONG fl);
325
326 BOOL XWPENTRY winhCopyMenuItem(HWND hmenuTarget,
327 HWND hmenuSource,
328 USHORT usID,
329 SHORT sTargetPosition);
330 typedef BOOL XWPENTRY WINHCOPYMENUITEM(HWND hmenuTarget,
331 HWND hmenuSource,
332 USHORT usID,
333 SHORT sTargetPosition);
334 typedef WINHCOPYMENUITEM *PWINHCOPYMENUITEM;
335
336 HWND XWPENTRY winhMergeIntoSubMenu(HWND hmenuTarget,
337 SHORT sTargetPosition,
338 const char *pcszTitle,
339 SHORT sID,
340 HWND hmenuSource);
341 typedef HWND XWPENTRY WINHMERGEINTOSUBMENU(HWND hmenuTarget,
342 SHORT sTargetPosition,
343 const char *pcszTitle,
344 SHORT sID,
345 HWND hmenuSource);
346 typedef WINHMERGEINTOSUBMENU *PWINHMERGEINTOSUBMENU;
347
348 ULONG XWPENTRY winhMergeMenus(HWND hmenuTarget,
349 SHORT sTargetPosition,
350 HWND hmenuSource,
351 ULONG fl);
352 typedef ULONG XWPENTRY WINHMERGEMENUS(HWND hmenuTarget,
353 SHORT sTargetPosition,
354 HWND hmenuSource,
355 ULONG fl);
356 typedef WINHMERGEMENUS *PWINHMERGEMENUS;
357
358 ULONG XWPENTRY winhClearMenu(HWND hwndMenu);
359
360 PSZ XWPENTRY winhQueryMenuItemText(HWND hwndMenu,
361 USHORT usItemID);
362
363 BOOL XWPENTRY winhAppend2MenuItemText(HWND hwndMenu,
364 USHORT usItemID,
365 const char *pcszAppend,
366 BOOL fTab);
367
368 VOID XWPENTRY winhMenuRemoveEllipse(HWND hwndMenu,
369 USHORT usItemId);
370
371 SHORT XWPENTRY winhQueryItemUnderMouse(HWND hwndMenu, POINTL *pptlMouse, RECTL *prtlItem);
372
373 #endif
374
375 /* ******************************************************************
376 *
377 * Slider helpers
378 *
379 ********************************************************************/
380
381 HWND XWPENTRY winhReplaceWithLinearSlider(HWND hwndParent,
382 HWND hwndOwner,
383 HWND hwndInsertAfter,
384 ULONG ulID,
385 ULONG ulSliderStyle,
386 ULONG ulTickCount);
387
388 BOOL XWPENTRY winhSetSliderTicks(HWND hwndSlider,
389 MPARAM mpEveryOther1,
390 ULONG ulPixels1,
391 MPARAM mpEveryOther2,
392 ULONG ulPixels2);
393 typedef BOOL XWPENTRY WINHSETSLIDERTICKS(HWND hwndSlider,
394 MPARAM mpEveryOther1,
395 ULONG ulPixels1,
396 MPARAM mpEveryOther2,
397 ULONG ulPixels2);
398 typedef WINHSETSLIDERTICKS *PWINHSETSLIDERTICKS;
399
400 /*
401 * winhSetSliderArmPosition:
402 * this moves the slider arm in a given
403 * linear slider.
404 *
405 * usMode can be one of the following:
406 * -- SMA_RANGEVALUE: usOffset is in pixels
407 * from the slider's home position.
408 * -- SMA_INCREMENTVALUE: usOffset is in
409 * units of the slider's primary scale.
410 */
411
412 #define winhSetSliderArmPosition(hwndSlider, usMode, usOffset) \
413 WinSendMsg(hwndSlider, SLM_SETSLIDERINFO, \
414 MPFROM2SHORT(SMA_SLIDERARMPOSITION, \
415 usMode), \
416 MPFROMSHORT(usOffset))
417
418 /*
419 * winhQuerySliderArmPosition:
420 * reverse to the previous, this returns a
421 * slider arm position (as a LONG value).
422 */
423
424 #define winhQuerySliderArmPosition(hwndSlider, usMode) \
425 (LONG)(WinSendMsg(hwndSlider, \
426 SLM_QUERYSLIDERINFO, \
427 MPFROM2SHORT(SMA_SLIDERARMPOSITION, \
428 usMode), \
429 0))
430
431 HWND XWPENTRY winhReplaceWithCircularSlider(HWND hwndParent,
432 HWND hwndOwner,
433 HWND hwndInsertAfter,
434 ULONG ulID,
435 ULONG ulSliderStyle,
436 SHORT sMin,
437 SHORT sMax,
438 USHORT usIncrement,
439 USHORT usTicksEvery);
440
441 /* ******************************************************************
442 *
443 * Spin button helpers
444 *
445 ********************************************************************/
446
447 VOID XWPENTRY winhSetDlgItemSpinData(HWND hwndDlg,
448 ULONG idSpinButton,
449 ULONG min,
450 ULONG max,
451 ULONG current);
452 typedef VOID XWPENTRY WINHSETDLGITEMSPINDATA(HWND hwndDlg,
453 ULONG idSpinButton,
454 ULONG min,
455 ULONG max,
456 ULONG current);
457 typedef WINHSETDLGITEMSPINDATA *PWINHSETDLGITEMSPINDATA;
458
459 LONG XWPENTRY winhAdjustDlgItemSpinData(HWND hwndDlg,
460 USHORT usItemID,
461 LONG lGrid,
462 USHORT usNotifyCode);
463 typedef LONG XWPENTRY WINHADJUSTDLGITEMSPINDATA(HWND hwndDlg,
464 USHORT usItemID,
465 LONG lGrid,
466 USHORT usNotifyCode);
467 typedef WINHADJUSTDLGITEMSPINDATA *PWINHADJUSTDLGITEMSPINDATA;
468
469 /* ******************************************************************
470 *
471 * Entry field helpers
472 *
473 ********************************************************************/
474
475 /*
476 * winhSetEntryFieldLimit:
477 * sets the maximum length for the entry field
478 * (EM_SETTEXTLIMIT message).
479 *
480 * PMREF doesn't say this, but the limit does
481 * _not_ include the null-terminator. That is,
482 * if you specify "12" characters here, you can
483 * really enter 12 characters.
484 *
485 * The default length is 30 characters, I think.
486 */
487
488 #define winhSetEntryFieldLimit(hwndEntryField, usLength) \
489 WinSendMsg(hwndEntryField, EM_SETTEXTLIMIT, (MPARAM)(usLength), (MPARAM)0)
490
491 /*
492 *@@ winhEntryFieldSelectAll:
493 * this selects the entire text in the entry field.
494 * Useful when the thing gets the focus.
495 */
496
497 #define winhEntryFieldSelectAll(hwndEntryField) \
498 WinSendMsg(hwndEntryField, EM_SETSEL, MPFROM2SHORT(0, 10000), MPNULL)
499
500 /*
501 *@@ winhHasEntryFieldChanged:
502 * this queries whether the entry field's contents
503 * have changed (EM_QUERYCHANGED message).
504 *
505 * This returns TRUE if changes have occured since
506 * the last time this message or WM_QUERYWINDOWPARAMS
507 * (WinQueryWindowText) was received.
508 */
509
510 #define winhHasEntryFieldChanged(hwndEntryField) \
511 (BOOL)WinSendMsg(hwndEntryField, EM_QUERYCHANGED, (MPARAM)0, (MPARAM)0)
512
513 /* ******************************************************************
514 *
515 * List box helpers
516 *
517 ********************************************************************/
518
519 /* The following macros are defined in the OS/2 headers for
520 list boxes:
521
522 LONG WinQueryLboxCount(HWND hwndLbox);
523 // wrapper around LM_QUERYITEMCOUNT;
524 // list box item count
525
526 SHORT WinQueryLboxItemTextLength(HWND hwndLbox,
527 SHORT index); // item index, starting from 0
528 // wrapper around LM_QUERYITEMTEXTLENGTH;
529 // returns length of item text, excluding NULL character
530
531 LONG WinQueryLboxItemText(HWND hwndLbox,
532 SHORT index, // item index, starting from 0
533 PSZ psz, // buffer
534 PSZ cchMax); // size of buffer, incl. null
535 // wrapper around LM_QUERYITEMTEXT;
536 // returns length of item text, excluding NULL character
537
538 BOOL WinSetLboxItemText(HWND hwndLbox,
539 LONG index,
540 PSZ psz);
541 // wrapper around LM_SETITEMTEXT
542
543 LONG WinInsertLboxItem(HWND hwndLbox,
544 LONG index, // new item index, starting from 0
545 // or LIT_END
546 // or LIT_SORTASCENDING
547 // or LIT_SORTDESCENDING
548 PSZ psz)
549 // wrapper around LM_INSERTITEM;
550 // returns LIT_MEMERROR, LIT_ERROR, or zero-based index
551
552 LONG WinDeleteLboxItem(HWND hwndLbox,
553 LONG index); // item index, starting from 0
554
555 LONG WinQueryLboxSelectedItem(HWND hwndLbox);
556 // wrapper around LM_QUERYSELECTION;
557 // works with single selection only,
558 // use winhQueryLboxSelectedItem instead
559 */
560
561 /*
562 * winhQueryLboxItemCount:
563 * returns the no. of items in the listbox
564 * as a SHORT.
565 *
566 *added V0.9.1 (99-12-14) [umoeller]
567 */
568
569 // #define winhQueryLboxItemCount(hwndListBox)
570 // (SHORT)WinSendMsg(hwndListBox, LM_QUERYITEMCOUNT, 0, 0)
571
572 // removed, use WinQueryLboxCount
573
574 /*
575 *@@ winhDeleteAllItems:
576 * deletes all list box items. Returns
577 * a BOOL.
578 *
579 *@@added V0.9.1 (99-12-14) [umoeller]
580 */
581
582 #define winhDeleteAllItems(hwndListBox) \
583 (BOOL)WinSendMsg(hwndListBox, \
584 LM_DELETEALL, 0, 0)
585 /*
586 *@@ winhQueryLboxSelectedItem:
587 * this queries the next selected list box item.
588 * For the first call, set sItemStart to LIT_FIRST;
589 * then repeat the call with sItemStart set to
590 * the previous return value until this returns
591 * LIT_NONE.
592 *
593 * Example:
594 + SHORT sItemStart = LIT_FIRST;
595 + while (TRUE)
596 + {
597 + sItemStart = winhQueryLboxSelectedItem(hwndListBox,
598 + sItemStart)
599 + if (sItemStart == LIT_NONE)
600 + break;
601 + ...
602 + }
603 *
604 * To have the cursored item returned, use LIT_CURSOR.
605 *
606 * For single selection, you can also use
607 * WinQueryLboxSelectedItem from the OS/2 PM headers.
608 */
609
610 #define winhQueryLboxSelectedItem(hwndListBox, sItemStart) \
611 SHORT1FROMMR(WinSendMsg(hwndListBox, \
612 LM_QUERYSELECTION, \
613 (MPARAM)(sItemStart), \
614 MPNULL))
615
616 /*
617 *@@ winhSetLboxSelectedItem:
618 * selects a list box item.
619 * This works for both single-selection and
620 * multiple-selection listboxes.
621 * In single-selection listboxes, if an item
622 * is selected (fSelect == TRUE), the previous
623 * item is automatically deselected.
624 * Note that (BOOL)fSelect is ignored if
625 * sItemIndex == LIT_NONE.
626 */
627
628 #define winhSetLboxSelectedItem(hwndListBox, sItemIndex, fSelect) \
629 (BOOL)(WinSendMsg(hwndListBox, \
630 LM_SELECTITEM, \
631 (MPARAM)(sItemIndex), \
632 (MPARAM)(fSelect)))
633
634 ULONG XWPENTRY winhLboxSelectAll(HWND hwndListBox, BOOL fSelect);
635
636 /*
637 * winhSetLboxItemHandle:
638 * sets the "item handle" for the specified sItemIndex.
639 * See LM_SETITEMHANDLE in PMREF for details.
640 */
641
642 #define winhSetLboxItemHandle(hwndListBox, sItemIndex, ulHandle) \
643 (BOOL)(WinSendMsg(hwndListBox, LM_SETITEMHANDLE, \
644 (MPARAM)(sItemIndex), \
645 (MPARAM)ulHandle))
646
647 /*
648 * winhQueryLboxItemHandle:
649 * the reverse to the previous. Returns a ULONG.
650 */
651
652 #define winhQueryLboxItemHandle(hwndListBox, sItemIndex) \
653 (ULONG)WinSendMsg(hwndListBox, LM_QUERYITEMHANDLE, \
654 MPFROMSHORT(sItemIndex), (MPARAM)NULL)
655
656 PSZ XWPENTRY winhQueryLboxItemText(HWND hwndListbox, SHORT sIndex);
657
658 BOOL XWPENTRY winhMoveLboxItem(HWND hwndSource,
659 SHORT sSourceIndex,
660 HWND hwndTarget,
661 SHORT sTargetIndex,
662 BOOL fSelectTarget);
663
664 ULONG XWPENTRY winhLboxFindItemFromHandle(HWND hwndListBox,
665 ULONG ulHandle);
666
667 /* ******************************************************************
668 *
669 * Scroll bar helpers
670 *
671 ********************************************************************/
672
673 BOOL XWPENTRY winhUpdateScrollBar(HWND hwndScrollBar,
674 ULONG ulWinPels,
675 ULONG ulViewportPels,
676 ULONG ulCurUnitOfs,
677 BOOL fAutoHide);
678
679 BOOL XWPENTRY winhHandleScrollMsg(HWND hwnd2Scroll,
680 HWND hwndScrollBar,
681 PULONG pulCurPelsOfs,
682 PRECTL prcl2Scroll,
683 LONG ulViewportPels,
684 USHORT usLineStepUnits,
685 ULONG msg,
686 MPARAM mp2);
687
688 BOOL XWPENTRY winhProcessScrollChars(HWND hwndClient,
689 HWND hwndVScroll,
690 HWND hwndHScroll,
691 MPARAM mp1,
692 MPARAM mp2,
693 ULONG ulVertMax,
694 ULONG ulHorzMax);
695
696 /* ******************************************************************
697 *
698 * Window positioning helpers
699 *
700 ********************************************************************/
701
702 BOOL XWPENTRY winhSaveWindowPos(HWND hwnd, HINI hIni, const char *pcszApp, const char *pcszKey);
703
704 BOOL XWPENTRY winhRestoreWindowPos(HWND hwnd, HINI hIni, const char *pcszApp, const char *pcszKey, ULONG fl);
705
706 #define XAC_MOVEX 0x0001
707 #define XAC_MOVEY 0x0002
708 #define XAC_SIZEX 0x0004
709 #define XAC_SIZEY 0x0008
710
711 /*
712 *@@ XADJUSTCTRLS:
713 *
714 */
715
716 typedef struct _XADJUSTCTRLS
717 {
718 BOOL fInitialized;
719 SWP swpMain; // SWP for main window
720 SWP *paswp; // pointer to array of control SWP structs
721 } XADJUSTCTRLS, *PXADJUSTCTRLS;
722
723 BOOL XWPENTRY winhAdjustControls(HWND hwndDlg,
724 const MPARAM *pmpFlags,
725 ULONG ulCount,
726 PSWP pswpNew,
727 PXADJUSTCTRLS pxac);
728
729 void XWPENTRY winhCenterWindow(HWND hwnd);
730 typedef void XWPENTRY WINHCENTERWINDOW(HWND hwnd);
731 typedef WINHCENTERWINDOW *PWINHCENTERWINDOW;
732
733 #define PLF_SMART 0x0001
734
735 BOOL winhPlaceBesides(HWND hwnd,
736 HWND hwndRelative,
737 ULONG fl);
738
739 HWND XWPENTRY winhFindWindowBelow(HWND hwndFind);
740
741 /* ******************************************************************
742 *
743 * Presparams helpers
744 *
745 ********************************************************************/
746
747 PSZ XWPENTRY winhQueryWindowFont(HWND hwnd);
748 typedef PSZ XWPENTRY WINHQUERYWINDOWFONT(HWND hwnd);
749 typedef WINHQUERYWINDOWFONT *PWINHQUERYWINDOWFONT;
750
751 PCSZ XWPENTRY winhQueryDefaultFont(VOID);
752
753 BOOL XWPENTRY winhSetWindowFont(HWND hwnd, const char *pcszFont);
754 typedef BOOL XWPENTRY WINHSETWINDOWFONT(HWND hwnd, const char *pcszFont);
755 typedef WINHSETWINDOWFONT *PWINHSETWINDOWFONT;
756
757 /*
758 *@@ winhSetDlgItemFont:
759 * invokes winhSetWindowFont on a dialog
760 * item.
761 *
762 * Returns TRUE if successful or FALSE otherwise.
763 *
764 *@@added V0.9.0
765 */
766
767 #define winhSetDlgItemFont(hwnd, usId, pszFont) \
768 (winhSetWindowFont(WinWindowFromID(hwnd, usId), pszFont))
769
770 ULONG XWPENTRY winhSetControlsFont(HWND hwndDlg, SHORT usIDMin, SHORT usIDMax, const char *pcszFont);
771
772 #ifdef INCL_WINSYS
773 BOOL XWPENTRY winhStorePresParam(PPRESPARAMS *pppp,
774 ULONG ulAttrType,
775 ULONG cbData,
776 PVOID pData);
777
778 PPRESPARAMS XWPENTRY winhCreateDefaultPresparams(VOID);
779 #endif
780
781 LONG XWPENTRY winhQueryPresColor(HWND hwnd, ULONG ulPP, BOOL fInherit, LONG lSysColor);
782 typedef LONG XWPENTRY WINHQUERYPRESCOLOR(HWND hwnd, ULONG ulPP, BOOL fInherit, LONG lSysColor);
783 typedef WINHQUERYPRESCOLOR *PWINHQUERYPRESCOLOR;
784
785 LONG XWPENTRY winhQueryPresColor2(HWND hwnd,
786 ULONG ulppRGB,
787 ULONG ulppIndex,
788 BOOL fInherit,
789 LONG lSysColor);
790
791 BOOL XWPENTRY winhSetPresColor(HWND hwnd, ULONG ulIndex, LONG lColor);
792
793 /* ******************************************************************
794 *
795 * Help instance helpers
796 *
797 ********************************************************************/
798
799 #ifdef INCL_WINHELP
800 HWND XWPENTRY winhCreateHelp(HWND hwndFrame,
801 const char *pcszFileName,
802 HMODULE hmod,
803 PHELPTABLE pHelpTable,
804 const char *pcszWindowTitle);
805
806 ULONG winhDisplayHelpPanel(HWND hwndHelpInstance,
807 ULONG ulHelpPanel);
808
809 void XWPENTRY winhDestroyHelp(HWND hwndHelp, HWND hwndFrame);
810 #endif
811
812 /* ******************************************************************
813 *
814 * Application control
815 *
816 ********************************************************************/
817
818 BOOL XWPENTRY winhAnotherInstance(const char *pcszSemName, BOOL fSwitch);
819
820 HSWITCH XWPENTRY winhAddToTasklist(HWND hwnd, HPOINTER hIcon);
821
822 /* ******************************************************************
823 *
824 * Miscellaneous
825 *
826 ********************************************************************/
827
828 VOID XWPENTRY winhFree(PVOID p);
829 typedef VOID XWPENTRY WINHFREE(PVOID p);
830 typedef WINHFREE *PWINHFREE;
831
832 /*
833 *@@ winhMyAnchorBlock:
834 * returns the HAB of the current thread.
835 *
836 * Many Win* functions require an HAB to be
837 * passed in. While many of them will work
838 * when passing in NULLHANDLE, some (such as
839 * WinGetMsg) won't. If you don't know the
840 * anchor block of the calling thread, use
841 * this function.
842 *
843 * The HAB is simply a LONG whose hiword has
844 * the current PID and the lowword has the
845 * current TID. The previous function that
846 * created a temporary window to figure this
847 * out has been replaced with this macro, since
848 * WinQueryAnchorBlock(HWND_DESKTOP) yields the
849 * same result.
850 *
851 *@@added V1.0.1 (2002-11-30) [umoeller]
852 */
853
854 #define winhMyAnchorBlock() WinQueryAnchorBlock(HWND_DESKTOP)
855
856 /*
857 HAB XWPENTRY winhMyAnchorBlock(VOID);
858 typedef HAB XWPENTRY WINHMYANCHORBLOCK(VOID);
859 typedef WINHMYANCHORBLOCK *PWINHMYANCHORBLOCK;
860 */
861
862 VOID XWPENTRY winhSleep(ULONG ulSleep);
863
864 #define WINH_FOD_SAVEDLG 0x0001
865 #define WINH_FOD_INILOADDIR 0x0010
866 #define WINH_FOD_INISAVEDIR 0x0020
867
868 BOOL XWPENTRY winhFileDlg(HWND hwndOwner,
869 PSZ pszFile,
870 ULONG flFlags,
871 HINI hini,
872 const char *pcszApplication,
873 const char *pcszKey);
874
875 HPOINTER XWPENTRY winhQueryWaitPointer(VOID);
876
877 HPOINTER XWPENTRY winhSetWaitPointer(VOID);
878
879 PSZ XWPENTRY winhQueryWindowText(HWND hwnd);
880
881 BOOL XWPENTRY winhSetWindowText(HWND hwnd,
882 const char *pcszFormat,
883 ...);
884
885 /*
886 *@@ winhQueryDlgItemText:
887 * like winhQueryWindowText, but for the dialog item
888 * in hwnd which has the ID usItemID.
889 */
890
891 #define winhQueryDlgItemText(hwnd, usItemID) winhQueryWindowText(WinWindowFromID(hwnd, usItemID))
892
893 BOOL XWPENTRY winhReplaceWindowText(HWND hwnd,
894 const char *pcszSearch,
895 const char *pcszReplaceWith);
896
897 ULONG XWPENTRY winhCenteredDlgBox(HWND hwndParent, HWND hwndOwner,
898 PFNWP pfnDlgProc, HMODULE hmod, ULONG idDlg, PVOID pCreateParams);
899 typedef ULONG XWPENTRY WINHCENTEREDDLGBOX(HWND hwndParent, HWND hwndOwner,
900 PFNWP pfnDlgProc, HMODULE hmod, ULONG idDlg, PVOID pCreateParams);
901 typedef WINHCENTEREDDLGBOX *PWINHCENTEREDDLGBOX;
902
903 ULONG XWPENTRY winhEnableControls(HWND hwndDlg,
904 USHORT usIDFirst,
905 USHORT usIDLast,
906 BOOL fEnable);
907
908 ULONG winhEnableControls2(HWND hwndDlg,
909 const ULONG *paulIDs,
910 ULONG cIDs,
911 BOOL fEnable);
912
913 HWND XWPENTRY winhCreateStdWindow(HWND hwndFrameParent,
914 PSWP pswpFrame,
915 ULONG flFrameCreateFlags,
916 ULONG ulFrameStyle,
917 const char *pcszFrameTitle,
918 ULONG ulResourcesID,
919 const char *pcszClassClient,
920 ULONG flStyleClient,
921 ULONG ulID,
922 PVOID pClientCtlData,
923 PHWND phwndClient);
924
925 HWND XWPENTRY winhCreateObjectWindow(const char *pcszWindowClass,
926 PVOID pvCreateParam);
927
928 HWND XWPENTRY winhCreateControl(HWND hwndParent,
929 HWND hwndOwner,
930 const char *pcszClass,
931 const char *pcszText,
932 ULONG ulStyle,
933 ULONG ulID);
934
935 VOID XWPENTRY winhRepaintWindows(HWND hwndParent);
936
937 HMQ XWPENTRY winhFindMsgQueue(PID pid, TID tid, HAB* phab);
938
939 VOID XWPENTRY winhFindPMErrorWindows(HWND *phwndHardError, HWND *phwndSysError);
940
941 HWND XWPENTRY winhCreateFakeDesktop(HWND hwndSibling);
942
943 // Warp 4 notebook button style
944 #ifndef BS_NOTEBOOKBUTTON
945 #define BS_NOTEBOOKBUTTON 8L
946 #endif
947
948 BOOL XWPENTRY winhAssertWarp4Notebook(HWND hwndDlg,
949 USHORT usIdThreshold);
950
951 ULONG XWPENTRY winhDrawFormattedText(HPS hps, PRECTL prcl, const char *pcszText, ULONG flCmd);
952
953 #ifdef INCL_WINSWITCHLIST
954 PSWBLOCK XWPENTRY winhQuerySwitchList(HAB hab);
955 typedef PSWBLOCK XWPENTRY WINHQUERYSWITCHLIST(HAB hab);
956 typedef WINHQUERYSWITCHLIST *PWINHQUERYSWITCHLIST;
957
958 HSWITCH XWPENTRY winhHSWITCHfromHAPP(HAPP happ);
959 #endif
960
961 HWND XWPENTRY winhQueryTasklistWindow(VOID);
962 typedef HWND XWPENTRY WINHQUERYTASKLISTWINDOW(VOID);
963 typedef WINHQUERYTASKLISTWINDOW *PWINHQUERYTASKLISTWINDOW;
964
965 VOID XWPENTRY winhKillTasklist(VOID);
966
967 ULONG XWPENTRY winhQueryPendingSpoolJobs(VOID);
968
969 VOID XWPENTRY winhSetNumLock(BOOL fState);
970
971 BOOL XWPENTRY winhSetClipboardText(HAB hab,
972 PCSZ pcsz,
973 ULONG cbSize);
974
975 /* ******************************************************************
976 *
977 * WPS Class List helpers
978 *
979 ********************************************************************/
980
981 PBYTE XWPENTRY winhQueryWPSClassList(VOID);
982
983 PBYTE XWPENTRY winhQueryWPSClass(PBYTE pObjClass, const char *pszClass);
984
985 APIRET XWPENTRY winhRegisterClass(const char* pcszClassName,
986 const char* pcszModule,
987 PSZ pszBuf,
988 ULONG cbBuf);
989
990 BOOL XWPENTRY winhIsClassRegistered(const char *pcszClass);
991
992 ULONG XWPENTRY winhResetWPS(HAB hab);
993
994#endif
995
996#if __cplusplus
997}
998#endif
999
Note: See TracBrowser for help on using the repository browser.