Microsoft KB Archive/260578

= How To Capture a Text Size Change Within an ActiveX Control =

Article ID: 260578

Article Last Modified on 5/11/2006

-

APPLIES TO


 * Microsoft Internet Explorer 3.0
 * Microsoft Internet Explorer 3.01
 * Microsoft Internet Explorer 3.02
 * Microsoft Internet Explorer 4.0 128-Bit Edition
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 4.01 Service Pack 1
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 5.0
 * Microsoft Internet Explorer 5.01
 * Microsoft Internet Explorer 5.5

-



This article was previously published under Q260578



SUMMARY
When you open a page in Microsoft Internet Explorer and you use the Text Size option from the View menu to change text size, multiple properties on the page change.

This article describes how you can catch the property changed event from within an ActiveX Control.



Microsoft Foundation Classes (MFC) Control
In an MFC control, the AmbientPropertyChange's dispatch ID (DISPID) will be DISPID_UNKNOWN. The following steps show how you can tell if the font changed.

  Declare a Private variable in the control: LPFONTDISP orgFont;   In the constructor of the control, for example, CMFCControlCtrl, add the following code: if (0 != GetAmbientProperty(DISPID_AMBIENT_FONT, VT_FONT, &orgFont)) AfxMessageBox(&quot;Ambient property is supported in this container&quot;);   Modify OnAmbientPropertyChange as follows: void CMFCControlCtrl::OnAmbientPropertyChange(DISPID dispid) {

if (DISPID_UNKNOWN == dispid) {       LPFONTDISP pFont = AmbientFont; if (pFont != orgFont) AfxMessageBox(&quot;Font Changed&quot;); }   COleControl::OnAmbientPropertyChange(dispid); }                   

Microsoft Visual Basic Control
In a Visual Basic control, the PropertyName of the AmbientChanged event is an empty string. The following code demonstrates how you can use code to create the empty string with Visual Basic. Option Explicit Private orgFontSize As Currency

Private Sub UserControl_AmbientChanged(PropertyName As String) If PropertyName = &quot;&quot; Then If orgFontSize <> Ambient.Font.Size Then MsgBox orgFontSize & &quot; font changed to &quot; & Ambient.Font.Size orgFontSize = Ambient.Font.Size End If  End If End Sub

Private Sub UserControl_Show orgFontSize = Ambient.Font.Size End Sub

