Menu
-->
Implementing Multiple Font Object Interfaces![2011 2011](/uploads/1/2/6/0/126069432/493023503.png)
![Mac Mac](/uploads/1/2/6/0/126069432/676853816.jpg)
- Activex Control Download
- Microsoft 2011 Activex Control In Mac Version
- Microsoft 2011 Activex Control In Mac Download
Jun 28, 2019 The answer lies in the fact that this technology was created by Microsoft. By default, ActiveX only works on applications that were also made by Microsoft – that includes Internet Explorer, PowerPoint, Excel, Word, etc. However, you can now enable ActiveX on both Google Chrome and Mozilla Firefox, even though this wasn’t possible initially. I've read that the Mac version of Excel doesn't support ActiveX controls. My question is: is there a way to build a userform in Excel VBA (in Windows) using controls that aren't ActiveX controls? Or is ActiveX all there is for building userforms in Excel VBA? I've seen people say to use the controls. VBA has some limitation, which include Activex. DLL not existing on Mac, VBA that rely on those extension won’t run on Mac. If possible, try to use as much as possible Form Control instead of ActiveX Control. In most case, it will be just fine. For more info, I suggest you to try it yourself and read the excellent Ron de Bruin’s page on VBA and Mac.
If your ActiveX control displays text, you can allow the control user to change the text appearance by changing a font property. Font properties are implemented as font objects and can be one of two types: stock or custom. Stock Font properties are preimplemented font properties that you can add using the Add Property Wizard. Custom Font properties are not preimplemented and the control developer determines the property's behavior and usage.
This article covers the following topics:
Using the Stock Font Property
Stock Font properties are preimplemented by the class COleControl. In addition, a standard Font property page is also available, allowing the user to change various attributes of the font object, such as its name, size, and style.
Access the font object through the GetFont, SetFont, and InternalGetFont functions of
COleControl
. The control user will access the font object via the GetFont
and SetFont
functions in the same manner as any other Get/Set property. When access to the font object is required from within a control, use the InternalGetFont
function.As discussed in MFC ActiveX Controls: Properties, adding stock properties is easy with the Add Property Wizard. You choose the Font property, and the Add Property Wizard automatically inserts the stock Font entry into the control's dispatch map.
To add the stock Font property using the Add Property Wizard
- Load your control's project.
- In Class View, expand the library node of your control.
- Right-click the interface node for your control (the second node of the library node) to open the shortcut menu.
- From the shortcut menu, click Add and then click Add Property.This opens the Add Property Wizard.Office 365 customers get the new Office for Mac first. You’ll have Office applications on your Mac or PC, apps on tablets and smartphones for when you're on the go, and Office. Www microsoft office for mac. Office 365 的 Office for Mac,让你能从几乎任何地方灵活地完成工作。找到适合你的 Office。 快速开始使用 Word、Excel、PowerPoint、Outlook 和 OneNote 的全新新式版本 - 结合了你喜爱的 Office 熟悉功能和 Mac. Office for Mac微软官方正版下载购买 最新Office 2019取代Office 2016 for Mac, 同时适用Mac/Windows, 订阅Office 365享受Mac iOS等多台设备办公.获得Mac办公最佳体验.
- In the Property Name box, click Font.
- Click Finish.
The Add Property Wizard adds the following line to the control's dispatch map, located in the control class implementation file:
In addition, the Add Property Wizard adds the following line to the control .IDL file:
The stock Caption property is an example of a text property that can be drawn using the stock Font property information. Adding the stock Caption property to the control uses steps similar to those used for the stock Font property.
To add the stock Caption property using the Add Property Wizard
- Load your control's project.
- In Class View, expand the library node of your control.
- Right-click the interface node for your control (the second node of the library node) to open the shortcut menu.But there was no Silverlight plugin for Internet Explorer on those platforms.Microsoft announced the end of life of Silverlight 5 in 2012. Microsoft Silverlight (or simply Silverlight) is a deprecated application framework for writing and running rich Internet applications, similar to Adobe Flash (Learn ). Best Answer: is the best Microsoft Silverlight for Mac Removal software that can uninstall Silverlight and all its related files.What is Silverlight? Silverlight was also one of the two application development platforms for Windows Phone. Microsoft silverlight plugin download mac.
- From the shortcut menu, click Add and then click Add Property.This opens the Add Property Wizard.
- In the Property Name box, click Caption.
- Click Finish.
The Add Property Wizard adds the following line to the control's dispatch map, located in the control class implementation file:
Modifying the OnDraw Function
The default implementation of
OnDraw
uses the Windows system font for all text displayed in the control. This means that you must modify the OnDraw
code by selecting the font object into the device context. To do this, call COleControl::SelectStockFont and pass the control's device context, as shown in the following example:After the
OnDraw
function has been modified to use the font object, any text within the control is displayed with characteristics from the control's stock Font property.Using Custom Font Properties in Your Control
In addition to the stock Font property, the ActiveX control can have custom Font properties. To add a custom font property you must:
- Use the Add Property Wizard to implement the custom Font property.
- Processing font notifications.
- Implementing a new font notification interface.
Implementing a Custom Font Property
To implement a custom Font property, you use the Add Property Wizard to add the property and then make some modifications to the code. The following sections describe how to add the custom
HeadingFont
property to the Sample control.To add the custom Font property using the Add Property Wizard
- Load your control's project.
- In Class View, expand the library node of your control.
- Right-click the interface node for your control (the second node of the library node) to open the shortcut menu.
- From the shortcut menu, click Add and then click Add Property.This opens the Add Property Wizard.
- In the Property Name box, type a name for the property. For this example, use HeadingFont.
- For Implementation Type, click Get/Set Methods.
- In the Property Type box, select IDispatch* for the property's type.
- Click Finish.
The Add Property Wizard creates the code to add the
HeadingFont
custom property to the CSampleCtrl
class and the SAMPLE.IDL file. Because HeadingFont
is a Get/Set property type, the Add Property Wizard modifies the CSampleCtrl
class's dispatch map to include a DISP_PROPERTY_EX_IDDISP_PROPERTY_EX macro entry:The DISP_PROPERTY_EX macro associates the
HeadingFont
property name with its corresponding CSampleCtrl
class Get and Set methods, GetHeadingFont
and SetHeadingFont
. The type of the property value is also specified; in this case, VT_FONT.The Add Property Wizard also adds a declaration in the control header file (.H) for the
GetHeadingFont
and SetHeadingFont
functions and adds their function templates in the control implementation file (.CPP):Finally, the Add Property Wizard modifies the control .IDL file by adding an entry for the
HeadingFont
property:Modifications to the Control Code
Now that you have added the
HeadingFont
property to the control, you must make some changes to the control header and implementation files to fully support the new property.In the control header file (.H), add the following declaration of a protected member variable:
In the control implementation file (.CPP), do the following:
- Initialize m_fontHeading in the control constructor.
- Declare a static FONTDESC structure containing default attributes of the font.
- In the control
DoPropExchange
member function, add a call to thePX_Font
function. This provides initialization and persistence for your custom Font property. - Finish implementing the control
GetHeadingFont
member function. - Finish implementing the control
SetHeadingFont
member function. - Modify the control
OnDraw
member function to define a variable to hold the previously selected font. - Modify the control
OnDraw
member function to select the custom font into the device context by adding the following line wherever the font is to be used. - Modify the control
OnDraw
member function to select the previous font back into the device context by adding the following line after the font has been used.
After the custom Font property has been implemented, the standard Font property page should be implemented, allowing control users to change the control's current font. To add the property page ID for the standard Font property page, insert the following line after the BEGIN_PROPPAGEIDS macro:
You must also increment the count parameter of your BEGIN_PROPPAGEIDS macro by one. The following line illustrates this:
After these changes have been made, rebuild the entire project to incorporate the additional functionality.
Processing Font Notifications
In most cases the control needs to know when the characteristics of the font object have been modified. Each font object is capable of providing notifications when it changes by calling a member function of the
IFontNotification
interface, implemented by COleControl
.If the control uses the stock Font property, its notifications are handled by the
OnFontChanged
member function of COleControl
. When you add custom font properties, you can have them use the same implementation. In the example in the previous section, this was accomplished by passing &m_xFontNotification when initializing the m_fontHeading member variable.Implementing Multiple Font Object Interfaces
The solid lines in the figure above show that both font objects are using the same implementation of
IFontNotification
. This could cause problems if you wanted to distinguish which font changed.One way to distinguish between the control's font object notifications is to create a separate implementation of the
IFontNotification
interface for each font object in the control. This technique allows you to optimize your drawing code by updating only the string, or strings, that use the recently modified font. The following sections demonstrate the steps necessary to implement separate notification interfaces for a second Font property. The second font property is assumed to be the HeadingFont
property that was added in the previous section.Implementing a New Font Notification Interface
To distinguish between the notifications of two or more fonts, a new notification interface must be implemented for each font used in the control. The following sections describe how to implement a new font notification interface by modifying the control header and implementation files.
Additions to the Header File
In the control header file (.H), add the following lines to the class declaration:
This creates an implementation of the
IPropertyNotifySink
interface called HeadingFontNotify
. This new interface contains a method called OnChanged
.Additions to the Implementation File
![2011 2011](/uploads/1/2/6/0/126069432/493023503.png)
In the code that initializes the heading font (in the control constructor), change &m_xFontNotification to &m_xHeadingFontNotify. Then add the following code:
Activex Control Download
The
AddRef
and Release
methods in the IPropertyNotifySink
interface keep track of the reference count for the ActiveX control object. When the control obtains access to interface pointer, the control calls AddRef
to increment the reference count. When the control is finished with the pointer, it calls Release
, in much the same way that GlobalFree
might be called to free a global memory block. When the reference count for this interface goes to zero, the interface implementation can be freed. In this example, the QueryInterface
function returns a pointer to a IPropertyNotifySink
interface on a particular object. This function allows an ActiveX control to query an object to determine what interfaces it supports.After these changes have been made to your project, rebuild the project and use Test Container to test the interface. See Testing Properties and Events with Test Container for information on how to access the test container.
See also
MFC ActiveX Controls
MFC ActiveX Controls: Using Pictures in an ActiveX Control
MFC ActiveX Controls: Using Stock Property Pages
-->MFC ActiveX Controls: Using Pictures in an ActiveX Control
MFC ActiveX Controls: Using Stock Property Pages
本主题包括在工作表或图表工作表上使用 ActiveX 控件的特定信息。This topic covers specific information about using ActiveX controls on worksheets and chart sheets.有关添加和使用控件的常规信息, 请参阅在文档中使用 ActiveX 控件和创建自定义对话框。For general information on adding and working with controls, see Using ActiveX Controls on a Document and Creating a Custom Dialog Box.
在工作表上处理控件时,必须记住以下几点:Keep the following points in mind when you are working with controls on sheets:
- 除了可用于 ActiveX 控件的标准属性, 下列属性也可用于 Microsoft Excel 中的 ActiveX 控件: BottomRightCell、 LinkedCell、 ListFillRange、 PlacementPrintObject、 TopLeftCell 和**ZOrder**。In addition to the standard properties available for ActiveX controls, the following properties can be used with ActiveX controls in Microsoft Excel: BottomRightCell, LinkedCell, ListFillRange, Placement, PrintObject, TopLeftCell, and ZOrder.这些属性可用 ActiveX 控件的名称来设置和返回。These properties can be set and returned using the ActiveX control name.下例滚动工作簿窗口,使 CommandButton1 位于窗口的左上角。The following example scrolls the workbook window so CommandButton1 is in the upper-left corner.
- 在激活 ActiveX 控件时, 某些 Microsoft Excel Visual Basic 方法和属性将被禁用。Some Microsoft Excel Visual Basic methods and properties are disabled when an ActiveX control is activated.例如, 当控件处于活动状态时, 不能使用Sort方法, 因此, 在按钮单击事件过程中, 以下代码将失败 (因为用户单击该控件仍处于活动状态)。For example, the Sort method cannot be used when a control is active, so the following code fails in a button click event procedure (because the control is still active after the user clicks it).您可以在使用失败的属性或方法之前激活工作表上的其他一些元素, 从而解决此问题。You can work around this problem by activating some other element on the sheet before you use the property or method that failed.例如, 下面的代码对区域进行排序:For example, the following code sorts the range:
- 当用户双击嵌入在其他应用程序文档中的 Microsoft Excel 工作簿对其进行编辑时,该工作簿上的控件将不能正常工作。Controls on a Microsoft Excel workbook embedded in a document in another application will not work if the user double-clicks the workbook to edit it.如果用户右键单击工作簿,然后选择快捷菜单上的“打开”**** 命令,工作簿上的控件将正常工作。The controls will work if the user right-clicks the workbook and selects the Open command from the shortcut menu.
- 用 Microsoft Excel 5.0/95 工作簿文件格式保存 Microsoft Excel 工作簿时,将丢失 ActiveX 控件信息。When a Microsoft Excel workbook is saved using the Microsoft Excel 5.0/95 Workbook file format, ActiveX control information is lost.
- 工作表上 ActiveX 控件的事件过程中的 Me 关键字引用的是工作表,而不是控件。The Me keyword in an event procedure for an ActiveX control on a sheet refers to the sheet, not to the control.
用 Visual Basic 添加控件Adding Controls with Visual Basic
在 Microsoft Excel 中,用 OLEObjects 集合中的 OLEObject 对象代表 ActiveX 控件(所有 OLEObject 对象也都包含在 Shapes 集合中)。In Microsoft Excel, ActiveX controls are represented by OLEObject objects in the OLEObjects collection (all OLEObject objects are also in the Shapes collection).若要用编程方式向工作表添加 ActiveX 控件,请用 OLEObjects 集合的 Add 方法。To programmatically add an ActiveX control to a sheet, use the Add method of the OLEObjects collection.下例向第一张工作表添加命令按钮。The following example adds a command button to worksheet 1.
通过 Visual Basic 使用控件属性Using Control Properties with Visual Basic
绝大多数情况下,Visual Basic 代码可用名称引用 ActiveX 控件。Most often, your Visual Basic code will refer to ActiveX controls by name.下例更改了控件“CommandButton1”的标题。The following example changes the caption on the control named 'CommandButton1.'
请注意,当在控件所在的工作表的类模块之外使用控件的名称时,必须用工作表的名称限定该控件的名称。Note that when you use a control name outside the class module for the sheet containing the control, you must qualify the control name with the sheet name.
若要更改在 Visual Basic 代码中所用的控件名称,请先选择控件,然后在“属性”窗口中设置控件的“(名称)”**** 属性。To change the control name you use in Visual Basic code, select the control and set the (Name) property in the Properties window.
因为 ActiveX 控件也可用 OLEObjects 集合中的 OLEObject 对象代表,所以也可用该集合中的对象来设置控件的属性。Because ActiveX controls are also represented by OLEObject objects in the OLEObjects collection, you can set control properties using the objects in the collection.下例设置了控件“CommandButton1”的左边位置。The following example sets the left position of the control named 'CommandButton1.'
没有显示为 OLEObject 对象属性的控件属性可通过由 Object 属性返回的实际控件对象来设置。Control properties that are not shown as properties of the OLEObject object can be set by returning the actual control object using the Object property.下例设置了控件“CommandButton1”的标题。The following example sets the caption for CommandButton1.
Microsoft 2011 Activex Control In Mac Version
因为所有 OLE 对象也是 Shapes 集合的成员,所以也可用该集合设置多个控件的属性。Because all OLE objects are also members of the Shapes collection, you can use the collection to set properties for several controls.下例对齐第一张工作表上所有控件的左边缘。The following example aligns the left edge of all controls on worksheet 1.
![Mac Mac](/uploads/1/2/6/0/126069432/676853816.jpg)
使用 Shapes 和 OLEObjects 集合的控件名称Using Control Names with the Shapes and OLEObjects Collections
工作表上的 ActiveX 控件具有两个名称:包含控件的形状的名称(查看工作表时,可在“名称”**** 框中看到此名称);控件的代码名称(在“属性”窗口的“(名称)”**** 右侧单元格中可看到此名称)。An ActiveX control on a sheet has two names: the name of the shape that contains the control, which you can see in the Name box when you view the sheet, and the code name for the control, which you can see in the cell to the right of (Name) in the Properties window.第一次向工作表添加控件时,形状名称和代码名称是匹配的。When you first add a control to a sheet, the shape name and code name match.但是,如果您更改这两个名称中的任意一个,另一个不会随之自动更改。However, if you change either the shape name or code name, the other is not automatically changed to match.
在控件的事件过程名称中使用的是控件代码名称。You use the code name of a control in the names of its event procedures.但是,从工作表的 Shapes 或 OLEObjects 集合返回控件时,必须使用形状名称而不是代码名称来通过名称引用控件。However, when you return a control from the Shapes or OLEObjects collection for a sheet, you must use the shape name, not the code name, to refer to the control by name.例如,假定要向工作表添加一个复选框,默认的形状名称和代码名称都是 CheckBox1。For example, assume that you add a check box to a sheet and that both the default shape name and the default code name are CheckBox1.如果通过在“属性”窗口的“(名称)”**** 旁边键入“chkFinished”**** 更改控件代码名称,则必须在事件过程名称中使用“chkFinished”,但仍需要使用 CheckBox1 才能从 Shapes 或 OLEObject 集合返回控件,如下例所示。If you then change the control code name by typing chkFinished next to (Name) in the Properties window, you must use chkFinished in event procedure names, but you still have to use CheckBox1 to return the control from the Shapes or OLEObject collection, as shown in the following example.
支持和反馈Support and feedback
Microsoft 2011 Activex Control In Mac Download
有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation?请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.