Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C++ VBScript Javascript CSS HTML , +
I'm very aware of how to use an activeX control's properties in HTML. But how do you access the methods of an activeX in HTML? I've tried google, ehow, stack overflow, and other sites. Nothing worked. My custom C++ ActiveX embeds in the webpage perfectly, but it's useless unless I can use the methods. BTW - What is the difference between methods and properties? they are the same except methods are better because they can have more than one stupid parameter in the syntax. (AFAIK)
Posted 22-Aug-12 14:43pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You just use the dot operator - the same as you do in vb.
Take this sample for example:
var excelApp=null, excelFile=null, excelSheet=null;
function initExcel(filename)
  excelApp = new ActiveXObject("Excel.Application");
  excelFile = excelApp.Workbooks.Open(filename);
  excelSheet = excelApp.Worksheets('Sheet1');
As for methods/properties - they're quite simply what their names imply - properties hold information about the object, methods are things that the object can do (functions).
WorkBooks is a property, Open is a method of that property.
Worksheets is another property of excelApp.
Properties can be simple types, like int, char, byte etc - or they can be objects with several properties/methods.
But in short - property=data, method=function. Smile | :)
time-killer-games at 23-Aug-12 19:40pm
For the strangest reason, I feel that I've already tried that. I'll give it another go once I get home.
time-killer-games at 31-Aug-12 13:42pm
//Does this require a specific way to write my OCX plugin? I tried that and it didn't work.
//Here's all I have in my code, apart from what is automatically generated by the ActiveX OCX project templet:
HANDLE handle;
HWND apphwnd;
int CALLBACK EnumWindowsProc(HWND hwnd, LPARAM param)
DWORD TpID = GetWindowThreadProcessId(hwnd, &pID);
if (TpID == (DWORD)param)
return false;
return true;
HANDLE StartProcess(LPCTSTR program, LPCTSTR args)
HANDLE hProcess = NULL;
STARTUPINFO startupInfo;
::ZeroMemory(&startupInfo, sizeof(startupInfo));
startupInfo.cb = sizeof(startupInfo);
if(::CreateProcess(program, (LPTSTR)args,
::EnumWindows(&EnumWindowsProc, processInfo.dwThreadId);
hProcess = processInfo.hProcess;
return hProcess;
void HostExe(LPCTSTR Exe)
CRect rect;
SetWindowLong(apphwnd, GWL_STYLE, WS_VISIBLE);
::MoveWindow(apphwnd, rect.left,,rect.right, rect.bottom, true);

void CHostExe2Ctrl::HostingStartEmbed(LPCTSTR Exe)
void CHostExe2Ctrl::HostingEndEmbed()
void CHostExe2Ctrl::HostingSetRectangle(long Left, long Top, long Right, long Bottom)
void CHostExe2Ctrl::HostingSetParent(LPCTSTR Parent)
void CHostExe2Ctrl::HostingSetChild(LPCTSTR Child)
//I added the methods with the class wizard. Is there anything else I need to add to access these methods from IE?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 5,130
1 DamithSL 4,237
2 Maciej Los 3,700
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,846

Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 23 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100