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

Last change on this file since 346 was 346, checked in by pr, 19 years ago

Fix winhStoreWindowPos() Bug 903.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 45.0 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-2006 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 occurred 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 // V1.0.6 (2006-10-28) [pr]
766 // V1.0.7 (2006-12-16) [pr]: Named screen width/height parameters
767
768 /*
769 *@@ STOREPOS:
770 *
771 */
772
773 #pragma pack(2)
774 typedef struct _STOREPOS
775 {
776 USHORT usMagic; // Always 0x7B6A (???)
777 ULONG ulFlags;
778 USHORT usXPos;
779 USHORT usYPos;
780 USHORT usWidth;
781 USHORT usHeight;
782 ULONG ulRes1; // Always 1 (???)
783 USHORT usRestoreXPos;
784 USHORT usRestoreYPos;
785 USHORT usRestoreWidth;
786 USHORT usRestoreHeight;
787 ULONG ulRes2; // Always 1 (???)
788 USHORT usMinXPos;
789 USHORT usMinYPos;
790 ULONG ulScreenWidth;
791 ULONG ulScreenHeight;
792 ULONG ulRes3; // Always 0xFFFFFFFF (???)
793 ULONG ulRes4; // Always 0xFFFFFFFF (???)
794 ULONG ulPPLen; // Presentation Parameters length
795 } STOREPOS, *PSTOREPOS;
796 #pragma pack()
797
798 #pragma import(WinGetFrameTreePPSize, , "PMWIN", 972)
799 #pragma import(WinGetFrameTreePPs, , "PMWIN", 973)
800
801 ULONG APIENTRY WinGetFrameTreePPSize(HWND hwnd);
802 ULONG APIENTRY WinGetFrameTreePPs(HWND hwnd, ULONG cchMax, PCH pch);
803
804 BOOL XWPENTRY winhStoreWindowPos(HWND hwnd, HINI hIni, const char *pcszApp, const char *pcszKey);
805
806 #define XAC_MOVEX 0x0001
807 #define XAC_MOVEY 0x0002
808 #define XAC_SIZEX 0x0004
809 #define XAC_SIZEY 0x0008
810
811 /*
812 *@@ XADJUSTCTRLS:
813 *
814 */
815
816 typedef struct _XADJUSTCTRLS
817 {
818 BOOL fInitialized;
819 SWP swpMain; // SWP for main window
820 SWP *paswp; // pointer to array of control SWP structs
821 } XADJUSTCTRLS, *PXADJUSTCTRLS;
822
823 BOOL XWPENTRY winhAdjustControls(HWND hwndDlg,
824 const MPARAM *pmpFlags,
825 ULONG ulCount,
826 PSWP pswpNew,
827 PXADJUSTCTRLS pxac);
828
829 void XWPENTRY winhCenterWindow(HWND hwnd);
830 typedef void XWPENTRY WINHCENTERWINDOW(HWND hwnd);
831 typedef WINHCENTERWINDOW *PWINHCENTERWINDOW;
832
833 #define PLF_SMART 0x0001
834
835 BOOL winhPlaceBesides(HWND hwnd,
836 HWND hwndRelative,
837 ULONG fl);
838
839 HWND XWPENTRY winhFindWindowBelow(HWND hwndFind);
840
841 /* ******************************************************************
842 *
843 * Presparams helpers
844 *
845 ********************************************************************/
846
847 PSZ XWPENTRY winhQueryWindowFont(HWND hwnd);
848 typedef PSZ XWPENTRY WINHQUERYWINDOWFONT(HWND hwnd);
849 typedef WINHQUERYWINDOWFONT *PWINHQUERYWINDOWFONT;
850
851 PCSZ XWPENTRY winhQueryDefaultFont(VOID);
852
853 PSZ XWPENTRY winhQueryMenuSysFont(VOID);
854
855 BOOL XWPENTRY winhSetWindowFont(HWND hwnd, const char *pcszFont);
856 typedef BOOL XWPENTRY WINHSETWINDOWFONT(HWND hwnd, const char *pcszFont);
857 typedef WINHSETWINDOWFONT *PWINHSETWINDOWFONT;
858
859 /*
860 *@@ winhSetDlgItemFont:
861 * invokes winhSetWindowFont on a dialog
862 * item.
863 *
864 * Returns TRUE if successful or FALSE otherwise.
865 *
866 *@@added V0.9.0
867 */
868
869 #define winhSetDlgItemFont(hwnd, usId, pszFont) \
870 (winhSetWindowFont(WinWindowFromID(hwnd, usId), pszFont))
871
872 ULONG XWPENTRY winhSetControlsFont(HWND hwndDlg, SHORT usIDMin, SHORT usIDMax, const char *pcszFont);
873
874 #ifdef INCL_WINSYS
875 BOOL XWPENTRY winhStorePresParam(PPRESPARAMS *pppp,
876 ULONG ulAttrType,
877 ULONG cbData,
878 PVOID pData);
879
880 PPRESPARAMS XWPENTRY winhCreateDefaultPresparams(VOID);
881 #endif
882
883 LONG XWPENTRY winhQueryPresColor(HWND hwnd, ULONG ulPP, BOOL fInherit, LONG lSysColor);
884 typedef LONG XWPENTRY WINHQUERYPRESCOLOR(HWND hwnd, ULONG ulPP, BOOL fInherit, LONG lSysColor);
885 typedef WINHQUERYPRESCOLOR *PWINHQUERYPRESCOLOR;
886
887 LONG XWPENTRY winhQueryPresColor2(HWND hwnd,
888 ULONG ulppRGB,
889 ULONG ulppIndex,
890 BOOL fInherit,
891 LONG lSysColor);
892
893 BOOL XWPENTRY winhSetPresColor(HWND hwnd, ULONG ulIndex, LONG lColor);
894
895 /* ******************************************************************
896 *
897 * Help instance helpers
898 *
899 ********************************************************************/
900
901 #ifdef INCL_WINHELP
902 HWND XWPENTRY winhCreateHelp(HWND hwndFrame,
903 const char *pcszFileName,
904 HMODULE hmod,
905 PHELPTABLE pHelpTable,
906 const char *pcszWindowTitle);
907
908 ULONG winhDisplayHelpPanel(HWND hwndHelpInstance,
909 ULONG ulHelpPanel);
910
911 void XWPENTRY winhDestroyHelp(HWND hwndHelp, HWND hwndFrame);
912 #endif
913
914 /* ******************************************************************
915 *
916 * Application control
917 *
918 ********************************************************************/
919
920 BOOL XWPENTRY winhAnotherInstance(const char *pcszSemName, BOOL fSwitch);
921
922 HSWITCH XWPENTRY winhAddToTasklist(HWND hwnd, HPOINTER hIcon);
923
924 BOOL XWPENTRY winhUpdateTasklist(HWND hwnd, PCSZ pcszNewTitle);
925
926 /* ******************************************************************
927 *
928 * Miscellaneous
929 *
930 ********************************************************************/
931
932 VOID XWPENTRY winhFree(PVOID p);
933 typedef VOID XWPENTRY WINHFREE(PVOID p);
934 typedef WINHFREE *PWINHFREE;
935
936 /*
937 *@@ winhMyAnchorBlock:
938 * returns the HAB of the current thread.
939 *
940 * Many Win* functions require an HAB to be
941 * passed in. While many of them will work
942 * when passing in NULLHANDLE, some (such as
943 * WinGetMsg) won't. If you don't know the
944 * anchor block of the calling thread, use
945 * this function.
946 *
947 * The HAB is simply a LONG whose hiword has
948 * the current PID and the lowword has the
949 * current TID. The previous function that
950 * created a temporary window to figure this
951 * out has been replaced with this macro, since
952 * WinQueryAnchorBlock(HWND_DESKTOP) yields the
953 * same result.
954 *
955 *@@added V1.0.1 (2002-11-30) [umoeller]
956 */
957
958 #define winhMyAnchorBlock() WinQueryAnchorBlock(HWND_DESKTOP)
959
960 /*
961 HAB XWPENTRY winhMyAnchorBlock(VOID);
962 typedef HAB XWPENTRY WINHMYANCHORBLOCK(VOID);
963 typedef WINHMYANCHORBLOCK *PWINHMYANCHORBLOCK;
964 */
965
966 VOID XWPENTRY winhSleep(ULONG ulSleep);
967
968 #define WINH_FOD_SAVEDLG 0x0001
969 #define WINH_FOD_INILOADDIR 0x0010
970 #define WINH_FOD_INISAVEDIR 0x0020
971
972 BOOL XWPENTRY winhFileDlg(HWND hwndOwner,
973 PSZ pszFile,
974 ULONG flFlags,
975 HINI hini,
976 const char *pcszApplication,
977 const char *pcszKey);
978
979 HPOINTER XWPENTRY winhQueryWaitPointer(VOID);
980
981 HPOINTER XWPENTRY winhSetWaitPointer(VOID);
982
983 PSZ XWPENTRY winhQueryWindowText2(HWND hwnd,
984 PULONG pulExtra);
985
986 PSZ XWPENTRY winhQueryWindowText(HWND hwnd);
987
988 BOOL XWPENTRY winhSetWindowText(HWND hwnd,
989 const char *pcszFormat,
990 ...);
991
992 PSZ XWPENTRY winhQueryDlgItemText2(HWND hwnd,
993 USHORT usItemID,
994 PULONG pulExtra);
995
996 /*
997 *@@ winhQueryDlgItemText:
998 * like winhQueryWindowText, but for the dialog item
999 * in hwnd which has the ID usItemID.
1000 *
1001 *@@changed V1.0.1 (2003-01-05) [umoeller]: now using winhQueryDlgItemText2
1002 */
1003
1004 #define winhQueryDlgItemText(hwnd, usItemID) winhQueryDlgItemText2(hwnd, usItemID, NULL)
1005
1006 BOOL XWPENTRY winhAppendWindowEllipseText(HWND hwnd);
1007
1008 BOOL XWPENTRY winhAppendDlgItemEllipseText(HWND hwnd,
1009 USHORT usItemID);
1010
1011 BOOL XWPENTRY winhReplaceWindowText(HWND hwnd,
1012 const char *pcszSearch,
1013 const char *pcszReplaceWith);
1014
1015 ULONG XWPENTRY winhCenteredDlgBox(HWND hwndParent, HWND hwndOwner,
1016 PFNWP pfnDlgProc, HMODULE hmod, ULONG idDlg, PVOID pCreateParams);
1017 typedef ULONG XWPENTRY WINHCENTEREDDLGBOX(HWND hwndParent, HWND hwndOwner,
1018 PFNWP pfnDlgProc, HMODULE hmod, ULONG idDlg, PVOID pCreateParams);
1019 typedef WINHCENTEREDDLGBOX *PWINHCENTEREDDLGBOX;
1020
1021 ULONG XWPENTRY winhEnableControls(HWND hwndDlg,
1022 USHORT usIDFirst,
1023 USHORT usIDLast,
1024 BOOL fEnable);
1025
1026 ULONG winhEnableControls2(HWND hwndDlg,
1027 const ULONG *paulIDs,
1028 ULONG cIDs,
1029 BOOL fEnable);
1030
1031 HWND XWPENTRY winhCreateStdWindow(HWND hwndFrameParent,
1032 PSWP pswpFrame,
1033 ULONG flFrameCreateFlags,
1034 ULONG ulFrameStyle,
1035 const char *pcszFrameTitle,
1036 ULONG ulResourcesID,
1037 const char *pcszClassClient,
1038 ULONG flStyleClient,
1039 ULONG ulID,
1040 PVOID pClientCtlData,
1041 PHWND phwndClient);
1042
1043 HWND XWPENTRY winhCreateObjectWindow(const char *pcszWindowClass,
1044 PVOID pvCreateParam);
1045
1046 HWND XWPENTRY winhCreateControl(HWND hwndParent,
1047 HWND hwndOwner,
1048 const char *pcszClass,
1049 const char *pcszText,
1050 ULONG ulStyle,
1051 ULONG ulID);
1052
1053 BOOL XWPENTRY winhSetParentAndOwner(HWND hwnd,
1054 HWND hwndNewParent,
1055 BOOL fRedraw);
1056
1057 VOID XWPENTRY winhRepaintWindows(HWND hwndParent);
1058
1059 HMQ XWPENTRY winhFindMsgQueue(PID pid, TID tid, HAB* phab);
1060
1061 VOID XWPENTRY winhFindPMErrorWindows(HWND *phwndHardError, HWND *phwndSysError);
1062
1063 HWND XWPENTRY winhCreateFakeDesktop(HWND hwndSibling);
1064
1065 // Warp 4 notebook button style
1066 #ifndef BS_NOTEBOOKBUTTON
1067 #define BS_NOTEBOOKBUTTON 8L
1068 #endif
1069
1070 BOOL XWPENTRY winhAssertWarp4Notebook(HWND hwndDlg,
1071 USHORT usIdThreshold);
1072
1073 ULONG XWPENTRY winhDrawFormattedText(HPS hps, PRECTL prcl, const char *pcszText, ULONG flCmd);
1074
1075 #ifdef INCL_WINSWITCHLIST
1076 PSWBLOCK XWPENTRY winhQuerySwitchList(HAB hab);
1077 typedef PSWBLOCK XWPENTRY WINHQUERYSWITCHLIST(HAB hab);
1078 typedef WINHQUERYSWITCHLIST *PWINHQUERYSWITCHLIST;
1079
1080 HSWITCH XWPENTRY winhHSWITCHfromHAPP(HAPP happ);
1081 #endif
1082
1083 HWND XWPENTRY winhQueryTasklistWindow(VOID);
1084 typedef HWND XWPENTRY WINHQUERYTASKLISTWINDOW(VOID);
1085 typedef WINHQUERYTASKLISTWINDOW *PWINHQUERYTASKLISTWINDOW;
1086
1087 VOID XWPENTRY winhKillTasklist(VOID);
1088
1089 ULONG XWPENTRY winhQueryPendingSpoolJobs(VOID);
1090
1091 VOID XWPENTRY winhSetNumLock(BOOL fState);
1092
1093 BOOL XWPENTRY winhSetClipboardText(HAB hab,
1094 PCSZ pcsz,
1095 ULONG cbSize);
1096
1097 /* ******************************************************************
1098 *
1099 * WPS Class List helpers
1100 *
1101 ********************************************************************/
1102
1103 PBYTE XWPENTRY winhQueryWPSClassList(VOID);
1104
1105 PBYTE XWPENTRY winhQueryWPSClass(PBYTE pObjClass, const char *pszClass);
1106
1107 APIRET XWPENTRY winhRegisterClass(const char* pcszClassName,
1108 const char* pcszModule,
1109 PSZ pszBuf,
1110 ULONG cbBuf);
1111
1112 BOOL XWPENTRY winhIsClassRegistered(const char *pcszClass);
1113
1114 extern BOOL32 APIENTRY WinRestartWorkplace(void);
1115
1116 ULONG XWPENTRY winhResetWPS(HAB hab);
1117
1118#endif
1119
1120#if __cplusplus
1121}
1122#endif
1123
Note: See TracBrowser for help on using the repository browser.