Home > Software engineering >  MFC embedded word hidden or disable parts of the menu bar
MFC embedded word hidden or disable parts of the menu bar

Time:10-01

Now I have put the word into the MFC, the dialog application, also get CCommandBars, but to review how to control the word files in this kind of the use of the menu?



Pray god guide!!!!!!!!!!!!!!!

CodePudding user response:

Such as online myself a top great god replies

CodePudding user response:

Looking for a low version of the word, recording macros, click on the menu operation, there is a corresponding vb code

CodePudding user response:

FindControl method
Please refer to the application in the sample feature
Returns a conform to the specified conditions of CommandBarControl object,

Expression. FindControl (Type, Id, Tag, Visible, Recursive)

Expression required, the expression returns a CommandBars object,

Type MsoControlType Type, optional, to find the types of controls,

MsoControlType type can be one of the following MsoControlType constants:
MsoControlActiveX
MsoControlCustom
MsoControlButton
MsoControlEdit
MsoControlDropdown
MsoControlComboBox
MsoControlButtonDropdown
MsoControlSplitDropdown
MsoControlGenericDropdown
MsoControlGraphicCombo
MsoControlSplitButtonMRUPopup
MsoControlSplitExpandingGrid
MsoControlGraphicDropdown
MsoControlPopup
MsoControlGraphicPopup
MsoControlButtonPopup
MsoControlGauge
MsoControlLabel
MsoControlExpandingGrid
MsoControlGrid
MsoControlOCXDropDown
MsoControlSplitButtonPopup
MsoControlPane

Id the Variant type, optional, to find the control identifier,

To Tag the Variant type, optional, search control Tag values,

Visible the Variant type, optional, if the value is True, then only find command bar controls is displayed on the screen, the default value is False, Visible on the screen of the command bar, including execution FindControl method when open all Visible toolbars and menus,

Recursive Boolean, optional, if the value is True, then the command bar and its all find the formula toolbar popup, this parameter applies only to CommandBar object, the default value is False,

Description
If two or more controls are CommandBars the collection in line with the search criteria, then the FindControl returned to find the first control, if there is no control in line with the search criteria, then the FindControl returns Nothing,

Example
This example can realize the functions as follows: to look for in the command bar "Custom" first controls, if the control is a button, then the sample will use FindControl method to find the Copy button (located in the "common") on the toolbar, and then Copy the Copy button on the glyphs and paste it into the control,

The Set oldCtrl=CommandBars (" Custom ".) Controls (1)
If oldCtrl. Type=1 Then
The Set newCtrl=CommandBars. FindControl (Type:=_
MsoControlButton, ID:=_
CommandBars (" Standard "). Controls (" Copy "). The ID)
NewCtrl. CopyFace
OldCtrl. PasteFace
End the If
All show

CommandBarButton object
Please refer to the event attribute methods
CommandBars (CommandBar)
CommandBarControls (CommandBarControl)
CommandBarButton
CommandBarComboBox
CommandBarPopup

Represents a button control in the command bar,

Using object CommandBarButton
With the Controls (index) can return a CommandBarButton object; Here is the index of the control index number, (the control of the Type attribute must be msoControlButton,)

Assuming command bar "Custom" in the second control is a button, the following example changes the button style,

The Set c=CommandBars (" Custom ".) Controls, (2)
With c
If the Type=msoControlButton Then
If the Style=msoButtonIcon Then
The Style=msoButtonIconAndCaption
The Else
The Style=msoButtonIcon
End the If
End the If
End With
Using FindControl method can also return a CommandBarButton object,

The Visible attribute
Please refer to the application in the sample feature
Some content in this topic may not apply to certain language,

If the specified object is visible, it returns True, Boolean type, read/write,

Expression. The Visible

Expression required, the expression returns "applied" in the list of objects, one of the

Description
New custom command bar Visible attributes of the default value is False,

Only first order column Enabled attribute set to True, only can be the Visible property is set to True,

Example
This example which can realize the function of the is: inspect in the collection order column members, to find the "Forms" command bar, if found the command bar, then according to the command bar and protect its positioning,

FoundFlag=False
For Each cmdbar CommandBars In
If cmdbar. Name="Forms" Then
Cmdbar. Protection=msoBarNoChangeDock
Cmdbar. Visible=True
FoundFlag=True
End the If
Next
If Not foundFlag Then
MsgBox "' Forms' command bar is not in the collection."
End the If
This example can be showed "Office assistant" and set its type dynamic effect,

With the Application. The Assistant
The Visible=True
The contributor=True
The Animation=msoAnimationBeginSpeaking
End With
  • Related