L_AnnSetAutoMenuState

Summary

Sets all menu items at one time.

Syntax

#include "l_bitmap.h"

L_LTANN_API L_INT L_AnnSetAutoMenuState(hObject, nObjectType, pEnable, pEnableFlags, uBits, uFlags)

Parameters

HANNOBJECT hObject

Handle to the annotation object.

L_INT nObjectType

Constant that specifies an object's type. If hObject 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.

L_UCHAR *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.

L_UCHAR *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:

For example, if you wish to change the setting for ANNAUTOTEXT_MENU_CUT, make sure pEnableFlags[0] & 0x40 == 1 is true.

L_UINT 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.

L_UINT 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 L_AnnGetSelected and L_AnnSetSelected 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

Value Meaning
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

Platforms

Win32, x64.

See Also

Functions

Topics

Example

L_INT AnnSetAutoMenuStateExample(HANNOBJECT hAutoObject) 
{ 
   L_INT    nRet; 
   L_UCHAR  pEnableFlags[2]; 
   L_UCHAR  pEnable[2]; 
   L_UCHAR  resultFlag; 
   L_UINT   uBits = 16; 
   L_UCHAR  result; 
   L_TCHAR  cs[256]; 
 
   /* Get the menu state for Note objects */ 
   nRet = L_AnnGetAutoMenuState(hAutoObject, ANNOBJECT_NOTE, pEnable, pEnableFlags, uBits); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   // 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 */ 
   { 
      _tprintf(_T("%s"), 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. */ 
      { 
         _tprintf(_T("%s"), TEXT("The menu item was enabled. It will be disabled.")); 
         pEnable[0] = 0x00; 
         nRet = L_AnnSetAutoMenuState(hAutoObject, ANNOBJECT_NOTE, pEnable, pEnableFlags, uBits, 0); 
         if (nRet != SUCCESS) 
            return nRet; 
      } 
      else /* The enable flag was not set, the menu item is disabled. */ 
      { 
         _tprintf(_T("%s"), TEXT("The menu item was disabled. It will be enabled.")); 
         pEnable[0] = 0x40; 
         nRet = L_AnnSetAutoMenuState(hAutoObject, ANNOBJECT_NOTE, pEnable, pEnableFlags, uBits, 0); 
         if (nRet != SUCCESS) 
            return nRet; 
      } 
   } 
   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]); 
      _tprintf(_T("%s"), cs); 
      nRet = L_AnnSetAutoMenuState(hAutoObject, ANNOBJECT_NOTE, pEnable, pEnableFlags, uBits, 0); 
      if (nRet != SUCCESS) 
         return nRet; 
   } 
 
   return SUCCESS; 
} 
Help Version 22.0.2023.7.11
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.