Home > Software engineering >  Public ActiveX control
Public ActiveX control

Time:10-02

To write a common ActiveX controls (such as Button, CheckBox, TextBox, etc.) for the use of other languages,
Some questions ask you:

1, each version of Windows has comctl32. DLL, which contains 5. X common control;
Comctl32. Ocx contains 6.0 public control, but after Windows 7 without this file, if no 6.0 public control after Windows 7?

2, System. Windows. Forms. The common control DLL is dotNET common controls,
If you use the System. Windows. Forms. DLL in public control, must be installed dotNET runtime?

3, easy to write c # language utility controls wrapper code, for example:
Using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

Using System. The Runtime. InteropServices;
Using System. The Reflection;
Using Microsoft. Win32;

The namespace DotNetControl
{
[ProgId (" DotNetControl. MyUserControl ")]
[ClassInterface (ClassInterfaceType. AutoDual)]
[Guid (" FBD9A300 - e68 A0D2-4-8 a6c - EB3B378F5E2D ")]
[ComVisible (true)]
Public partial class MyUserControl: System. Windows. Forms. UserControl
{
Public MyUserControl ()
{
InitializeComponent ();
}

[ComRegisterFunction ()]
Public static void RegisterClass (string key)
{
//Strip off HKEY_CLASSES_ROOT \ the from the passed key as I don 't need it
The StringBuilder sb=new StringBuilder (key);
Sb. Replace (@ HKEY_CLASSES_ROOT \ ""," ");

//Open the clsids \ {guid} key for write access
RegistryKey k=Registry. ClassesRoot. OpenSubKey (sb. The ToString (), true);

//And create the 'Control' key - this allows it to show up in
//the ActiveX control container
RegistryKey CTRL=final reateSubKey (" Control ");
CTRL. Close ();

//Next to create the CodeBase entry - men if not string named and GACced.
RegistryKey inprocServer32=k.O penSubKey (" inprocServer32 ", true);
InprocServer32. SetValue (" CodeBase, "Assembly. GetExecutingAssembly (). The CodeBase);
InprocServer32. Close ();

//Finally close the main key
That final lose ();
}

[ComUnregisterFunction ()]
Public static void UnregisterClass (string key)
{
The StringBuilder sb=new StringBuilder (key);
Sb. Replace (@ HKEY_CLASSES_ROOT \ ""," ");

//the Open HKCR \ clsids \ {guid} for write access
RegistryKey k=Registry. ClassesRoot. OpenSubKey (sb. The ToString (), true);

//Delete the 'Control' key, but don 't throw an exception if it does not exist
K.D eleteSubKey (" Control ", false);

//Next open up InprocServer32
RegistryKey inprocServer32=k.O penSubKey (" inprocServer32 ", true);

//And delete the CodeBase key, again not throwing the if missing
K.D eleteSubKey (" CodeBase ", false);

//Finally close the main key
That final lose ();
}
}
}
By the test can be normal use,
C/C + + language whether a similar wrapper code? Or reference sample?

4, the Internet is a VB CommonControls (Replacement of the MS common controls) project,
Using VC to rewrite can refer to the project?

We have any Suggestions, ideas, welcome advice,,,



CodePudding user response:

VB CommonControls (Replacement of the MS common controls) project, url:
http://www.vbforums.com/showthread.php? 698563 - CommonControls - % 28 replacement - of - the - MS - common - controls the % 29

CodePudding user response:

Everything will be subject to the MSDN online.
I only know this,
  • Related