Calling into InfoPath s IPropertyNotifySink Interface in .NET framework

Generator QR in .NET framework Calling into InfoPath s IPropertyNotifySink Interface
Calling into InfoPath s IPropertyNotifySink Interface
QR Code ISO/IEC18004 Generator In Visual Studio .NET
Using Barcode encoder for ASP.NET Control to generate, create QR Code 2d barcode image in ASP.NET applications.
Remember that, earlier, when we showed you how to implement an ActiveX control in C++, we talked about the fact that, in order for a control
Printing Bar Code In VS .NET
Using Barcode encoder for ASP.NET Control to generate, create bar code image in ASP.NET applications.
Building Custom Controls for InfoPath Using ActiveX
Generate QR Code ISO/IEC18004 In Visual C#.NET
Using Barcode generation for Visual Studio .NET Control to generate, create QR Code image in .NET applications.
to alert InfoPath of changes to the control s data, it has to call into the host s IPropertyNotifySink interface Speci cally, the control calls the OnChanged method, which in ATL was done by calling the FireOnChanged method Well, for managed code, there s no difference We just need to set up an event source for the IPropertyNotifySink interface As you probably have guessed, since the IPropertyNotifySink interface is a COM interface, which coincidentally is de ned in the OCIdlidl le in the Platform SDK, we need to use COM interop in order to use this interface in our managed code control First, we need to declare this interface using the standard COM interop attributes, as shown in Listing 197
Print QR Code In .NET Framework
Using Barcode printer for .NET framework Control to generate, create QR-Code image in VS .NET applications.
Listing 197: Declaration of the IPropertyNotifySink Interface
Quick Response Code Creator In VB.NET
Using Barcode creation for Visual Studio .NET Control to generate, create QR Code ISO/IEC18004 image in .NET applications.
[ComImport] [Guid("9BFBBC02-EFF1-101A-84ED-00AA00341D07")] [InterfaceType(ComInterfaceTypeInterfaceIsIUnknown)] public interface IPropertyNotifySink { [PreserveSig] int OnChanged(int dispId); [PreserveSig] int OnRequestEdit(int dispId); }
Creating GTIN - 13 In .NET Framework
Using Barcode maker for ASP.NET Control to generate, create GTIN - 13 image in ASP.NET applications.
Next, to expose the IPropertyNotifySink interface as an event source to InfoPath, we need to add another COM interop attribute to the InfoPathMaskedTextBox class ComSourceInterfaces This attribute speci es which interfaces are exposed as COM connection points Therefore, to expose IPropertyNotifySink as an event source, we must specify the ComSourceInterfaces attribute on the class as follows:
Draw Data Matrix ECC200 In .NET
Using Barcode printer for ASP.NET Control to generate, create DataMatrix image in ASP.NET applications.
[ComSourceInterfaces(typeof(IPropertyNotifySink))] public partial class InfoPathMaskedTextBox : UserControl, IInfoPathMaskedTextBox, IObjectSafety
Bar Code Drawer In .NET Framework
Using Barcode generation for ASP.NET Control to generate, create bar code image in ASP.NET applications.
Once that is completed, we must de ne a delegate so we can call the OnChanged method in InfoPath The signature of this delegate must match that of the OnChanged method and is declared is as follows:
Generating Code-39 In Visual Studio .NET
Using Barcode generation for ASP.NET Control to generate, create Code 3 of 9 image in ASP.NET applications.
public delegate int OnChangedDelegate(int dispID);
Paint Barcode In VS .NET
Using Barcode drawer for ASP.NET Control to generate, create bar code image in ASP.NET applications.
19: Building Custom Controls
UCC-128 Maker In VS .NET
Using Barcode creation for ASP.NET Control to generate, create EAN / UCC - 13 image in ASP.NET applications.
Now we just need to re the event whenever we want to alert InfoPath of changes to the data in the control To re the event, let s create a helper method to do the work This helper method, called FireOnChanged, is shown in Listing 198 As you can see, this method takes the dispatch ID of the property that changed, which is then passed to the OnChanged method in InfoPath Usually, this dispatch ID will match that of the binding property, which in the case of our control is set to 0 Note that passing 0 to OnChanged will work if your binding property is named Value However, if you name the property something other than Value, you should pass -1: as the dispatch ID to InfoPath, which will tell it to update all the control properties Also, you ll notice in the code in Listing 198 that we are ensuring that the OnChanged method is not null before calling it This is necessary because the IPropertyNotifySink event sink will be detached and reattached when the data in the main data source for the form has changed If you don t perform this check, your control will throw an exception, which will cause InfoPath to crash (Also, remember earlier that we mentioned that the ClassInterface attribute must be set to ClassInterfaceTypeAutoDual If you set this attribute to anything but ClassInterfaceTypeAutoDual, the OnChanged and OnRequestEdit delegates will be null)
I-2/5 Creator In .NET Framework
Using Barcode generation for ASP.NET Control to generate, create 2/5 Interleaved image in ASP.NET applications.
Listing 198: FireOnChanged Helper Method
Printing Code 128B In Java
Using Barcode generation for Java Control to generate, create Code128 image in Java applications.
private int FireOnChanged(int dispID) { if (OnChanged != null) { return OnChanged(dispID); } return 0; }
Code 128 Code Set C Recognizer In VS .NET
Using Barcode recognizer for VS .NET Control to read, scan read, scan image in VS .NET applications.
Typically, for performance reasons, you wouldn t want to re the OnChanged event each time the user types a character in the masked text box Instead, you probably want to re the event when focus leaves the control That s just what we ll do When the masked text box loses focus (ie, the user presses the Tab key or clicks to move focus out of the control), we ll call the FireOnChanged method, passing it the dispatch ID of the binding property if Value is the binding property or -1 otherwise Of course, you probably want to call the FireOnChanged method only if the data has actually changed
Creating Data Matrix 2d Barcode In Visual C#.NET
Using Barcode printer for Visual Studio .NET Control to generate, create Data Matrix 2d barcode image in VS .NET applications.
Draw Bar Code In C#
Using Barcode generation for VS .NET Control to generate, create bar code image in VS .NET applications.
Decode Bar Code In Java
Using Barcode scanner for Java Control to read, scan read, scan image in Java applications.
Bar Code Creation In .NET
Using Barcode printer for VS .NET Control to generate, create bar code image in Visual Studio .NET applications.