Click here to Skip to main content
Rate this: bad
good
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 13:43pm

1 solution

Rate this: bad
good
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 | :)
  Permalink  
Comments
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 pID;
DWORD TpID = GetWindowThreadProcessId(hwnd, &pID);
if (TpID == (DWORD)param)
{
apphwnd=hwnd;
return false;
}
return true;
}
 
HANDLE StartProcess(LPCTSTR program, LPCTSTR args)
{
 
HANDLE hProcess = NULL;
PROCESS_INFORMATION processInfo;
STARTUPINFO startupInfo;
::ZeroMemory(&startupInfo, sizeof(startupInfo));
startupInfo.cb = sizeof(startupInfo);
if(::CreateProcess(program, (LPTSTR)args,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&startupInfo,
&processInfo))
{
::EnumWindows(&EnumWindowsProc, processInfo.dwThreadId);
hProcess = processInfo.hProcess;
WaitForSingleObject(hProcess,INFINITE);
}
return hProcess;
}
 
void HostExe(LPCTSTR Exe)
{
CRect rect;
GetClientRect(GetActiveWindow(),&rect);
handle=StartProcess(Exe,Exe);
if(apphwnd!=NULL)
{
::SetParent(apphwnd,GetActiveWindow());
SetWindowLong(apphwnd, GWL_STYLE, WS_VISIBLE);
::MoveWindow(apphwnd, rect.left, rect.top,rect.right, rect.bottom, true);

}
}
 
void CHostExe2Ctrl::HostingStartEmbed(LPCTSTR Exe)
{
HostExe(Exe);
}
 
void CHostExe2Ctrl::HostingEndEmbed()
{
TerminateProcess(handle,0);
}
 
void CHostExe2Ctrl::HostingSetRectangle(long Left, long Top, long Right, long Bottom)
{
::MoveWindow(apphwnd,Left,Top,Right,Bottom,true);
}
 
void CHostExe2Ctrl::HostingSetParent(LPCTSTR Parent)
{
::SetParent(apphwnd,(HWND)Parent);
}
 
void CHostExe2Ctrl::HostingSetChild(LPCTSTR Child)
{
::SetParent((HWND)Child,(HWND)GetActiveWindow());
}
 
//I added the methods with the class wizard. Is there anything else I need to add to access these methods from IE?
//Thanks!

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

  Print Answers RSS
0 OriginalGriff 210
1 kbrandwijk 100
2 Richard MacCutchan 100
3 ProgramFOX 80
4 Mukesh Bhagat 65
0 Sergey Alexandrovich Kryukov 9,050
1 OriginalGriff 8,151
2 CPallini 2,613
3 Richard MacCutchan 2,221
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web03 | 2.8.140827.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