|
Thanks for the reply,
The problem is when I run the JScript in Mozilla Firefox browser it says
that ActiveX object is not defined.
My CoClass is defined as shown below.
class ATL_NO_VTABLE CQpOffice :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CQpOffice, &CLSID_QpOffice>,
public IDeskBand,
public IObjectWithSite,
public IDispatchImpl<IQpOffice, &IID_IQpOffice, &LIBID_AUTOUPDATETBLib>
and the interface method is defined as
STDMETHODIMP CQpOffice::Hello2(BSTR *String)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
// TODO: Add your implementation code here
if(!String)
return(E_POINTER);
*String=::SysAllocString(L"Hello2!");
return S_OK;
}
and the JScript to call the interface method is defined as
var obj;
obj= new ActiveXObject("AUTOUPDATETBLib.QpOffice");
alert(obj.Hello2());
What could be the problem so I received the error "ActiveX object not defined" the COM DLL is registered in the system and I can see the CoClass and Interface method in "Object Browser" in Visual Basic 6.0.
ritz1234
|
|
|
|
|
ritz1234 wrote: ("AUTOUPDATETBLib.QpOffice"
Is that the right progID (you may use OLEVIEW to check it)?
Are you able to late bind the control using Visual Basic 6 ?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thanks for the reply cPallini.
yes,that was the wrong progId.
I realized that and changed the code in JScript as below
var ob;
ob= new ActiveXObject("AutoUpdateTB.QpOffice");
alert(ob.Hello2());//Hello2 is the interface method that returns a string
When I drag and drop the html page that has the above mention code the
Internet explorer ask for weather to allow the interaction with the
ActiveX or not, that means the progId is right in this case.But when I
press "Yes" button the messagebox that should be display doesn't appear.
And when I double click at the left most icon located at the bottom
status bar it says "Automation server can't create object".
Pls tell me what is the reason.
1 more question.
1)Is it possible to call the COM DLL method in such a way, that when we call the method the messagebox that Internet Explorer ask for weather to allow the activex to interact doesn't appear?
ritz1234
|
|
|
|
|
I'm implementing a dialog that inherits off CSimpleDialog that's part of a CAtlDllModuleT. The dialog loads fine, but one of the things I'm trying to do is to move the resource of the dialog into a different DLL, to make it easier to internationalize (replace the dialog text, etc).
I know how to load the resource DLL, but I'm unsure of how to tell my dialog class to specifically load the dialog resource from that DLL.
Thanks in advance for any suggestions. If I'm not clear in anything, do ask me to clarify.
|
|
|
|
|
|
How to handle COM Events in Java script
How to use ATL COM in java script and handle COM event in java script
if the ATL COM is developed in C++
Abhiraj
modified on Tuesday, April 29, 2008 2:43 AM
|
|
|
|
|
|
Hi Steve
You took the question wrong ...
The question is how to handle events in Java script which are fired from ATL COM
I am able to call COM interface methods in java scripts but not able to handle events fired from the same ATL COM Component
and not "call java script functions in C++"
with regards
Abhiraj
|
|
|
|
|
You haven't explained properly. How is the ATL COM object hosted? If it's hosted on the page you can simply handle it like any other event in HTML. It it's not on the page you would sink the events with an interface implemented in C/C++ and the methods would delegate to the web page as described in my previous post.
Steve
|
|
|
|
|
Hi Steve
I would like to change my question...
How to use ATL COM in java script and handle COM event in java script
if the ATL COM is developed in C++
Abhiraj
|
|
|
|
|
Firstly, I’ll assume you’re embedding a COM object in a HTML page (you haven’t explicitly stated this). Here’s what my page looks like:
<html>
<head>
<title>CallMe</title>
</head>
<body>
<object id="my_obj" classid="clsid:7815559F-240E-406E-A0F0-974B7272C65F">
</object>
<script type="text/javascript" for="my_obj" event="Hello">
window.alert("Hello!");
</script>
<input type="button" value="Call into COM object" onclick="my_obj.CallMe();" />
</body>
</html>
Note that I used MSVC6, but other versions will have equivalent functionality.
You’ll have to use connection points to implement an outgoing interface. Here’s the IDL of my project:
import "oaidl.idl";
import "ocidl.idl";
[
object,
uuid(4E413D85-21DC-48FC-AD65-B8635B74CBFF),
dual,
helpstring("IHostMeObj Interface"),
pointer_default(unique)
]
interface IHostMeObj : IDispatch
{
[id(1), helpstring("method CallMe")] HRESULT CallMe();
};
[
uuid(9598F3A4-B8DE-4BA8-9AE1-90903ED9EF38),
version(1.0),
helpstring("HostMe 1.0 Type Library")
]
library HOSTMELib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
[
uuid(5C211D24-97D2-4AA1-AB93-EE605DC97614),
helpstring("_IHostMeObjEvents Interface")
]
dispinterface _IHostMeObjEvents
{
properties:
methods:
[id(1), helpstring("method Hello")] void Hello();
};
[
uuid(7815559F-240E-406E-A0F0-974B7272C65F),
helpstring("HostMeObj Class")
]
coclass HostMeObj
{
[default] interface IHostMeObj;
[default, source] dispinterface _IHostMeObjEvents;
};
};
It’s also important to implement the IProvideClassInfo and IProvideClassInfo2 interfaces or the callbacks will not work.
The following articles (on the Wayback Machine, as the originals seem to have been deleted) may help:
http://web.archive.org/web/20060915111734/http://msdn.microsoft.com/archive/en-us/dnarguion/html/drgui082399.asp[^]
http://web.archive.org/web/20060921072123/http://msdn.microsoft.com/archive/en-us/dnarguion/html/drgui102599.asp[^]
Steve
|
|
|
|
|
Hi Steve
I have implemented the IProvideClassInfo and IProvideClassInfo2 interfaces for the callbacks and the callback are working fine
Now the issue is even if I fire Event from ATL COM once , its shown more than once on the web page as if i have fired event from ATL COM many times and everytime the count is getting increased ....
I have used this ATL Component in VB also , in VB its working fine if event is fired once the event is shown once and not more than that...
Here is the code snippet
......
MessageBox(NULL,TEXT("Fire Event Reached"),TEXT("OK"),MB_OK);
hr = pConnection->Invoke(1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, ¶ms, &varResult, NULL, NULL);
MessageBox(NULL,TEXT("Fire Event Complete"),TEXT("OK"),MB_OK);
.........
I have used two message boxes just for the sake for debugging...
Now in VB whenever there is event i have shown a msg box so once event is fired only 3 messages boxes comes one after the other
1. Fired Event Reached
2. Event Message Box (When "pConnection->Invoke" is fired)
3. Fire Event Complete
Now in Internet Explorer its different.. whenever event is fired by ATL COM
Event Message Box is shown many times in the Internet Explorer and everytime the count is getting increased
What can be the problem...
with regards
Abhiraj
|
|
|
|
|
Why are you firing the event manually using IDispatch::Invoke . The ATL wizard generates that code for you when you select the “Implement Connection Point…” option in the IDE.
Steve
|
|
|
|
|
I am not firing the event manually.. i am using the code generated by the ATL Wizard as such..
For firing event from worker thread .... microsoft has given link to be implemented for the same thats the only change i have done and rest of the code i have not touched...
with regards
Abhiraj
modified on Wednesday, May 7, 2008 12:27 AM
|
|
|
|
|
Hi all!
I would like to serialize/deserialize a std::vector of objects of a class into some buffer of a stream or of some other buffer. Can you address me about how to do this with the highest performance possible?
If I had an ARRAY of these instances..I would switch to a std::vector using this code:
CMyClass d[20];
// fill the array!
std::vector<CMyClass> v(d,d+sizof(d)/(d[0]));
What in case I use deserialization from a stream?
Is there a way to let the std::vector copy or use itself access the buffer
of a stream?
I would like to avoid the istream::read line below to go faster..do you know some way or address some nice super STL feature?
CMyClass d[20]; // buffer is created continuosly
istream::read( d, 20 ); // copy data from the buffer ( IS AVOIDABLE? )
std::vector<CMyClass> v( d,d+sizof(d)/(d[0])); // get the std::vector
Kind Regards
ManuStone
|
|
|
|
|
Assuming CMyClass has a std::istream extractor, you could use this to read from a file called "a.a"
std::ifstream is("a.a");
std::vector<CMyClass> v;
std::copy(std::istream_iterator<CMyClass>(is), std::istream_iterator<CMyClass>(), std::back_inserter(v));
|
|
|
|
|
Thank you Stuart
I will test it immediately!
Actually what I would like to achieve is to directly move an entire block of data from the stream to vector someway!
I have doubt that std::copy probably might be slow, but I have to test it before saying that
Have a nice evening!
ManuStone
|
|
|
|
|
I am working on a button that has a custom shape, and I wanted to give the user the option to match the button color scheme used by XP. I was planning to fill the button region with a gradient matching the current XP theme.
I asked this question on the Yahoo WTL forum. The answer makes writing a custom shaped button a little more difficult.
I am trying to use theme colors in XP to draw a gradient background
that is not rectangular. I am utilizing atltheme.h to call
GetThemeColor(BP_PUSHBUTTON, PBS_HOT, TMT_GRADIENTCOLOR1, &c). I am
trying to retrieve just one gradient color at the moment. I've tried
using DrawThemeBackground for a button. The colors are correct, but
the shape cannot be changed to fit the region I am filling.
I've discovered that most theme parts do not return gradient colors.
(I am able to get some colors, just not the gradient colors.) Does
anyone know how to retrieve the gradient colors used to draw themed
buttons? Most of the examples I have found hard code the gradient
colors to look like the theme colors.
The answer I received:
Themed buttons are actually drawn using a template bitmap, so there are no
gradient colours to retrieve.
Is this documented some place? I searched using google and I've had no luck locating any references to bitmap templates used for buttons.
|
|
|
|
|
Jim Barry answered all of my questions on Yahoo WTL[^]. Many thanks to him.
Short answer: Oh yes, totally undocumented.
Jim's answer also made it clear to me why custom shapes are difficult to theme if you want to use the "Button" theme.
I am most grateful for Jim's quick and accurate answers.
|
|
|
|
|
Hello friends,
How can I use the VB.NET's library in VC++.
Any article that will give the clear idean on this problem.
Thanks in advance to all of you.
ritz1234
|
|
|
|
|
You could either try using COM interop[^], or you could check out how to use the /clr switch[^] with the C++ compiler.
--
Kein Mitleid Für Die Mehrheit
|
|
|
|
|
I developed a desktop application with WTL, which contains a toolbar. The tool bar was ceated like as following codes. It works well. But when I tried to modify the style of the toolbar and make it to be docable or vertical. I failed in all attempts. I wonder why it becaoms so difficult with WTL while it's very easy with MFC to modofy a toolbar from horozontal to vertical dynamically. I tried to look for useful sample codes from internet. But, failed to find any matching samples. I believe it's a simplist requirement for a toolbar to be docable or to present in vertical direction. There must be many developers who ever encountered the same confusion as me. Then how do they resolve thire problems?
Can anyone provide me some hints or contribute some of his samplke codes. I'll apprieciate so much. I attahched my sample. Can anyone help me to modify the toolbar into vertical or docable one? Thanks a lot in advance.
BOOL CreateToolBarCtlr(HWND hParent, CToolBarCtrl& toolBarCtrl, RECT rcBar, LPCTSTR lpszCaption) { ATLASSERT( hParent && lpszCaption); if(hParent == NULL || lpszCaption == NULL) return FALSE; <br />
ATLASSERT(toolBarCtrl.m_hWnd == NULL); <br />
if( toolBarCtrl.m_hWnd != NULL) return FALSE; <br />
DWORD dwStyle = CCS_NODIVIDER | CCS_NOPARENTALIGN | CCS_NORESIZE;<br />
dwStyle |= TBSTYLE_TRANSPARENT | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS |<br />
TBSTYLE_CUSTOMERASE; dwStyle |= ATN_CHILD_STYLE; <br />
toolBarCtrl.Create(hParent, rcBar, lpszCaption, dwStyle, 0); <br />
ATLASSERT(toolBarCtrl.IsWindow()); <br />
DWORD dwStyleEx = toolBarCtrl.GetExtendedStyle(); <br />
dwStyleEx |= TBSTYLE_EX_DRAWDDARROWS; <br />
toolBarCtrl.SetExtendedStyle(dwStyleEx); <br />
toolBarCtrl.SetButtonStructSize();<br />
toolBarCtrl.SetImageList(m_hImageList); return TRUE; }.
|
|
|
|
|
Hi, everyone
It's really urgent for me to learn more about how to create a vertical or docable toolbar with wtl. I'll apprieciate you so much if you give me any advice, even if give me any WTL forum URL, where I may found answers or solutions to my question.
Thanks a lot in advance.
|
|
|
|
|
HWND hWndToolBar = CreateSimpleToolBarCtrl(m_hWnd, IDR_MAINFRAME, FALSE, ATL_SIMPLE_TOOLBAR_PANE_STYLE| CCS_VERT | TBSTYLE_WRAPABLE );
That should get you a vertical toolbar. Or try viksoe.dk ( look for atldock or WTL Docked UI )or even here[^] on CodeProject.
|
|
|
|
|
Hi,
Charles, Thanks a lot for your reply. I tried according to your hint. But didn't get vertical toolbar. And I don't know what's wrong happened.
Can you contribute a sample WTL project which demonstrates the vertical tooblar implementaion.
You may also send it to me by Email to JackLin5168@gmail.com or JackLin5168@yahoo.com .
Thank you so much. Charles.
Jack. China
modified on Monday, May 5, 2008 3:27 AM
|
|
|
|