OWLNext
7.0
Borland's Object Windows Library for the modern age
Toggle main menu visibility
Loading...
Searching...
No Matches
menu.h
Go to the documentation of this file.
1
//----------------------------------------------------------------------------
2
// ObjectWindows
3
// Copyright (c) 1991, 1996 by Borland International, All Rights Reserved
4
//
5
/// \file
6
/// Definition of Window Menu encapsulation class
7
//----------------------------------------------------------------------------
8
9
#if !defined(OWL_MENU_H)
10
#define OWL_MENU_H
11
12
#include <
owl/private/defs.h
>
13
#if defined(BI_HAS_PRAGMA_ONCE)
14
# pragma once
15
#endif
16
17
#include <
owl/gdiobjec.h
>
18
#include <
owl/wsyscls.h
>
19
20
21
namespace
owl
{
22
23
#include <
owl/preclass.h
>
24
25
/// \addtogroup menus
26
/// @{
27
28
class
_OWLCLASS
TXMenu
;
29
class
_OWLCLASS
TMenu
;
30
31
//
32
/// Represents an unsigned integer or handle which identifies a new menu item.
33
//
34
typedef
UINT_PTR
TMenuItem
;
35
36
// All-including mask for MENUITEMINFO
37
//
38
#if !defined(MIIM_ALL)
39
# define MIIM_ALL (MIIM_CHECKMARKS|MIIM_DATA|MIIM_ID|MIIM_STATE|MIIM_SUBMENU|MIIM_TYPE)
40
#endif
41
42
43
//
44
/// \class TMenuItemInfo
45
// ~~~~~ ~~~~~~~~~~~~~
46
class
_OWLCLASS
TMenuItemInfo
:
public
MENUITEMINFO {
47
public
:
48
TMenuItemInfo
(
uint
msk = 0);
49
50
/// Construct MENUITEMINFO from a specific item of a menu object.
51
/// Defaults to retrieving all information except for the type, which
52
/// require a destination buffer.
53
//
54
TMenuItemInfo
(
TMenu
& menu,
uint
posOrId,
bool
isPos,
55
uint
msk = MIIM_CHECKMARKS|MIIM_DATA|
56
MIIM_ID|MIIM_STATE|MIIM_SUBMENU);
57
58
/// Construct MENUITEMINFO from a specific item of a menu object.
59
/// Similar to prior except that it also retrieves the type data.
60
//
61
TMenuItemInfo
(
TMenu
& menu,
uint
posOrId,
bool
isPos,
void
* buffer,
62
uint
size,
uint
msk =
MIIM_ALL
);
63
};
64
65
66
//
67
/// \class TMenu
68
// ~~~~~ ~~~~~
69
/// The TMenu class encapsulates window menus. You can use TMenu member functions to
70
/// construct, modify, query, and create menu objects. You can also use TMenu to add
71
/// bitmaps to your menu or to specify if a menu item is checked or unchecked. TMenu
72
/// includes two versions of a helper function, DeepCopy , designed to make copies
73
/// of menus and insert them at a specified position on the menu bar. See the
74
/// ObjectWindows Programmer's Guide for information about how to create menu
75
/// objects.
76
//
77
class
_OWLCLASS
TMenu
{
78
public
:
79
TMenu
(
TAutoDelete
autoDelete =
AutoDelete
);
80
TMenu
(
const
TMenu
& original,
TAutoDelete
autoDelete =
AutoDelete
);
81
TMenu
(HMENU handle,
TAutoDelete
autoDelete =
NoAutoDelete
);
82
TMenu
(HWND hWnd,
TAutoDelete
autoDelete =
NoAutoDelete
);
83
TMenu
(
const
void
* menuTemplate);
84
TMenu
(HINSTANCE instance,
TResId
resId);
85
virtual
~TMenu
();
86
87
TMenu
& operator =(
const
TMenu
&);
88
89
void
CheckValid
(
uint
redId = IDS_MENUFAILURE);
90
virtual
HMENU
GetHandle
()
const
;
91
92
operator
TMenuItem
()
const
;
93
operator
HMENU()
const
;
94
95
bool
IsOK
()
const
;
96
97
/// \name HMENU encapsulated functions
98
/// @{
99
bool
AppendMenu
(
uint
flags,
TMenuItem
newItem=
static_cast<
unsigned
int
>
(-1), LPCTSTR newStr=
nullptr
);
//JJH added static cast
100
bool
AppendMenu
(
uint
flags,
TMenuItem
newItem,
const
tstring
& newStr) {
return
AppendMenu
(flags, newItem, newStr.c_str());}
101
bool
AppendMenu(
uint
flags,
TMenuItem
newitem,
const
TBitmap
& newBmp);
102
bool
CheckMenuItem(
uint
item,
uint
check);
103
bool
DeleteMenu(
uint
item,
uint
flags);
104
bool
EnableMenuItem(
uint
item,
uint
enable);
105
uint
GetMenuItemCount()
const
;
106
uint
GetMenuItemID(
int
posItem)
const
;
107
uint
GetMenuState(
uint
item,
uint
flags)
const
;
108
int
GetMenuString(
uint
item, LPTSTR str,
int
count,
uint
flags)
const
;
109
tstring
GetMenuString(
uint
item,
uint
flags)
const
;
110
HMENU GetSubMenu(
int
posItem)
const
;
111
bool
InsertMenu(
uint
item,
uint
flags,
TMenuItem
newItem=-1, LPCTSTR newStr =
nullptr
);
112
bool
InsertMenu
(
uint
item,
uint
flags,
TMenuItem
newItem,
const
tstring
& newStr) {
return
InsertMenu
(item, flags, newItem, newStr.c_str());}
113
bool
InsertMenu(
uint
item,
uint
flags,
TMenuItem
newItem,
const
TBitmap
& newBmp);
114
bool
ModifyMenu(
uint
item,
uint
flags,
TMenuItem
newItem=-1, LPCTSTR newStr =
nullptr
);
115
bool
ModifyMenu
(
uint
item,
uint
flags,
TMenuItem
newItem,
const
tstring
& newStr) {
return
ModifyMenu
(item, flags, newItem, newStr.c_str());}
116
bool
ModifyMenu(
uint
item,
uint
flags,
TMenuItem
newItem,
const
TBitmap
& newBmp);
117
bool
RemoveMenu(
uint
item,
uint
flags);
118
bool
SetMenuItemBitmaps(
uint
item,
uint
flags,
119
const
TBitmap
* bmpUnchecked=
nullptr
,
120
const
TBitmap
* bmpChecked=
nullptr
);
121
/// @}
122
123
/// \name Encapsulation of new functionality introduced with Win95
124
/// @{
125
uint
GetDefaultItem(
bool
getPos,
uint
flags)
const
;
126
bool
SetDefaultItem(
uint
posOrId,
bool
isPos);
127
bool
CheckRadioItem(
uint
first,
uint
last,
uint
check,
uint
flags);
128
/// @}
129
130
/// \name MENUITEMINFO related API
131
/// @{
132
bool
GetMenuItemInfo(
uint
posOrId,
bool
isPos,
TMenuItemInfo
& mi)
const
;
133
bool
SetMenuItemInfo(
uint
posOrId,
bool
isPos,
TMenuItemInfo
& mi);
134
bool
InsertMenuItem(
uint
posOrId,
bool
isPos,
TMenuItemInfo
& mi);
135
/// @}
136
137
static
bool
GetMenuCheckMarkDimensions(
TSize
& size);
138
static
TSize
GetMenuCheckMarkDimensions();
139
140
/// \name Virtual menu functions
141
/// @{
142
virtual
void
MeasureItem(MEASUREITEMSTRUCT & measureItem);
143
virtual
void
DrawItem(DRAWITEMSTRUCT & drawItem);
144
/// @}
145
146
protected
:
147
static
void
DeepCopy(
TMenu
& dst,
const
TMenu
& src,
int
srcOffset = 0,
int
itemCount = -1);
148
static
void
DeepCopy(
TMenu
& dst,
int
dstOffset,
const
TMenu
& src,
int
srcOffset = 0,
int
itemCount = -1);
149
150
protected_data
:
151
HMENU Handle;
///< Holds the handle to the menu.
152
bool
ShouldDelete;
///< ShouldDelete is set to true if the Destructor needs to delete the handle to the menu.
153
};
154
155
//
156
/// \class TXMenu
157
// ~~~~~ ~~~~~~
158
/// A nested class, TXMenu describes an exception that occurs when a menu item
159
/// cannot be constructed.
160
class
_OWLCLASS
TXMenu
:
public
TXOwl
{
161
public
:
162
TXMenu
(
uint
resId = IDS_MENUFAILURE);
163
164
TXMenu
*
Clone
();
165
void
Throw
();
166
167
static
void
Raise
(
uint
resId = IDS_MENUFAILURE);
168
};
169
170
//
171
/// \class TSystemMenu
172
// ~~~~~ ~~~~~~~~~~~
173
/// TSystemMenu creates a system menu object that then becomes the existing system
174
/// menu.
175
class
_OWLCLASS
TSystemMenu
:
public
TMenu
{
176
public
:
177
TSystemMenu
(HWND wnd,
bool
revert=
false
);
178
179
private
:
180
TSystemMenu
();
181
TSystemMenu
(
const
TSystemMenu
&);
182
};
183
184
//
185
/// \class TPopupMenu
186
// ~~~~~ ~~~~~~~~~~
187
/// TPopupMenu creates an empty pop-up menu to add to an existing window or pop-up
188
/// menu.
189
class
_OWLCLASS
TPopupMenu
:
public
TMenu
{
190
public
:
191
TPopupMenu
(
TAutoDelete
autoDelete =
AutoDelete
);
192
TPopupMenu
(HMENU handle,
TAutoDelete
autoDelete =
NoAutoDelete
);
193
TPopupMenu
(
const
TMenu
& menu,
TAutoDelete
autoDelete =
AutoDelete
);
194
int
TrackPopupMenu
(
uint
flags,
int
x,
int
y,
int
rsvd, HWND wnd,
const
TRect
* rect=
nullptr
);
195
int
TrackPopupMenu
(
uint
flags,
const
TPoint
& point,
int
rsvd, HWND wnd,
const
TRect
* rect=
nullptr
);
196
197
private
:
198
TPopupMenu
(
const
TPopupMenu
&);
199
};
200
201
//
202
/// \class TMenuDescr
203
// ~~~~~ ~~~~~~~~~~
204
/// Menu with information used to allow merging
205
//
206
class
_OWLCLASS
TMenuDescr
:
public
TMenu
{
207
public
:
208
/// Used by TMenuDescr, the TGroup enum describes the following constants that
209
/// define the index of the entry in the GroupCount array.
210
enum
TGroup
{
211
FileGroup
,
///< Index of the File menu group count
212
EditGroup
,
///< Index of the Edit menu group count
213
ContainerGroup
,
///< Index of the Container menu group count
214
ObjectGroup
,
///< Index of the Object group count
215
WindowGroup
,
///< Index of the Window menu group count
216
HelpGroup
,
///< Index of the Help menu group count
217
NumGroups
///< Total number of groups
218
};
219
TMenuDescr
();
220
TMenuDescr
(
const
TMenuDescr
& original);
221
TMenuDescr
(
TResId
id
,
int
fg,
int
eg,
int
cg,
int
og,
int
wg,
int
hg,
222
TModule
* module = &
GetGlobalModule
());
223
TMenuDescr
(
TResId
id
,
TModule
* module = &
GetGlobalModule
());
224
TMenuDescr
(HMENU hMenu,
int
fg,
int
eg,
int
cg,
int
og,
int
wg,
int
hg,
225
TModule
* module = &
GetGlobalModule
());
226
~TMenuDescr
();
227
228
TMenuDescr
& operator =(
const
TMenuDescr
& original);
229
230
HMENU GetHandle()
const
;
231
TModule
* GetModule()
const
;
232
void
SetModule(
TModule
* module);
233
TResId
GetId()
const
;
234
int
GetGroupCount(
int
group)
const
;
235
236
void
ClearServerGroupCount
();
///< Not implemented?
237
void
ClearContainerGroupCount
();
///< Not implemented?
238
239
bool
Merge
(
const
TMenuDescr
& sourceMenuDescr);
240
bool
Merge
(
const
TMenuDescr
& sourceMenuDescr,
TMenu
& destMenu);
241
242
protected
:
243
bool
ExtractGroups
();
244
245
protected_data
:
246
/// Points to the TModule object that owns this TMenuDescr.
247
TModule
* Module;
248
249
/// The resource ID for the menu. The resource ID is passed in the constructors to
250
/// identify the menu resource.
251
TResId
Id;
252
253
/// An array of values indicating the number of pop-up menus in each group on the
254
/// menu bar.
255
int
GroupCount[
NumGroups
];
256
257
friend
_OWLCFUNC
(
ipstream
&) operator >>(
ipstream
& is,
TMenuDescr
& m);
258
friend
_OWLCFUNC
(
opstream
&) operator <<(
opstream
& os,
const
TMenuDescr
& m);
259
};
260
261
/// @}
262
263
#include <
owl/posclass.h
>
264
265
//----------------------------------------------------------------------------
266
// Inline implementations
267
//
268
269
//
270
/// Gets the handle to the menu, possibly causing any deferred menu acquisition to
271
/// occur.
272
inline
HMENU
TMenuDescr::GetHandle
()
const
273
{
274
return
TMenu::GetHandle
();
275
}
276
277
//
278
/// Returns a pointer to the module object.
279
inline
TModule
*
TMenuDescr::GetModule
()
const
280
{
281
return
Module;
282
}
283
284
//
285
/// Sets the default module object for this menu descriptor.
286
inline
void
TMenuDescr::SetModule
(
TModule
* module)
287
{
288
Module =
module
;
289
}
290
291
//
292
/// Gets the menu resource ID used to construct the menu descriptor.
293
inline
TResId
TMenuDescr::GetId
()
const
294
{
295
return
Id;
296
}
297
298
//
299
/// Gets the number of menus in a specified group within the menu bar. There are a
300
/// maximum of six functional groups as defined by the TGroup enum. These groups
301
/// include FileGroup, EditGroup, ContainerGroup, ObjectGroup, WindowGroup, and
302
/// HelpGroup.
303
inline
int
TMenuDescr::GetGroupCount
(
int
group)
const
304
{
305
return
GroupCount[group];
306
}
307
308
//
309
/// Returns the handle to the menu.
310
inline
HMENU
TMenu::GetHandle
()
const
311
{
312
return
Handle;
313
}
314
315
//
316
/// Returns the menu's handle. This function provides compatibility with functions
317
/// that require a TMenuItem menu parameter.
318
//
319
inline
TMenu::operator
TMenuItem
()
const
320
{
321
return
reinterpret_cast<
TMenuItem
>
(
GetHandle
());
322
}
323
324
//
325
/// Returns the menu's handle.
326
inline
TMenu::operator HMENU()
const
327
{
328
return
GetHandle
();
329
}
330
331
//
332
/// Returns true if the menu has a valid handle.
333
inline
bool
TMenu::IsOK
()
const
334
{
335
return
GetHandle
() !=
nullptr
;
336
}
337
338
//
339
/// Adds a text menu item to the end of the menu. See TMenu::GetMenuState for a
340
/// description of the flag values that specify the attributes of the menu, for
341
/// example, menu item is checked, menu item is a a bitmap, and so on.
342
inline
bool
TMenu::AppendMenu
(
uint
flags,
TMenuItem
newItem, LPCTSTR newStr)
343
{
344
PRECONDITION
(Handle);
345
return ::AppendMenu(Handle, flags, newItem, newStr);
346
}
347
348
//
349
/// Adds a bitmap menu item at the end of the menu. See TMenu::GetMenuState for a
350
/// description of the flag values that specify the attributes of the menu; for
351
/// example, menu item is checked, menu item is disabled, and so on.
352
inline
bool
TMenu::AppendMenu
(
uint
flags,
TMenuItem
newItem,
const
TBitmap
& newBmp)
353
{
354
PRECONDITION
(Handle);
355
return ::AppendMenu(Handle, flags|MF_BITMAP, newItem,
356
reinterpret_cast<
LPCTSTR
>
(newBmp.
GetHandle
()));
357
}
358
359
//
360
/// Checks or unchecks the menu item. By combining flags with the bitwise OR
361
/// operator (|) check specifies both the position of item (MF_BYCOMMAND,
362
/// MF_BYPOSITION) and whether item is to be checked (MF_CHECKED) or unchecked
363
/// (MF_UNCHECKED).
364
inline
bool
TMenu::CheckMenuItem
(
uint
item,
uint
check)
365
{
366
PRECONDITION
(Handle);
367
return ::CheckMenuItem(Handle, item, check);
368
}
369
370
//
371
/// Removes the menu item (item) from the menu or deletes the menu item if it's a
372
/// pop-up menu. flags is used to identify the position of the menu item by its
373
/// relative position in the menu (MF_BYPOSITION) or by referencing the handle to
374
/// the top-level menu (MF_BYCOMMAND).
375
inline
bool
TMenu::DeleteMenu
(
uint
item,
uint
flags)
376
{
377
PRECONDITION
(Handle);
378
return ::DeleteMenu(Handle, item, flags);
379
}
380
381
//
382
/// Enables, disables, or grays the menu item specified in the item parameter. If a
383
/// menu item is enabled (the default state), it can be selected and used as usual.
384
/// If a menu item is grayed, it appears in grayed text and cannot be selected by
385
/// the user. If a menu item is disabled, it is not displayed. Returns true if
386
/// successful.
387
inline
bool
TMenu::EnableMenuItem
(
uint
item,
uint
enable)
388
{
389
PRECONDITION
(Handle);
390
return ::EnableMenuItem(Handle, item, enable);
391
}
392
393
//
394
/// Returns the number of items in a top-level or pop-up menu.
395
inline
uint
TMenu::GetMenuItemCount
()
const
396
{
397
PRECONDITION
(Handle);
398
return ::GetMenuItemCount(Handle);
399
}
400
401
//
402
/// Returns the menu flags for the menu item specified by item. flags specifies how
403
/// the item is interpreted, and is one of the following values:
404
/// - \c \b MF_BYCOMMAND Interpret item as a menu command ID. Default it neither
405
/// - \c \b MF_BYCOMMAND nor MF_BYPOSITION is specified.
406
/// - \c \b MF_BYPOSITION Interpret item as the zero-base relative postion of the menu item
407
/// within the menu.
408
///
409
/// If item is found, and is a pop-up menu, the low-order byte of the return value
410
/// contains the flags associated with item, and the high-order byte contains the
411
/// number of items in the pop-up menu. If itemis not a pop-up menu, the return
412
/// value specifies a combination of these flags:
413
///
414
/// - \c \b MF_BITMAP Menu item is a a bitmap.
415
/// - \c \b MF_CHECKED Menu item is checked (pop-up menus only).
416
/// - \c \b MF_DISABLED Menu item is disabled.
417
/// - \c \b MF_ENABLED Menu item is enabled. \note this constant's value is 0.
418
/// - \c \b MF_GRAYED Menu item is disabled and grayed.
419
/// - \c \b MF_MENUBARBREAK Same as MF_MENUBREAK except pop-up menu columns are separated by
420
/// a vertical dividing line.
421
/// - \c \b MF_MENUBREAK Static menu items are placed on a new line, pop-up menu items are
422
/// placed in a new column, without separating columns.
423
/// - \c \b MF_SEPARATOR A horizontal dividing line is drawn, which cannot be enabled,
424
/// checked, grayed, or highlighted. Both item and flags are ingonred.
425
/// - \c \b MF_UNCHECKED Menu item check mark is removed (default). \note this constant
426
/// value is 0.
427
///
428
/// Returns -1 if item doesn't exist.
429
//
430
inline
uint
TMenu::GetMenuState
(
uint
item,
uint
flags)
const
431
{
432
PRECONDITION
(Handle);
433
return ::GetMenuState(Handle, item, flags);
434
}
435
436
//
437
/// Returns the label (str) of the menu item (item).
438
inline
int
TMenu::GetMenuString
(
uint
item, LPTSTR str,
int
count,
uint
flags)
const
439
{
440
PRECONDITION
(Handle);
441
return ::GetMenuString(Handle, item, str, count, flags);
442
}
443
444
//
445
/// Returns the handle of the menu specified by posItem.
446
inline
HMENU
TMenu::GetSubMenu
(
int
posItem)
const
447
{
448
PRECONDITION
(Handle);
449
return ::GetSubMenu(Handle, posItem);
450
}
451
452
//
453
/// Inserts a new text menu item or pop-up menu into the menu after the menu item
454
/// specified in item. The flagsparameter contains either the MF_BYCOMMAND or
455
/// MF_BYPOSITION values that indicate how to interpret the item parameter. If
456
/// MF_BYCOMMAND, item is a command ID; if MF_BYPOSITION, item holds a relative
457
/// position within the menu.
458
inline
bool
TMenu::InsertMenu
(
uint
item,
uint
flags,
TMenuItem
newItem, LPCTSTR newStr)
459
{
460
PRECONDITION
(Handle);
461
return ::InsertMenu(Handle, item, flags|MF_STRING, newItem, newStr);
462
}
463
464
//
465
/// Adds a bitmap menu item after the menu item specified in item. The flags
466
/// parameter contains either the MF_BYCOMMAND or MF_BYPOSITION values that indicate
467
/// how to interpret the item parameter. If MF_BYCOMMAND, item is a command ID; if
468
/// MF_BYPOSITION, item holds a relative position within the menu.
469
inline
bool
TMenu::InsertMenu
(
uint
item,
uint
flags,
TMenuItem
newItem,
const
TBitmap
& newBmp)
470
{
471
return ::InsertMenu(Handle, item, flags|MF_BITMAP, newItem,
472
reinterpret_cast<
LPCTSTR
>
(newBmp.
GetHandle
()));
473
}
474
475
//
476
/// Changes an existing menu item from the item specified in item to newItem. The
477
/// flags parameter contains either the MF_BYCOMMAND or MF_BYPOSITION values that
478
/// indicate how to interpret the item parameter. If MF_BYCOMMAND, item is a command
479
/// ID; if MF_BYPOSITION, item holds a relative position within the menu.
480
inline
bool
TMenu::ModifyMenu
(
uint
item,
uint
flags,
TMenuItem
newItem, LPCTSTR newStr)
481
{
482
PRECONDITION
(Handle);
483
return ::ModifyMenu(Handle, item, flags|MF_STRING, newItem, newStr);
484
}
485
486
//
487
/// Changes an existing menu item into a bitmap. The flags parameter contains either
488
/// the MF_BYCOMMAND or MF_BYPOSITION values that indicate how to interpret the item
489
/// parameter. If MF_BYCOMMAND, item is a command ID; if MF_BYPOSITION, item holds a
490
/// relative position within the menu.
491
inline
bool
TMenu::ModifyMenu
(
uint
item,
uint
flags,
TMenuItem
newItem,
const
TBitmap
& newBmp)
492
{
493
PRECONDITION
(Handle);
494
return ::ModifyMenu(Handle, item, flags|MF_BITMAP, newItem,
495
reinterpret_cast<
LPCTSTR
>
(newBmp.
GetHandle
()));
496
}
497
498
//
499
/// Removes the menu item from the menu but does not delete it if it is a submenu.
500
inline
bool
TMenu::RemoveMenu
(
uint
item,
uint
flags)
501
{
502
PRECONDITION
(Handle);
503
return ::RemoveMenu(Handle, item, flags);
504
}
505
506
//
507
/// Specifies the bitmap to be displayed when the menu item is checked and
508
/// unchecked. item indicates the menu item to be associated with the bitmap. flags
509
/// indicates how the size parameter is interpreted (whether by MF_BYPOSITION or by
510
/// MF_BYCOMMAND). GetMenuCheckMarkDimensions gets the size of the bitmap.
511
inline
bool
TMenu::SetMenuItemBitmaps
(
uint
item,
uint
flags,
512
const
TBitmap
* bmpUnchecked,
513
const
TBitmap
* bmpChecked)
514
{
515
PRECONDITION
(Handle);
516
return ::SetMenuItemBitmaps(Handle, item, flags,
517
bmpUnchecked ? HBITMAP(*bmpUnchecked) :
nullptr
,
518
bmpChecked ? HBITMAP(*bmpChecked) :
nullptr
);
519
}
520
521
//
522
/// Gets the size of the bitmap used to display the default check mark on checked
523
/// menu items.
524
/// Always returns true. The size reference stores the dimensions of the checkmark
525
/// bitmaps.
526
//
527
inline
bool
TMenu::GetMenuCheckMarkDimensions
(
TSize
& size)
528
{
529
size =
TSize
(
::GetMenuCheckMarkDimensions
());
530
return
true
;
531
}
532
533
//
534
/// Return the dimensions of the check mark bitmaps.
535
//
536
inline
TSize
TMenu::GetMenuCheckMarkDimensions
()
537
{
538
return
TSize
(
::GetMenuCheckMarkDimensions
());
539
}
540
541
//
542
/// Allows the application to create a pop-up menu at the specified location in the
543
/// specified window. flags specifies a screen position and can be one of the
544
/// TPM_xxxx values (TPM_CENTERALIGN, TPM_LEFTALIGN, TPM_RIGHTALIGN, TPM_LEFTBUTTON,
545
/// or TPM_RIGHTBUTTON). wnd is the handle to the window that receives messages
546
/// about the menu. x specifies the horizontal position in screen coordinates of the
547
/// left side of the menu. y species the vertical position in screen coordinates of
548
/// the top of the menu (for example, 0,0 specifies that a menu's left corner is in
549
/// the top left corner of the screen). rect defines the area that the user can
550
/// click without dismissing the menu.
551
///
552
/// If you specify TPM_RETURNCMD in the flags parameter, the return value is the
553
/// menu-item identifier of the item that the user selected. If the user cancels
554
/// the menu without making a selection, or if an error occurs, then the return
555
/// value is zero.
556
///
557
/// If you do not specify TPM_RETURNCMD in the flags parameter, the return value
558
/// is nonzero if the function succeeds and zero if it fails. To get extended
559
/// error information, call GetLastError.
560
//
561
inline
int
TPopupMenu::TrackPopupMenu
(
uint
flags,
int
x,
int
y,
int
rsvd,
562
HWND wnd,
const
TRect
* rect)
563
{
564
PRECONDITION
(
GetHandle
());
565
return ::TrackPopupMenu(
GetHandle
(), flags, x, y, rsvd, wnd, rect);
566
}
567
568
//
569
/// TPoint-aware overload
570
//
571
inline
int
TPopupMenu::TrackPopupMenu
(
uint
flags,
const
TPoint
& point,
572
int
rsvd, HWND wnd,
const
TRect
* rect)
573
{
574
PRECONDITION
(
GetHandle
());
575
return ::TrackPopupMenu(
GetHandle
(), flags, point.x, point.y, rsvd, wnd, rect);
576
}
577
578
}
// OWL namespace
579
580
581
#endif
// OWL_MENU_H
PRECONDITION
#define PRECONDITION(condition)
Definition
checks.h:227
owl::TBitmap
TBitmap is the GDI bitmap class derived from TGdiObject.
Definition
gdiobjec.h:510
owl::TBitmap::GetHandle
HBITMAP GetHandle() const
Returns the handle of the bitmap of type BITMAP.
Definition
gdiobjec.h:1355
owl::TMenuDescr
Menu with information used to allow merging.
Definition
menu.h:206
owl::TMenuDescr::GetGroupCount
int GetGroupCount(int group) const
Gets the number of menus in a specified group within the menu bar.
Definition
menu.h:303
owl::TMenuDescr::GetHandle
HMENU GetHandle() const
Gets the handle to the menu, possibly causing any deferred menu acquisition to occur.
Definition
menu.h:272
owl::TMenuDescr::ClearContainerGroupCount
void ClearContainerGroupCount()
Not implemented?
owl::TMenuDescr::GetModule
TModule * GetModule() const
Returns a pointer to the module object.
Definition
menu.h:279
owl::TMenuDescr::TMenuDescr
TMenuDescr()
Default constructor for a TMenuDescr object.
Definition
menudesc.cpp:165
owl::TMenuDescr::ClearServerGroupCount
void ClearServerGroupCount()
Not implemented?
owl::TMenuDescr::TGroup
TGroup
Used by TMenuDescr, the TGroup enum describes the following constants that define the index of the en...
Definition
menu.h:210
owl::TMenuDescr::FileGroup
@ FileGroup
Index of the File menu group count.
Definition
menu.h:211
owl::TMenuDescr::ContainerGroup
@ ContainerGroup
Index of the Container menu group count.
Definition
menu.h:213
owl::TMenuDescr::HelpGroup
@ HelpGroup
Index of the Help menu group count.
Definition
menu.h:216
owl::TMenuDescr::NumGroups
@ NumGroups
Total number of groups.
Definition
menu.h:217
owl::TMenuDescr::ObjectGroup
@ ObjectGroup
Index of the Object group count.
Definition
menu.h:214
owl::TMenuDescr::EditGroup
@ EditGroup
Index of the Edit menu group count.
Definition
menu.h:212
owl::TMenuDescr::WindowGroup
@ WindowGroup
Index of the Window menu group count.
Definition
menu.h:215
owl::TMenuDescr::GetId
TResId GetId() const
Gets the menu resource ID used to construct the menu descriptor.
Definition
menu.h:293
owl::TMenuDescr::SetModule
void SetModule(TModule *module)
Sets the default module object for this menu descriptor.
Definition
menu.h:286
owl::TMenuDescr::ExtractGroups
bool ExtractGroups()
Extracts the group counts from the loaded menu bar by counting the number of menus between separator ...
Definition
menudesc.cpp:280
owl::TMenuDescr::Merge
bool Merge(const TMenuDescr &sourceMenuDescr)
Merges the functional groups of another menu descriptor into this menu descriptor.
Definition
menudesc.cpp:329
owl::TMenu
The TMenu class encapsulates window menus.
Definition
menu.h:77
owl::TMenu::GetMenuItemCount
uint GetMenuItemCount() const
Returns the number of items in a top-level or pop-up menu.
Definition
menu.h:395
owl::TMenu::ModifyMenu
bool ModifyMenu(uint item, uint flags, TMenuItem newItem, const tstring &newStr)
Definition
menu.h:115
owl::TMenu::ModifyMenu
bool ModifyMenu(uint item, uint flags, TMenuItem newItem=-1, LPCTSTR newStr=nullptr)
Changes an existing menu item from the item specified in item to newItem.
Definition
menu.h:480
owl::TMenu::InsertMenu
bool InsertMenu(uint item, uint flags, TMenuItem newItem=-1, LPCTSTR newStr=nullptr)
Inserts a new text menu item or pop-up menu into the menu after the menu item specified in item.
Definition
menu.h:458
owl::TMenu::InsertMenu
bool InsertMenu(uint item, uint flags, TMenuItem newItem, const tstring &newStr)
Definition
menu.h:112
owl::TMenu::RemoveMenu
bool RemoveMenu(uint item, uint flags)
Removes the menu item from the menu but does not delete it if it is a submenu.
Definition
menu.h:500
owl::TMenu::AppendMenu
bool AppendMenu(uint flags, TMenuItem newItem, const tstring &newStr)
Definition
menu.h:100
owl::TMenu::SetMenuItemBitmaps
bool SetMenuItemBitmaps(uint item, uint flags, const TBitmap *bmpUnchecked=nullptr, const TBitmap *bmpChecked=nullptr)
Specifies the bitmap to be displayed when the menu item is checked and unchecked.
Definition
menu.h:511
owl::TMenu::DeleteMenu
bool DeleteMenu(uint item, uint flags)
Removes the menu item (item) from the menu or deletes the menu item if it's a pop-up menu.
Definition
menu.h:375
owl::TMenu::TMenu
TMenu(TAutoDelete autoDelete=AutoDelete)
Creates an empty menu and sets autoDelete, by default, so that the menu is automatically deleted when...
Definition
menu.cpp:67
owl::TMenu::GetMenuState
uint GetMenuState(uint item, uint flags) const
Returns the menu flags for the menu item specified by item.
Definition
menu.h:430
owl::TMenu::CheckMenuItem
bool CheckMenuItem(uint item, uint check)
Checks or unchecks the menu item.
Definition
menu.h:364
owl::TMenu::GetMenuCheckMarkDimensions
static TSize GetMenuCheckMarkDimensions()
Return the dimensions of the check mark bitmaps.
Definition
menu.h:536
owl::TMenu::GetSubMenu
HMENU GetSubMenu(int posItem) const
Returns the handle of the menu specified by posItem.
Definition
menu.h:446
owl::TMenu::CheckValid
void CheckValid(uint redId=IDS_MENUFAILURE)
Throws a TXMenu exception if the menu object is invalid.
Definition
menu.cpp:248
owl::TMenu::GetMenuString
int GetMenuString(uint item, TCHAR *str, int count, uint flags) const
Returns the label (str) of the menu item (item).
Definition
menu.h:438
owl::TMenu::EnableMenuItem
bool EnableMenuItem(uint item, uint enable)
Enables, disables, or grays the menu item specified in the item parameter.
Definition
menu.h:387
owl::TMenu::GetMenuCheckMarkDimensions
static bool GetMenuCheckMarkDimensions(TSize &size)
Gets the size of the bitmap used to display the default check mark on checked menu items.
Definition
menu.h:527
owl::TMenu::IsOK
bool IsOK() const
Returns true if the menu has a valid handle.
Definition
menu.h:333
owl::TMenu::AppendMenu
bool AppendMenu(uint flags, TMenuItem newItem=static_cast< unsigned int >(-1), LPCTSTR newStr=nullptr)
Adds a text menu item to the end of the menu.
Definition
menu.h:342
owl::TMenu::GetHandle
virtual HMENU GetHandle() const
Returns the handle to the menu.
Definition
menu.h:310
owl::TMenuItemInfo
Definition
menu.h:46
owl::TMenuItemInfo::TMenuItemInfo
TMenuItemInfo(uint msk=0)
Definition
menu.cpp:28
owl::TModule
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition
module.h:78
owl::TPoint
TPoint is a support class, derived from tagPOINT.
Definition
geometry.h:87
owl::TPopupMenu::TPopupMenu
TPopupMenu(TAutoDelete autoDelete=AutoDelete)
Constructs an empty pop-up menu.
Definition
menu.cpp:419
owl::TPopupMenu::TrackPopupMenu
int TrackPopupMenu(uint flags, int x, int y, int rsvd, HWND wnd, const TRect *rect=nullptr)
Allows the application to create a pop-up menu at the specified location in the specified window.
Definition
menu.h:561
owl::TRect
TRect is a mathematical class derived from tagRect.
Definition
geometry.h:308
owl::TResId
Definition
wsyscls.h:206
owl::TSize
The tagSIZE struct is defined as.
Definition
geometry.h:234
owl::TSize::TSize
TSize()
Default constructor that does nothing.
Definition
geometry.h:1406
owl::TSystemMenu::TSystemMenu
TSystemMenu(HWND wnd, bool revert=false)
Constructs a system menu object.
Definition
menu.cpp:408
owl::TXMenu
A nested class, TXMenu describes an exception that occurs when a menu item cannot be constructed.
Definition
menu.h:160
owl::TXMenu::Throw
void Throw()
Throws a TXMenu exception.
Definition
menu.cpp:471
owl::TXMenu::Raise
static void Raise(uint resId=IDS_MENUFAILURE)
Creates a TXMenu exception and throws it.
Definition
menu.cpp:480
owl::TXMenu::TXMenu
TXMenu(uint resId=IDS_MENUFAILURE)
Constructs a TXMenu exception object with a default IDS_GDIFAILURE message.
Definition
menu.cpp:449
owl::TXMenu::Clone
TXMenu * Clone()
Create a copy of the TXMenu exception.
Definition
menu.cpp:461
owl::ipstream
ipstream, a specialized input stream derivative of pstream, is the base class for reading (extracting...
Definition
objstrm.h:391
owl::opstream
Base class for writing streamable objects.
Definition
objstrm.h:480
gdiobjec.h
Definition of abstract GDI object class and derived classes.
owl::TAutoDelete
TAutoDelete
Flag for Handle ctors to control Handle deletion in dtor.
Definition
gdibase.h:70
owl::AutoDelete
@ AutoDelete
Definition
gdibase.h:70
owl::NoAutoDelete
@ NoAutoDelete
Definition
gdibase.h:70
owl::TXOwl::TXOwl
TXOwl(const tstring &msg, uint resId=0)
An OWL exception with a given message for displaying and an unsigned Id that can be used for identifi...
Definition
except.cpp:123
MIIM_ALL
#define MIIM_ALL
Definition
menu.h:39
owl::TMenuItem
UINT_PTR TMenuItem
Represents an unsigned integer or handle which identifies a new menu item.
Definition
menu.h:34
owl
Object Windows Library (OWLNext Core).
Definition
animctrl.h:22
owl::tstring
std::string tstring
Definition
defs.h:79
owl::uint
unsigned int uint
Definition
number.h:25
owl::GetGlobalModule
TModule & GetGlobalModule()
Definition
global.cpp:48
protected_data
#define protected_data
Definition
defs.h:208
defs.h
_OWLCFUNC
#define _OWLCFUNC(p)
Definition
defs.h:342
_OWLCLASS
#define _OWLCLASS
Definition
defs.h:338
posclass.h
preclass.h
wsyscls.h
Classes for window system structure and type encapsulation.
include
owl
menu.h
Generated by
1.18.0