I am interested in further exploring the possibilities of using/developing an ActiveX object for use in a Sidebar gadget but havent done anything like this before. What are the best ways of proceeding with this Can i use Visual Studio 2005 to create an ActiveX object i tried using ATL project, i was able to compile it but not to register it

ActiveX for Sidebar best practices
GT1000
Gromey
Kurt Jaegers
Thanks for your responses; to clarify I have formatted my Vista system just in case, I use Visual Studio 2005 and follow Bruce’s Tutorial Part1 and Part2 I compile the DLL and use regsvr32 TestActiveX.dll in the command prompt (Running all as Admin) I get notification that the DLL is registered successfully.
Next I use the following HTML:
<HTML>
<SCRIPT>
function main(){
try
{ var myControl = new ActiveXObject(“TestActiveX.TestControl”);
out(myControl.Echo(“Bruce Williams”));
}
catch (e)
{
content.innerText = "ERROR: " + e + " : " + e.name + " : " + e.message;
}
}
function out(text)
{
content.innerHTML += "<DIV style='height:20;overflow:hidden'>" + text + "</DIV>";
}
</SCRIPT>
</HEAD>
<BODY STYLE="height:300;width:600;background-color:gray" onload=main();">
<DIV id="content" style="height:270;width:580;border-style:solid;overflow:auto">
</DIV>
</BODY>
</HTML>
But it still doesn’t work I am starting to feel silly L
andrewdobson1
paulabq
montaquehou
Hello Bruce,
I am using Visual Studio 2005 following your tutorial i selected: File -> New Project ->Visual C++ -> ATL -> ATL Project
Your tutorial is well written and the screenshots are complementing well; i really much doubt me having made a silly mistake, i even tried it twice now,
I follow the rest of the tutorial carefully and build my solution; but how do i register this activex control If i debug run or start without debugging i get the
"Executable For Debug Session" dialog where i can choose the Executable file name i.e. Internet Explorer, ActiveX Control Test Container, regsvr32, Browse...
i tried to manually do regsvr32 TestActiveX.dll which reports success but it doesnt seam to work
ZopoStyle
yes his article looks good but he says: "Now our initial ActiveX control implementation is complete – you can press F7 to build and register your new ActiveX control." when following his instructions F7 doesnt do anything furthermore i dont have that option
D.A.V.E.
arashikage
PeterVrenken
Al Stark
var oTest=new ActiveXObject("TestActiveX.TestControl");
oTest.Echo
Check you're not getting a compiler error, I had to do a rebuild to get it to compile the first time (right click on TestActiveX and select Rebuild)
Ravencraft
If you want to distribute it with the Gadget, you need to find out what reg entries it creates under HKLM and progammatically put them into HKCU as the Gadget loads. I have noticed that this only works if the user is not an elevated Administrator. For it to work as an elevated Administrator, you need to register to HKLM.
Here's the code I use in my Media Player Gadget, which handles both user types:
//register graphics library
var ImgXLib, ImgXLibOK;
var regRoot = "HKCU";
//try HKCU first
if (!activeDLL()) {
//HKCU failed, so try HKLM
regRoot = "HKLM";
if (!activeDLL())
System.Debug.outputString("Error creating ActiveX object ("+err.name+" - "+err.message+")");
}
// Try to register the DLL
function activeDLL() {
try{
RegisterImgXLib(regRoot);
ImgXLib = new ActiveXObject("ImgXLib.ImgX");
ImgXLibOK = true;
} catch(err) {
// DLL not working under this Reg root, so remove the registry entries
ImgXLib = null;
ImgXLibOK = false;
UnregisterImgXLib(regRoot);
}
return ImgXLibOK;
}
// Register Thumbnail ActiveX component
function RegisterImgXLib(root) {
try{
oShell.RegWrite(root + "\\Software\\Classes\\CLSID\\{EBECE075-E4AE-4A77-89BF-9C85C0EFF82F}\\","ImgXLib.ImgX", "REG_SZ");
oShell.RegWrite(root + "\\Software\\Classes\\CLSID\\{EBECE075-E4AE-4A77-89BF-9C85C0EFF82F}\\Implemented Categories\\{40FC6ED5-2438-11CF-A3DB-080036F12502}\\", "", "REG_SZ");
oShell.RegWrite(root + "\\Software\\Classes\\CLSID\\{EBECE075-E4AE-4A77-89BF-9C85C0EFF82F}\\InprocServer32\\", gadgetPath + "\\ImgXLib.dll", "REG_SZ");
oShell.RegWrite(root + "\\Software\\Classes\\CLSID\\{EBECE075-E4AE-4A77-89BF-9C85C0EFF82F}\\InprocServer32\\ThreadingModel", "Apartment", "REG_SZ");
oShell.RegWrite(root + "\\Software\\Classes\\CLSID\\{EBECE075-E4AE-4A77-89BF-9C85C0EFF82F}\\ProgID\\", "ImgXLib.ImgX", "REG_SZ");
oShell.RegWrite(root + "\\Software\\Classes\\CLSID\\{EBECE075-E4AE-4A77-89BF-9C85C0EFF82F}\\TypeLib\\", "{E82BEFB5-939E-449F-A975-062F2BEDCFC2}", "REG_SZ");
oShell.RegWrite(root + "\\Software\\Classes\\CLSID\\{EBECE075-E4AE-4A77-89BF-9C85C0EFF82F}\\VERSION\\", "2.0", "REG_SZ");
oShell.RegWrite(root + "\\Software\\Classes\\ImgXLib.ImgX\\", "ImgXLib.ImgX", "REG_SZ");
oShell.RegWrite(root + "\\Software\\Classes\\ImgXLib.ImgX\\Clsid\\", "{EBECE075-E4AE-4A77-89BF-9C85C0EFF82F}", "REG_SZ");
oShell.RegWrite(root + "\\Software\\Classes\\TypeLib\\{E82BEFB5-939E-449F-A975-062F2BEDCFC2}\\2.0\\", "ImgXLib", "REG_SZ");
oShell.RegWrite(root + "\\Software\\Classes\\TypeLib\\{E82BEFB5-939E-449F-A975-062F2BEDCFC2}\\2.0\\0\\win32\\", gadgetPath + "\\ImgXLib.dll", "REG_SZ");
oShell.RegWrite(root + "\\Software\\Classes\\TypeLib\\{E82BEFB5-939E-449F-A975-062F2BEDCFC2}\\2.0\\FLAGS\\", "0", "REG_SZ");
oShell.RegWrite(root + "\\Software\\Classes\\TypeLib\\{E82BEFB5-939E-449F-A975-062F2BEDCFC2}\\2.0\\HELPDIR\\", gadgetPath, "REG_SZ");
} catch(err) {System.Debug.outputString("RegisterImgXLib: "+err.name+" - "+err.message)}
}
// Unregister Thumbnail ActiveX component
function UnregisterImgXLib(root) {
try{
oShell.RegDelete(root + "\\Software\\Classes\\CLSID\\{EBECE075-E4AE-4A77-89BF-9C85C0EFF82F}\\Implemented Categories\\{40FC6ED5-2438-11CF-A3DB-080036F12502}\\");
oShell.RegDelete(root + "\\Software\\Classes\\CLSID\\{EBECE075-E4AE-4A77-89BF-9C85C0EFF82F}\\Implemented Categories\\");
oShell.RegDelete(root + "\\Software\\Classes\\CLSID\\{EBECE075-E4AE-4A77-89BF-9C85C0EFF82F}\\InprocServer32\\");
oShell.RegDelete(root + "\\Software\\Classes\\CLSID\\{EBECE075-E4AE-4A77-89BF-9C85C0EFF82F}\\ProgID\\");
oShell.RegDelete(root + "\\Software\\Classes\\CLSID\\{EBECE075-E4AE-4A77-89BF-9C85C0EFF82F}\\TypeLib\\");
oShell.RegDelete(root + "\\Software\\Classes\\CLSID\\{EBECE075-E4AE-4A77-89BF-9C85C0EFF82F}\\VERSION\\");
oShell.RegDelete(root + "\\Software\\Classes\\CLSID\\{EBECE075-E4AE-4A77-89BF-9C85C0EFF82F}\\");
oShell.RegDelete(root + "\\Software\\Classes\\ImgXLib.ImgX\\Clsid\\");
oShell.RegDelete(root + "\\Software\\Classes\\ImgXLib.ImgX\\");
oShell.RegDelete(root + "\\Software\\Classes\\TypeLib\\{E82BEFB5-939E-449F-A975-062F2BEDCFC2}\\2.0\\0\\win32\\");
oShell.RegDelete(root + "\\Software\\Classes\\TypeLib\\{E82BEFB5-939E-449F-A975-062F2BEDCFC2}\\2.0\\0\\");
oShell.RegDelete(root + "\\Software\\Classes\\TypeLib\\{E82BEFB5-939E-449F-A975-062F2BEDCFC2}\\2.0\\FLAGS\\");
oShell.RegDelete(root + "\\Software\\Classes\\TypeLib\\{E82BEFB5-939E-449F-A975-062F2BEDCFC2}\\2.0\\HELPDIR\\");
oShell.RegDelete(root + "\\Software\\Classes\\TypeLib\\{E82BEFB5-939E-449F-A975-062F2BEDCFC2}\\2.0\\");
oShell.RegDelete(root + "\\Software\\Classes\\TypeLib\\{E82BEFB5-939E-449F-A975-062F2BEDCFC2}\\");
} catch(err) {System.Debug.outputString("UnregisterImgXLib: "+err.name+" - "+err.message)}
}
Michael Grau
Hi Jonathan,
Are you sure I am using Visual Studio 2005 Professional and i get to choose either regsvr32, IE or ActiveX control test container am i missing something It compiles fine, i am running as admin but my TestActiveXControl never gets registered
Will Merydith