LAnnotation::SetAutoMenuState
#include "ltwrappr.h"
virtual L_INT LAnnotation::SetAutoMenuState(nObjectType, pEnable, pEnableFlags, uBits, uFlags)
L_INT nObjectType; |
/* type of annotation object */ |
/* an array of bit flags */ | |
/* an array of bit flags */ | |
L_UINT uBits; |
/* number of bits in pEnable and pEnableFlags */ |
L_UINT uFlags; |
/* flags that determine which objects to process */ |
Sets all menu items at one time. This function is available in the Document/Medical Toolkits.
Parameter |
Description |
|
nObjectType |
Constant that specifies an object's type. If the object calling this function is an automation object, the menu items for all objects of type nObjectType will be enabled or disabled based on pEnableFlags and pEnable. For descriptions of possible object types, refer to Types of Annotations. |
|
pEnable |
An array of bit flags that specify whether to enable or disable the corresponding menu item specified in pEnableFlags. The bits in the pEnable array are ordered just like the bits in the pEnableFlags array. Therefore, if you wish to display the ANNAUTOTEXT_MENU_CUT menu item, you must make sure that pEnableFlags[0] & 0x40 == 1 is true, and that pEnable[0] & 0x40 == 1 is also true. |
|
pEnableFlags |
An array of bit flags that specify the menu items to change. The bits are ordered from most significant to least significant. Therefore, pEnableFlags[0] contains flags for menu items 0, 1, 2, 3, 4,5, 6, 7. This corresponds to ANNAUTOTEXT_MENU_UNDO, ANNAUTOTEXT_MENU_CUT, ANNAUTOTEXT_MENU_COPY, ANNAUTOTEXT_MENU_PASTE, ANNAUTOTEXT_MENU_DELETE, ANNAUTOTEXT_MENU_SELECTALL, ANNAUTOTEXT_MENU_BRINGTOFRONT, and ANNAUTOTEXT_MENU_SENDTOBACK. For example, if you wish to change the setting for ANNAUTOTEXT_MENU_CUT, make sure pEnableFlags[0] & 0x40 == 1 is true. |
|
uBits |
Number of bits in the pEnableFlags and pEnable arrays. The number of bytes pointed to by pEnable and pEnableFlags can be determined using the following equation: Bytes = (uBits + 7) / 8. |
|
uFlags |
Flags that determine which objects to process. Most of the flags apply only to container objects. You can combine values when appropriate by using a bitwise OR ( | ). The following are valid values: |
|
|
Value |
Meaning |
|
0 |
Process only the specified object. |
|
ANNFLAG_SELECTED |
[0x0001] Process only objects that have the selected property set to TRUE. For getting and setting the selected property, use the LAnnotation::IsSelected and LAnnotation::SetSelected functions. |
|
ANNFLAG_NOTTHIS |
[0x0004] Process only one level of objects within the specified container, not the container itself. If there are containers within the container, they are modified, but the objects within them are not. |
|
ANNFLAG_RECURSE |
[0x0008] Process objects within a container, and within any subcontainers, down to any level. |
|
ANNFLAG_NOTCONTAINER |
[0x0002] (Used with ANNFLAG_RECURSE) Process objects within containers, not the containers themselves. |
|
ANNFLAG_NOINVALIDATE |
[0x0010] Do not invalidate the affected rectangle in the window. Use this to avoid generating unwanted paint messages. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
If a bit in the pEnableFlags array is set to 1, then the corresponding bit in the pEnable array determines whether the corresponding menu item will be displayed or not. If the corresponding bit in pEnable is one, the menu item will be displayed, provided the menu item string is not NULL. If the corresponding bit in pEnable is 0, the corresponding menu item will not be displayed.
If a bit in pEnableFlags is 0, the corresponding bit in pEnable is ignored, and the menu item is displayed or not displayed based on the default behavior.
Required DLLs and Libraries
LTANN For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
See Also
Example
//This example uses the following member variables:
// LAnnotationWindow m_AnnotationWindow
// m_AnnotationWindow should be created and initialized (using CreateWnd)
prior to the example
void CVCAnnotationToolbar11Dlg::OnButtonSetAutoMenuState()
{
L_UCHAR pEnableFlags[2];
L_UCHAR pEnable[2];
L_UCHAR resultFlag;
L_UINT uBits = 16;
L_UCHAR result;
L_TCHAR cs[256];
LAnnAutomation *phAutoObject;
LAnnotationWindow m_AnnotationWindow;
phAutoObject = &m_AnnotationWindow.GetAutomationObject();
//Get the menu state for Note objects
phAutoObject->GetAutoMenuState(ANNOBJECT_NOTE,
pEnable, pEnableFlags, uBits);
//0x40 represents the Cut menu item.
//Therefore test to see if the 0x40 flag has been set
in pEnableFlags,
//indicating a change from its default behavior.
resultFlag = pEnableFlags[0] & 0x40;
if (resultFlag == 0x40) // The flag for the Cut menu
item has been set
{
AfxMessageBox(TEXT("pEnableFlags
is set"));
// Check to see if the same flag has
been set in pEnable
result = pEnable[0] & 0x40;
if (result == 0x40) // The enable flag
has been set, the menu item is enabled.
{
AfxMessageBox(TEXT("The
menu item was enabled. It will be disabled."));
pEnable[0] = 0x00;
phAutoObject->SetAutoMenuState(ANNOBJECT_NOTE, pEnable,
pEnableFlags, uBits, 0);
}
else // The enable flag was not set,
the menu item is disabled.
{
AfxMessageBox(TEXT("The
menu item was disabled. It will be enabled."));
pEnable[0] = 0x40;
phAutoObject->SetAutoMenuState(ANNOBJECT_NOTE, pEnable,
pEnableFlags, uBits, 0);
}
}
else // The flag for the Cut menu item was not set. Set
it and disable the Cut menu item.
{
pEnableFlags[0] = 0x40;
pEnable[0] = 0;
wsprintf (cs, TEXT("The value
of pEnableFlags[0] is %X.\n"), pEnableFlags[0]);
AfxMessageBox(cs);
phAutoObject->SetAutoMenuState(ANNOBJECT_NOTE,
pEnable, pEnableFlags, uBits, 0);
}
}