|
Hey, i'm making a Selection Object (IHTMLSelectionObject) and i'm trying to call .createRange(IDispatch**) but it says to just pass in a IHTMLTxtRange object but it's not picking up the derived IDispatch, i've never really messed with HTML objects in general, so any advise as to why it says that I cannot pass in an IHTMLTxtRange object... i dont know.. just kinda lost really.. (i'm trying to make something where i can cycle through certain keywords and bringing up a menu on what to do with these keywords) but i want to stick with C++ and i wont be able to edit HTML tags and such as most "examples" show... I dont know.. i'm just kinda out there today so speak slowly! haha
Thanks,
~Timothy T. Rymer
http://www.digipen.edu
http://tim.xpertz.com
http://www.ttrx.com (not up yet)
|
|
|
|
|
it's cool...n/m
~Timothy T. Rymer
www.digipen.edu
tim.xpertz.com
|
|
|
|
|
haha yeah...
~Timothy T. Rymer
www.digipen.edu
tim.xpertz.com
|
|
|
|
|
yep.
~Timothy T. Rymer
www.digipen.edu
tim.xpertz.com
|
|
|
|
|
Hi,
this is not meant to make you feel more embarrased and probably you already have solved this problem. ANyway, recently, I was doing something quite similar and just comparing notes with you -
//m_spDoc is the smart pointer to IHTMLDocument2 that
//represents the current webpage loaded in the browser. I
//too am trying to get the selection text and figure out
//the element position and element tagname.
IHTMLSelectionObject *sel;
CComQIPtr < IHTMLTxtRange, &IID_IHTMLTxtRange> tRange;
CComPtr < IHTMLElement> element;
hr = m_spDoc->get_selection(&sel);
if (FAILED(hr))
return;
CComBSTR type;
hr = sel->get_type(&type);
if (FAILED(hr))
return;
if (type == OLESTR("None"))
return;
CComPtr < IDispatch> ppDisp;
hr = sel->createRange(&ppDisp);
if (FAILED(hr))
return;
tRange = ppDisp;
CComBSTR bstr;
hr = tRange->get_text(&bstr);
if (FAILED(hr))
return;
if (bstr.Length() == 0)
return;
bstrText = bstr;
Wow!! do you study at digipen or teach there? Being an amateur game coder(yeah! I fiddle around with DX too!!) it's been a dream to get to learn game programming at digipen, but somehow couldn't afford it!!
sonork: 100:18407
|
|
|
|
|
Hi,
I can pass VARIANT to this method :
STDMETHODIMP Cwr::callWRrtf(VARIANT vTempArray,BSTR* output)
{AFX_MANAGE_STATE(AfxGetStaticModuleState())
VARIANT *rgv1;
SafeArrayAccessData(vTempArray.parray,(void**)&rgv1);
...
with this VBasic client :
Dim v2(1) As Variant
v2(0) = "some string"
res = myDLL.callWRrtf(v2)
but i want to do this in VBScript. Is it possible ? How ? I tried but
it doesn't work ....
Thanks
David
David D.
|
|
|
|
|
I'm guessing you wrote your COM DLL in ATL? Obviously you're COM DLL was written as an in process Single Threaded Apartment using an interface derived from IDispatch? These are some of the rules for dealing with script code, ie, on web pages.
There's many, many, many other unwritten rules. However, a few of them are:
1) If you are passing IN string data you MUST use BSTR as your type.
2) If you want string data OUT you MUST use VARIANT. Yeah, you'd figure that BSTR* would get you what you want but the unfortunate truth is while it may work occasionally, it will get you 9 times out of 10 and when you least expect it. Even using BSTR* as your [out,retval] won't always work. Instead make it just another parameter, [in] VARIANT* and return a succeed/fail as the return value so you know if the data was any good.
So, in this case it looks like you want to use VARIANT's in both parameters though I'm not sure but data is being passed in (or out) from your VARIANT object. On the other matter, VBScript is ALL variant data. If you simply ignore the type it should work fine.
|
|
|
|
|
Hi,
I have some problems with my application and need some help on it. That is the problem: I have a macro running on a MSWord document, and this macro calls some components (DCOM) that i've made. Once Visual C++ were instaled on the machine (either if it was removed) no problem occurr. But else it causes a fatal error that closes the MSWord (Winword.exe). I think , it install some dll's that resolves this problem, but I don't know wich to install.
My components uses ATL Dialogs, where I think the problem is. I use Install Shield to install my application and if there's some way to do with this tool may be helpful.
YVS
|
|
|
|
|
Check to see if ATL.DLL was installed on these machines before you installed VC++.
If not, you need to register that DLL also when you install your application.
(This is a common problem with Windows 95)
- Greatest invention : "The Microchip!"
|
|
|
|
|
Thank you, but it does not work.
YVS
|
|
|
|
|
When I use the function "accLocation" in an HTML page,
I get the points: top and left, that refer to the part of the page that I can see.
how can I get the points that refer to the beginning of the page?
For example:
I have a long html page (5000 points),
and I scrolled down.
We can see the points from 2500 to 3500.
I have an object that its top is 2700,
When I run the function "accLocation" I get the top 200.
How can I get the full measurement 2700?
Thank you
Chagit
|
|
|
|
|
I need to use IDispatch::Invoke() to call a function which I know by name. Therefore, I can use GetIDsOfNames() to find the DISPID of the function.
But what if I have overloaded functions, that is several functions with the same name, but different arguments? How can I get the DISPID of the right one?
I vote pro drink
|
|
|
|
|
You can't have methods with the same name.
|
|
|
|
|
Yeah, I've just found out that. Thanks for your reply.
I vote pro drink
|
|
|
|
|
How can i obtain the IUnknown interface pointer(LPUNKNOWN) for an ActiveX Control ?
Abdiel Jaramillo
Arango Software International
Panama, Rep. of Panama.
|
|
|
|
|
I have a simple ATL COM control and I need to supply a method that fills a BYTE buffer (passed by the caller) with some data that the control has read from a file. As this data may contain zeroes, I cannot use BSTR. I thought this would be easy - declare something like the following IDL:
[id(11), helpstring("method GetImage")] HRESULT GetImage([out] unsigned char* pData, [out, retval] BOOL* pVal);
Then access the buffer directly in the COM control:
STDMETHODIMP CKView2::GetImage(unsigned char* pData, BOOL* pVal)
{
// Access the buffer
memcpy(pData, m_pSource, ...)
// Done
*pVal = TRUE;
return S_OK;
}
Of course, this doesn't work.
The question is - is there a simply way to do this? Or do I need to look at the ghastly SAFEARRAY? Strings are allocated with AllocSysString - is there an equivalent way to allocate a generic buffer allowing you to easily copy some non-string data?
Any comments would be appreciated!
|
|
|
|
|
Yes you need to look at SAFEARRAY. It's not that bad to use a SafeArray.
I also found it's better to pass array as VARIANT.
Good luck and be patient!
- Greatest invention : "The Microchip!"
|
|
|
|
|
If you don't want to use an array, a quick and dirty way is the following:
[id(11), helpstring("method GetImage")] HRESULT GetImage(long pData, [out, retval] BOOL* pVal);
Here "pData" is the buffer address supplied by the client (casted to long). So the implementation will be like:
STDMETHODIMP CKView2::GetImage(long pData, BOOL* pVal)
{
// Access the buffer
memcpy((void*) pData, m_pSource, ...)
// Done
*pVal = TRUE;
return S_OK;
}
P.S. 1. This works only for "in-proc" controls.
P.S. 2. Since you data may contains NULL characters, you might want to add another parameter for buffer size or return data length.
|
|
|
|
|
<br />
ThisBytes([in] int nCount, [out] BYTE** ppBytes)<br />
{<br />
BYTE* pBytes = reinterpret_cast<BYTE*>(CoTaskMemAlloc(nCount * sizeof(BYTE));<br />
<br />
<br />
*ppBytes = pBytes;<br />
<br />
return S_OK;<br />
}<br />
Don't forget to call CoTaskMemFree
|
|
|
|
|
Hi,
I developed a COM app under VC++, which is called by a macro from WinWord.
The application have 6 Dll's, some works perfectly, and some which must show a dialog derived from CDialogImpl doesn't.
In machines that has or had the VC++ installed, my application works perfectly, no problems. But in machines that never had the VC++ installed, the problem occurs.
Everything is registered, installed as should be installed. So the problem is not with the application, and I think it could be with some Dll's from the system.
So if someone has a solution, please send me.
Thanks.
Otávio
otavio.romao@inatel.br
|
|
|
|
|
Make sure everything is built in release mode not debug.
|
|
|
|
|
|
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"
|
|
|
|