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

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

Sources as of 1.0.1.

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