|
Hi all,
I wanted to write a browser plugin. In Firefox, I could simply write some javascript with XUL to get things to work. In Internet Explorer, from my online searching, it seems that I have to write ATL code if I want a toolbar with buttons (Explorer Band)?
Now writing Javascript for one and ATL for other seems like a lot of repeatation. I would like to use Javascript for both. Is it possible to simply write a toolbar in ATL and call some javascript code for the toolbar buttons to manipulate window elements? If so, how can I call the Javascript from ATL?
Please guide.
Viv.
|
|
|
|
|
whizdom wrote: I wanted to write a browser plugin. In Firefox, I could simply write some javascript with XUL to get things to work. In Internet Explorer, from my online searching, it seems that I have to write ATL code if I want a toolbar with buttons (Explorer Band)?
Now writing Javascript for one and ATL for other seems like a lot of repeatation. I would like to use Javascript for both. Is it possible to simply write a toolbar in ATL and call some javascript code for the toolbar buttons to manipulate window elements? If so, how can I call the Javascript from ATL?
There is a set of Windows Scripting Engine objects and interfaces. I think the appropriate COM object has a progid of "JScript" and implements IActiveScript. You will need to implement an object with IActiveScriptSite. The stuff is fairly complicated, so it'll take some time to learn.
I'm impressed that you can get XUL to work. I tried to make a program to run on Seamonkey, and I've given up on it.
Nathan
|
|
|
|
|
Thanks Natan. Sorry for the late reply -- i got swamped with other things for a few days.
I'll look into learning the stuff. I had trouble with XUL as well, however, thanks to a couple of resources online, I could get basic stuff to work. If you like I'll get you some useful links -- since this is an ATL forum, I'll avoid posting them here.
ATL does seem a little involved... I guess it'll take me a bit of getting used to the syntax and conventions.
|
|
|
|
|
I use STL at work, but "lazy" way, i.e. it works, and who cares about performance, right ? So I know only basics about STL. Now I'm currently writing heavily multithreaded program for my own good. For the sake of fast development at this stage I opted to use STL. And then I noticed during debugging, that STL iterators call Critical Section locking, which causes a lot of slow down. I then delved (very briefly) into STL code and saw that they are really using CS for the iterators. I immediately dropped STL from the project, thanks to the fact that I use only arrays, not lists or maps, and there are plenty straight-forward-no-hidden-things implementations of templated arrays out there. But now I'm curious: when exactly STL iterators use CS locking? Is it for non-const iterators only? Is it for in-between-threads access? Or always? I'm too lazy and too busy to dive deep into STL code to check this, and it's not relevant to the project anymore, but out of curiosity it is very interesting, and might be useful for others who strive for performance and use STL.
Thank you in advance!
P.S. Forgot to mention: I use MS implementation of STL (VC++ 2005).
SY-
Kosta.
|
|
|
|
|
As far as I know STL does not do any critical section locking as that is left up to the application developer. We use STL (STLPort) extensively for high-performance server-side applications and find its performance outstanding.
As far as thread safety goes I would look at the Adapative Communication Framework (ACE). This library has reader/writer locks so readers don't block each other accessing a cache but a write blocks all readers. If you have a cache that is primarily read-only then this is quite and efficient mechanism.
Pax Domini sit semper vobiscum
|
|
|
|
|
I think I (almost) found answer to my own question.
Here is code:
#if _HAS_ITERATOR_DEBUGGING
void _Orphan_range(pointer _First, pointer _Last) const
{ // orphan iterators within specified (inclusive) range
_Lockit _Lock(_LOCK_DEBUG);
const_iterator **_Pnext = (const_iterator **)&this->_Myfirstiter;
while (*_Pnext != 0)
if ((*_Pnext)->_Myptr < _First || _Last < (*_Pnext)->_Myptr)
_Pnext = (const_iterator **)&(*_Pnext)->_Mynextiter;
else
{ // orphan the iterator
(*_Pnext)->_Mycont = 0;
*_Pnext = (const_iterator *)(*_Pnext)->_Mynextiter;
}
}
#endif /* _HAS_ITERATOR_DEBUGGING */
It's all over STL code, but it looks like locking happens only during 1) Debug Mode and 2) MultiTreaded application.
|
|
|
|
|
hi!
i want to use an activex control in my ATL project, i don't use MFC in this project(ATL Project). how do i do this?
must the activex be a Windowless?
Is there any sample to use an activex in ATL Project?
Zo.Naderi-Iran
|
|
|
|
|
If you're putting it in a dialog, use CAxDialogImpl to implement the dialog instead of CDialogImpl . Here's an example - it encapsulates a dialog that instantiates the Web browser ActiveX control as 'IDC_ABOUT':
#include <exdispid.h>
class CAboutDlg: public CAxDialogImpl<CAboutDlg>,
public IDispEventImpl<IDC_ABOUT, CAboutDlg, &DIID_DWebBrowserEvents2, &LIBID_SHDocVw, 1, 1>,
{
public:
CAboutDlg();
virtual ~CAboutDlg()
{
if (pWbAbout_)
{
BrowserDispEventImpl::DispEventUnadvise( pWbAbout_ );
}
}
typedef IDispEventImpl<IDC_ABOUT, CAboutDlg, &DIID_DWebBrowserEvents2, &LIBID_SHDocVw, 1, 1> BrowserDispEventImpl;
enum {IDD = IDD_ABOUTBOX};
BEGIN_MSG_MAP(CAboutDlg)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
END_MSG_MAP()
BEGIN_SINK_MAP(CAboutDlg)
SINK_ENTRY_EX(IDC_ABOUT, DIID_DWebBrowserEvents2, DISPID_DOCUMENTCOMPLETE, OnDocumentComplete)
END_SINK_MAP()
private:
LRESULT OnInitDialog(UINT , WPARAM , LPARAM , BOOL& )
{
CenterWindow();
aboutMessage_ = GetDlgItem(IDC_ABOUT);
CComPtr<IAxWinAmbientDispatch> spHost;
HRESULT hr = aboutMessage_.QueryHost(IID_IAxWinAmbientDispatch, (LPVOID*) &spHost);
if(SUCCEEDED(hr))
{
spHost->put_AllowContextMenu(VARIANT_FALSE);
spHost->put_DocHostFlags(DOCHOSTUIFLAG_DIALOG | DOCHOSTUIFLAG_NO3DBORDER | DOCHOSTUIFLAG_DISABLE_HELP_MENU);
}
if (SUCCEEDED(aboutMessage_.QueryControl(&pWbAbout_)) && pWbAbout_)
{
if (FAILED(BrowserDispEventImpl::DispEventAdvise ( pWbAbout_ )))
{
pWbAbout_ = 0;
}
else
{
pWbAbout_->put_RegisterAsBrowser(VARIANT_FALSE);
pWbAbout_->put_RegisterAsDropTarget(VARIANT_FALSE);
pWbAbout_->put_AddressBar(VARIANT_FALSE);
pWbAbout_->put_Offline(VARIANT_TRUE);
pWbAbout_->put_Resizable(VARIANT_FALSE);
pWbAbout_->put_Silent(VARIANT_TRUE);
pWbAbout_->put_MenuBar(VARIANT_FALSE);
pWbAbout_->put_StatusBar(VARIANT_FALSE);
pWbAbout_->put_ToolBar(VARIANT_FALSE);
CComVariant v;
pWbAbout_->Navigate(<default 'about' URL>, &v, &v, &v, &v);
}
}
return 0;
}
void __stdcall OnDocumentComplete(IDispatch* pDisp, VARIANT * URL)
{
}
CAxWindow aboutMessage_;
CComPtr<IWebBrowser2> pWbAbout_;
}; If you want your Active X control to be a window in a view, you just need to use CAxWindow, like so:
class CBrowserView : public CWindowImpl<CBrowserView, CAxWindow>
{
public:
CBrowserView() {}
virtual ~CBrowserView() {}
DECLARE_WND_SUPERCLASS(NULL, CAxWindow::GetWndClassName())
BEGIN_MSG_MAP_EX(CBrowserView)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
END_MSG_MAP()
private:
LRESULT OnCreate(UINT , WPARAM , LPARAM , BOOL& )
{
DefWindowProc();
CComPtr<IAxWinAmbientDispatch> spHost;
if(FAILED(QueryHost(IID_IAxWinAmbientDispatch, (LPVOID*) &spHost)) || !spHost)
{
OutputDebugString("CBrowserView::OnCreate - QueryHost failed\n");
return -1;
}
if (FAILED(QueryControl(&pWB2_)) || !pWB2_)
{
OutputDebugString("CBrowserView::OnCreate - QueryControl failed\n");
return -1;
}
return 0;
}
CComPtr<IWebBrowser2> pWB2_;
};
The type of Active X control created is specified when you call the Create method for the window - the window name is the ProgID or CLSID - see this page[^].
HTH!
|
|
|
|
|
hi,
edit: there is a short background explanation; but the problem is not outlook-specific
for an outlook-addin i need to get disp-events of outlook-items (IDispatch-based interface Outlook::ItemEvents)... which is fine as long as i just need the events of a fixed number of items (see below for a shortened code-example how i do it at the moment).
but now i need to connect to n items... and am as of yet clueless if there is a nice clean atl-way to do just that?
browsing the msdn-documentation for atl and googling didn't give me useful results so far
any hints and clues are appreciated.
class ATL_NO_VTABLE xyz :
...
public IDispEventSimpleImpl<1, xyz, &__uuidof(Outlook::ItemEvents)>,
...
{
...
typedef IDispEventSimpleImpl<1, xyz, &__uuidof(Outlook::ItemEvents)> MyItemEvents;
...
BEGIN_SINK_MAP(xyz)
SINK_ENTRY_INFO(
2,
__uuidof(Outlook::ItemEvents),
0xF006,
OnItemCustomAction,
&AtlCallDispatchDispatchBool
)
...
END_SINK_MAP()
...
}
modified on Friday, February 8, 2008 12:06 PM
|
|
|
|
|
Ummm - how about a simple object that encapsulates and inherits from a single 'IDispEventSimpleImpl<1, class-name, &__uuidof(Outlook::ItemEvents)> ', then have a collection of those, one for each object whose events you want to handle?
Can't think of a better way off the top of my head.
|
|
|
|
|
ah, sure... thanks. i guess i was just blind
|
|
|
|
|
Hi all
I have to copy elements of a std::vector at the end of a second std::vector.
What is the most efficient approach?
I think that method insert is not very efficient (am I right?);
what if I use copy in <algorithm>? If also this is not good,
what way can I follow?
Kind Regards
ManuStone
|
|
|
|
|
Does
insert(vec2.end(), vec1.begin(), vec1.end());
work?
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
manustone wrote: I think that method insert is not very efficient (am I right?);
what if I use copy in ?
Do you mean the copy constructor? I think performance is quite comparable to insertion method (as suggested by Steve Echols), but why don't you make a test?
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.
[my articles]
|
|
|
|
|
(Sorry for the delay)
Thank you very much for your response!
ManuStone
|
|
|
|
|
std::vector<t> vec1;<br />
std::vector<t> vec2;<br />
<br />
std::copy(vec1.begin(), vec1.end(), std::back_inserter(vec2));</t></t>
Pax Domini sit semper vobiscum
|
|
|
|
|
hi guys,
i m new to atl programming, i creating toolbar on rebar in which i add TBBUTTON with TBSTYLE_DROPDOWN , for button with seprate arrow for which i send message
SendMessage(TB_SETEXTENDEDSTYLE, 0, (LPARAM)TBSTYLE_EX_DRAWDDARROWS | TBSTYLE_EX_DOUBLEBUFFER );
which enlarge size of TBBUTTONs for this i send
SendMessage(TB_SETPADDING, (WPARAM )0, MAKELPARAM (setpaddingXaxis,setpaddingYaxis));
but on themechange from winXP to window classic style or vice-versa toolbar button size change drastically.
Is anyone know the solution of it...
thnx in advance.
|
|
|
|
|
hi friends,
i have created one ATL project and add one simple Atl class then, just add one class in list of inherianced classes in new simple atl class like below
class ATL_NO_VTABLE CSlider :<br />
public CComObjectRootEx<CComSingleThreadModel>,<br />
public CComCoClass<CSlider, &CLSID_Slider>,<br />
public IObjectWithSiteImpl<CSlider>,<br />
public IDispatchImpl<ISlider, &IID_ISlider, &LIBID_TabSlingLib, 1, 0>,<br />
<br />
public CWindowImpl<CSlider><br />
Then a got the error message like
error C2259: 'ATL::CComObject<Base>' : cannot instantiate abstract class
please help...
Thanks,
|
|
|
|
|
zakkas2483 wrote: Then a got the error message like
error C2259: 'ATL::CComObject<base />' : cannot instantiate abstract class
please help...
Thanks,
If you are using Visual Studio, you can switch from the tasks tab to the output tab, and you'll find the actual error message includes "Due to the following members..." and a list of the members that you need to override.
Nathan
|
|
|
|
|
I found surprisingly few articles that can help me about the subject. I simply want to have my program execute from the Windows Explorer context menu, and to have an icon with it. I found out that I can add an entry to *\\shell\\MyProgram, but I don't know how to associate an icon with it.
Could any one of you direct me to a nice article about this issue? I would like to do this in my own code, not to use some extension dll or something.
Thanks.
|
|
|
|
|
|
I have created an ATL control project which draws a polygon.
sides is the property wich takes input from user.
Inserted this control to MFC dialog.
when i tried to add variable for this control causes error as follows.
"Error: the Extender provider failed to return an extender for this object".
what does it mean?
|
|
|
|
|
Dear All,
Unable to convert CString to BSTR! Am I a stupid?!
I have an interface method which needs to convert CString to BSTR and return BSTR to caller.
AllocSysString of CString is not copying the data to BSTR.
STDMETHODIMP CTP_Interface_ErrorCode_Wrp::GetAdditionalDataFlag(BSTR *AddDataFlag)<br />
{<br />
AFX_MANAGE_STATE(AfxGetStaticModuleState())<br />
<br />
<br />
CString temp = pTP_Interface_ErrorCode->GetAdditionalDataFlag();<br />
*AddDataFlag = temp.AllocSysString();<br />
<br />
return S_OK;<br />
}
Any one please help me.
Thanks very much, Nani
|
|
|
|
|
You code looks correct.
How do you see that value is not copied? I mean have you used debugger or you just saw it on the client side?
BTW try first something simpler such as
CString temp(_T("foo"));
*AddDataFlag = temp.AllocSysString();
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.
[my articles]
|
|
|
|
|
Yeah. I am real crap!!!
I did everything correctly, but the debugger is giving some number instead of string.
I dont know why?!
I converted back from BSTR to CString in my client, and was able to print results properly.
Thank very much
|
|
|
|
|