|
|
How can i catch the events fired by an ActiveX control without using Class Wizard ?
I'm creating the controls at runtime that's why i can't use the ClassWizard to create the Event Sink Map.
Abdiel Jaramillo
Arango Software International
Panama, Rep. of Panama.
|
|
|
|
|
Very strange. My previous reply to this message seems to have disappeared.
Anyway, you can try using my XYDispDriver class to handle events. You need to implement a com object as your event handler (using either ATL or MFC). It only works for non-GUI controls (the com interface has to be derived from IDispatch).
Warning: Some ATL "experts" hate this method.
|
|
|
|
|
Hi, I recently wrote a COM control (GUI-less, not active-X) that I load into a webpage using the "OBJECT" tag. I have several HTML elements on the page that are updated periodically based on the state of the COM object (it does some complex calculations based on form variables on the page). Currently, I use a hacked solution of using the SetInterval/SetTimer methods in javascript and polling the state of the COM object. I was wondering if there's a better way to do this? I have lots of ideas but am wondering if there's a clear-cut good way to do this: Can I pass a pointer to the COM object and have it directly access elements on the webpage whenever it wants to change their state? Is it legal to pass IHTMLElement pointers directly from javascript to the COM object and then call methods on them from the control? What happens if the page is unloaded and the COM object tries to use the pointer? Is this a place where I could use event sinks? Thanks!
Mach5 Enterprises, LLC. http://www.mach5.com/
"Web Intelligence for the New Economy"
|
|
|
|
|
Ugh,
I'll try to answer something - generally you can pass pointer to your com object and allow him directly access webpage elements (or use 1x1 pixel visual AX and retrieve interfaces of IE directly without script). There should not be generally problems, because when you leave the page, your component will be destroyed (should be). Only beware of circular references - afaik the "page" holds reference to your object, so if you'll hold reference to page...
I'm not strong in IE scripting, but you can use events in some way,
you write
|
|
|
|
|
Hello,
I have some sort of problem in COM while passing the ADO recordset
object through variant to the client. In the server I can able to traverse
through the recordset . Once I got the variant at the client end, the variant
contains the NULL (VT_EMPTY) .
What is the problem? For your clarity I'm putting some excerption from my
coding.
At Server_End
HRESULT CServer::Function1(VARIANT *pvarRSObj, VARIANT *pvarRetVal)
{
_RecordsetPtr pRSObj = NULL;
try
{
pRSObj->CreateInstance(__uuidof(Recordset));
pRSObj->Open(varQueryString, (IDispatch*)m_conObj,
adOpenKeyset, adLockBatchOptimistic, adCmdText);
pvarRSObj->vt = VT_DISPATCH;
pvarRSObj->pdispVal = (IDispatch*)pRSObj;
}
catch(_com_error &e)
{
ERRBOX(e.ErrorMessage());
return e.Error();
}
catch(...)
{
ERRBOX("Unknown Exception");
return E_FAIL;
}
return S_OK;
}
At Client_End
InvokeServer()
{
IServer *pServer;
//instantiation of server
pServer->Function1(&varRSObj, &varResponse);
CHECKVARIANTTYPE(&varRSObj); //It'll check the variant type
// this is showing me that variant contains VT_EMPTY.
if(varRSObj.vt == VT_DISPATCH)
{
//necessary action
}
}
Timely reply appreciated.
Regards,
Ramesh
|
|
|
|
|
Hi,
You can return a Recordset as an IDispatch pointer like this:
STDMETHODIMP CMyClass::GetAllRecords(BSTR bstrSearchKey, IDispatch **output)
{
....
....
*output = (IDispatch*) pRecordset.Detach(); //Return recordset as IDispatch
}
Regards,
ShadiK
Shadi Al-Kahwaji
|
|
|
|
|
I am hosting IWebBrowser2 in my application. The problem is that "cut & copy" of the default context menu were not working. Whenever I tried to copy ,"Acces is denied" alert box comes up. So I implemented my own context menu using "ShowContextMenu" of IDocHostUIHandlerDispatch interface. I used IOleCommandTarget for delete, and implemented copy and cut on my own. However, my code does not work on IE 5.0. What should I do?. Are the IOleCommandTarget's Exec method or IWebBrowser's ExecWB method not availabe on 1E 5.0 .
These functions do not work on Win98 also. Is there any other way of doing these in win98?Please help. I am in urgent need.
|
|
|
|
|
uyiyuiyuncvnvbmnvbmnvbmsdgsdgfsdf!!!!!!!!!!!!
|
|
|
|
|
when i try to return an integer Locally, everything goe's smooth.
but when i try it remotely i get the next number:-858993460
whatever the input is.
Plese Help!
|
|
|
|
|
Ok, did you look at the conversion? -858993460 is 0xCCCCCCCC which is usually what you find in uninitialized memory when running in debug mode.
Are you initializing the variable that you're returning? Just a guess.
J
|
|
|
|
|
Hi all,
When outputting a VARIANT from a COM interface member (as an [out] parameter, not [in, out]), should I call ::VariantClear() or ::VariantInit() on the output parameter before assigning to it? Or is this redundant/incorrect?
e.g.:
STDMETHODIMP MyFunc (/*[out]*/ VARIANT* pVal)
{
VariantInit (pVal); // ok?
pVal->vt = ....
...
}
cheers
NB
|
|
|
|
|
See sample app of COM Variant and Safearrays at
http://www.sellsbrothers.com/tools/CComSafeArray.zip
(from chris sells site)
|
|
|
|
|
Helllo everybody:
I have a DCOM server that returns an integer. This server runs on a win95 machine. When i connect everything goes fine but when i try to return the integer from the server, The client stops immidiatly. Is there enyone who ever had the same problem.
I preciate your Help..
|
|
|
|
|
Not knowing exactly what you are doing, it sounds as if the integer datatype is different between the client and the DCOM server. What kind of client are you using?
I have had this problem and I solved it by using the BSTR datatype. To do "pure COM" and being on the safe side, you should always pass BSTR:s as parameters, since they will be the same on both client and server side. This leads to a bit more of converting, but that's life
Best regards,
/_henrik
Henrik Sternberg,
Cambridge Technolgy Partners, Germany
www.ctp.com/ce
henrik.sternberg@ctp.nospam.com
(take away nospam)
|
|
|
|
|
Hi,
I have a DCOM application, where the component fires 8-10 events.
But all the events are similar in structure. (ie. they doesnt have any data associated with them).
The only difference is the event name.
So, I can easily use a single event to Notify all my events to
the client (And have some Parameter that distinguishes the event
to the client).
Now, my question is will this (using a single event in place of many events)
provide any PERFORMANCE benefits in a DCOM application ??
if yes, How ?? (some technical description will be appreciated)
anyway, the number of Network RoundTrips is going to be the same...
if no,
What will be a good COM programming practice in this situation.
(using a Single event or using different events)
Please somebody reply ...
I had posted this earlier, but got no response...
Thanks,
Firoz.
|
|
|
|
|
From a mantainability and debugging point of view combining all events into a single one would of course be more beneficial.
I don't believe I've seen any performance difference in using multiple events rather than a single one, as you said the round trips will be the same.
|
|
|
|
|
Firoz wrote:
the number of Network RoundTrips is going to be the same...
How do you figure? As I see it, DCOM needs to setup for each call. If you only call once, this setup (marshalling and whatnot) is only done once. If you do many calls, this setup needs to be done each time. Sure the amount of data (from your point of view) being sent is the same (1 x 10 events or 10 x 1 events), but I think you need to take into consideration the setup and teardown of the connection.
Please correct me if I'm wrong.
J
|
|
|
|
|
Hello, can somebody please help me:
i'm trying to write a string to a file serverside. and i want to get the string back. So i use the next function:
MIDL :write [in]BSTR message
cpp: HRESULT Write(BSTR message)
{
//code to write to a file on the server
}
can u please explane how the BSTR type works and how can i convert it to a normal string
|
|
|
|
|
CString str = _T("")
str = message;
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
|
One of the easiest way to use the BSTR type as normal string, in my opinion is
to use the compiler string type: _bstr_t
Use like this:
HRESULT Write(BSTR message)
{
_tprintf(TEXT("Message:%s\r\n", (LPCTSTR) _bstr_t(message));
}
You can look at the description for _bstr_t in MDSN for more help.
It can also convert ASCII string to Unicode. You may want to use conversion macro.
HRESULT Write(BSTR message)
{
USES_CONVERSION;
LPCTSTR lpszNormal = OLE2CT(message);
_tprintf(TEXT("Message:%s\r\n", (LPCTSTR) lpszNormal);
}
|
|
|
|
|
|
MultiByteToWideChar / WideCharToMultiByte or mbstowcs / wcstombs
|
|
|
|
|
There are 2ways to do this
The first method uses the OLE2T() for BSTR conversion to string.
The second method uses _bstr_t for conversion.
******************************************************#inclu#include <iostream.h>
#include <atlbase.h>
#include <comdef.h>
void main()
{
BSTR b=L"StringConversion"; //BSTR string
USES_CONVERSION; //First method of Conversion
cout<<"String :"<
|
|
|
|