|
I resolved this issue, finally, and figured I'd post the solution for those of you that want an answer to this question as well.
The TranslateAccelerator() method in the IDocHostUIHandler interface is extended and key events are handled based on a flag passed from the container object (in this case, a window). I originally tried to pass the accelerator KB message to the parent window by using SendMessage() but that only caught the first key of the key stroke (i.e. an ALT-F would only catch the ALT key ).
Instead, I ended-up using a PostMessage call, which is able to properly handle the dispatched accelerator message.
Here's a code snippet for ya:
<br />
if ( m_vbEnableAllAccels == VARIANT_FALSE ) { <br />
HWND hWndParent = ::GetAncestor( lpMsg->hwnd, GA_ROOT );<br />
ATLASSERT( hWndParent );<br />
PostMessage( hWndParent, lpMsg->message, lpMsg->wParam, lpMsg->lParam );<br />
}<br />
else if (m_vbEnableAllAccels == VARIANT_TRUE<br />
|| (GetKeyState(VK_CONTROL) >= 0<br />
&& GetKeyState(VK_SHIFT) >= 0 && GetKeyState(VK_MENU) >= 0))<br />
{ ...<br />
D.
|
|
|
|
|
Hello,
why i can't make any changes to a ByRef passed Com MEthod Variable ?
The variable ha s the same value before and after the Com Method invokation.
Any Ideas ?
|
|
|
|
|
The behaviour is clear once we look at the IDL file
HRESULT Run(
[in] BSTR ProcedureName,
[in] SAFEARRAY(VARIANT)* Parameters,
[out, retval] VARIANT* pvarResult);
Which means your parameters are passed by value [in] and not by reference [in,out].
VOTD: 27 "Religion that God our Father accepts as pure and faultless is this:
to look after orphans and widows in their distress and to keep oneself from being polluted by the world." - Jam 1:27 (NIV)
|
|
|
|
|
Hello,
means retval that the scripting host knows, that he can change the variable ?
I've made ...[out] long* _value);
In VBScript i use ... CLng(_variantvar) to make the conversions.
Can i use only Variant Vars in the COM Interface ?
|
|
|
|
|
Well '[out,retval]' is used only for return value. '[in]' says that whatever you passed to your script function, you can't change it inside of your script since data are passed by value. Think of it as a C++ function:
int Sum(int num1, int num2) { return num1+ num2; }
changes to num1 and num2 affect local value only and 'return' is like a constant. I hope it is clearer now.
VOTD: 27 "Religion that God our Father accepts as pure and faultless is this:
to look after orphans and widows in their distress and to keep oneself from being polluted by the world." - Jam 1:27 (NIV)
|
|
|
|
|
Hello,
thanks, now it works !
BUT, is there no posibility to make this without to use a return variable ?
My VB Programms and C++ Clients are all working perfectly with a ByRef Call.
Must i really change all clients to use the RetVal, only because i want to use COM-Scripting with VBScript ?
In VBScript i can made ByRef Callings without problems.
Like :
Sub DoSubroutine( )
Dim x
x = 10
msgbox x
CallAnotherSub x
msgbox x
End Sub
Sub CallAnotherSub(ByRef var1)
var1 = var1^2
End Sub
|
|
|
|
|
Well VB and VBScript are different. VB supports a whole lot more data types than VBScript.
VOTD: 15 "The eyes of the Lord are on the righteous and his ears are attentive to their cry;
16 the face of the Lord is against those who do evil, to cut off the memory of them from the earth. " - Psalm 34:15-16 (1 Peter 3:11-12) (NIV)
|
|
|
|
|
Hello Ernest,
i ve noticed, that the article "Adding VBScript and JScript support in ..."
is yours. That had inspired me to make my COM-Servers available to scripting.
Now i've made my COM INterfaces scriptable und the next Problem occurs.
I need the Event's from my COM Objects in the VBScript. I have made it with
" Set msport = WScript.CreateObject("MSCOMSRV.Port","msport_") ". This is OK, if i runs it from the shell with WSH. In your Applikation i get the error
" Object needed WScript ". In which enviroment are the Scripts running (in your Application) ?.
My thought was to make the custom-Scripts like Plug-Ins in my C++ Main Applikation.
Koep ( author of the anonymous messages in the thread, but i ve forgot my password and the remind me action failed )
|
|
|
|
|
"WScript" is a different 'HOST' engine than the ActiveX version. I am still planning to write an article about it (give me 1-2 week). You can create COM object from your script and catch the event. In VBScript, create your activex (COM object) by calling
Set MsCOMSVR = CreateObject("MSCOMSRV.Port") MsCOMSVR_OnEvent is the name of the event function. MsCOMSVR must be global in VBScript, if you declare it inside of a 'Sub' it will be destroyed when the 'Sub' terminates.
VOTD: 15 "The eyes of the Lord are on the righteous and his ears are attentive to their cry;
16 the face of the Lord is against those who do evil, to cut off the memory of them from the earth. " - Psalm 34:15-16 (1 Peter 3:11-12) (NIV)
|
|
|
|
|
Are u sure ?
I think, and my tests confirm this, that u can't use events in normal VBScript. When i use "Set msport = WScript.CreateObject("MSCOMSRV.Port","msport_")" then it's possible. Because the WSH can do event action. The "wscript.sleep 10000" is also important for the event listening stuff. How would u do this without the WScript object ? The WScript can't used from the msscript.ocx . So i have no idea to make event-scripting available from C++ Code, because i don't want to create 10th or 100th of individual WScript processes.
Marco
|
|
|
|
|
Yep! it is possible, hopefully I will submit a new article this coming weekend that
demonstrate just that. Watch for it Saturday or Sunday!
ÿVOTD: 8 "Love never fails. But where there are prophecies, they will cease;
where there are tongues, they will be stilled; where there is knowledge, it will pass away." - 1 Cor 13:8 (NIV)
|
|
|
|
|
I just re-read your comment correctly and you are right about it. MSscript.ocx does not allow you to handle script event from your script but funnyly you can add/connect object with it.
ÿVOTD: 8 "Love never fails. But where there are prophecies, they will cease;
where there are tongues, they will be stilled; where there is knowledge, it will pass away." - 1 Cor 13:8 (NIV)
|
|
|
|
|
My program is a client (c++) that link to an activex dll created in VB.
I use this function :
hresult = m_connection->LoadData(OLESTR("01"),OLESTR("B20"), 0,0,&ResulVar,OLESTR("thisMachine"),ADO_ODBC , &m_E );
Hresult tells me everything worked fine but ResulVar return empty.
ResulVar is a VARIANT.
m_E is an object that receive error from the server. It tells me that :
ActiveX component can't create object.(usualy, it's when dll are not registred)
With an other program in vb I tested the same function an it worked perfectly, so I know my dll are registered.
If it can provide me with the error message from m_E, Why the VARIANT doesn't receive the data?
Does anyone have a clue?
Thanks
|
|
|
|
|
I want to put HTML code to MSHTML.
The code contains "FRAMESET" tag.
I tried,,,
IHTMLDocument3* doc3;
////get pointer
doc3->get_documentElement(&pElement);
pElement->put_outerHTML(L"~~~~")
But I couldn't put HTML code.
I tried next,,
doc2->get_body(&pElement);
pElement->put_innerHTML(L"~~~~")
But I couldn't put HTML code.
How to put HTML code??
Please tell me.
I thought hardly.
|
|
|
|
|
Try this. It works for me. From Steve.
MSHTML::IHTMLElementPtr spEle;
MSHTML::IHTMLDocument2Ptr spDoc2;
CString sHtml;
sHtml = "some HTML text here";
// get spDoc2 from CHtmlView
spDoc2 = m_pBrowserApp->get_Document( (IDispatch**)&spDoc2 );
if ( spDoc2 == NULL )
return;
spEle = spDoc2->Getbody();
if ( spEle == NULL )
return;
spEle->PutinnerHTML( (LPCTSTR)sHtml );
|
|
|
|
|
Unlikely to work, just because in HTML a tag is not inside a tag.
I would suggest to do instead : doc3->Write("..."); (which is the equivalent of Javascript's document.write("...") ),
And I swallow a small raisin.
|
|
|
|
|
I tried,,
BSTR bstr = SysAllocString(L"~~~");
SafeArrayCreateVector(VT_VARIANT, 0, 1);
SafeArrayAccessData(sfArray,(LPVOID*) & param);
param->vt = VT_BSTR;
param->bstrVal = bstr;
SafeArrayUnaccessData(sfArray);
document->write(sfArray);
But 'FRAME page' is blank page.
Of course,The Page exists.
I think document reset.
Please tell me another method.
Is it impossible ?
|
|
|
|
|
That works fine. In fact, when you do the equivalent of document.write() when the document is finished loading, IE simply creates a new one and put your HTML code in it. So, you should see the frames for your frameset.
Please remember that a frameset by itself is a very special HTML tag that has no meaning inside an HTML ....
If your aim is only to have one or more frames, I would recommend to use the tag instead, and use putinnerhtml,
And I swallow a small raisin.
|
|
|
|
|
Hi Everybody,
I want to take a Character string as a input parameter to a COM component created in VC++ using ATL.How do I perform this task.It would be better if the solution is also given for returning a character string as the output parameter of the COM component.
Thanks and Regards,
Abhishek.
Learning is a never ending process of Life.
|
|
|
|
|
Use a BSTR.
First pram below is how you pass it in, second is how you make it a return value.
HRESULT MyFunc(BSTR bstrParam, [out, retval]BSTR *bstrRetVal)
Jason Henderson quasi-homepage articles "Like it or not, I'm right!"
|
|
|
|
|
Just so I'm clear, what the best way to deal with this in a way that's "friendly" to both C++ and VB (I work exclusively in C++ myself)?
I'd envision a C++ calling sequence similar to:
BSTR* pbstrFoo = NULL;<br />
MyFunc(pbstrFoo);<br />
if(NULL != pbstrFoo)<br />
{<br />
::SysFreeString(pbstrFoo);<br />
pbstrFoo = NULL;<br />
}
Is that about right? So what would a similar calling sequence be for a VB programmer? Is there something I can do differently within my COM object to make it easier for both?
|
|
|
|
|
b_p_smith wrote:
BSTR* pbstrFoo = NULL;
MyFunc(pbstrFoo);
You forgot the first param in my example so it would look like this:
BSTR bstrFoo1;
BSTR* pbstrFoo = NULL;
bstrFoo1 = ::SysAllocString(L"Test")
MyFunc(bstrFoo1, pbstrFoo);
In C++ you must free both strings.
I don't use VB so I can't give an example, but when the string falls out of scope, VB should handle freeing the string.
So don't worry about your VB client app, it will just see this as a return value.
Jason Henderson quasi-homepage articles "Like it or not, I'm right!"
|
|
|
|
|
Thanks Jason. That's pretty clear, and I'll adjust my code accordingly.
|
|
|
|
|
Hi
I would like to establish a "connection" to another application. My code looks like this:
if (pBaanApp == NULL)
{
CoInitialize(NULL);
HRESULT hr = pBaanApp.CreateInstance("Baan4.Application");
....
....
This works fine when the Baan4 application is not allready started. If it is started, this will fail and hr=-2147467262. I then tried to use this line of code to "get hand on" the application:
HRESULT hr = pBaanApp.GetActiveObject("Baan4.Application");
This fails and hr=-2147221021.
Can anybody help me ?
Regards,
Evan
|
|
|
|
|
.CreateInstance(...) and .GetActiveObject(...) are not the right functions to use.
The one and only function to use is CoCreateInstance(CLSID, ..., IID, &IUnknown).
As for the error you get (-2147467262), it means "interface not supported". I believe that's because you're calling .CreateInstance() from a wrong context.
And I swallow a small raisin.
|
|
|
|