|
I found only one article on codeproject is using CCmdTarget for finding sink for AfxConnectionAdvise((LPUNKNOWN)s_pFrameWB,DIID_DWebBrowserEvents2,pUnk,FALSE,dw);
I know that I have to use interface DWebBrowserEvents2.
But for which It requires CCmdTarget,which is mfc class.
I am trying to monitor IE with help of toolbar, so I am using pure atl,com and not mfc.So what is alternative way to monitor events.I have IWebBrowser2 object in my hand.
|| ART OF LIVING ||
|
|
|
|
|
To handle those events in ATL, you need to derive a class from IDispEventImpl and add a sink map handling the events you want. Here's some incomplete code that handles mouse over and mouse out events from a browser window embedded as a control:
class MyView : public CWindowImpl<<small>My</small>View, CAxWindow>,
public IDispEventImpl<1, MyView, &DIID_HTMLElementEvents2, &LIBID_MSHTML, 4, 0>
{
public:
typedef IDispEventImpl<1, MyView, &DIID_HTMLElementEvents2, &LIBID_MSHTML, 4, 0> HTMLElementEventsSink;
BEGIN_SINK_MAP(MyView)
SINK_ENTRY_EX(1, DIID_HTMLElementEvents2, DISPID_HTMLELEMENTEVENTS_ONMOUSEOVER, OnMouseOver)
SINK_ENTRY_EX(1, DIID_HTMLElementEvents2, DISPID_HTMLELEMENTEVENTS_ONMOUSEOUT, OnMouseOut)
END_SINK_MAP()
BEGIN_MSG_MAP_EX(MyView)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
END_MSG_MAP()
private:
</code><code> void __stdcall OnMouseOver(IHTMLEventObj* pEvent);
void __stdcall OnMouseOut(IHTMLEventObj* pEvent);
</code>
<code> LRESULT OnCreate(UINT , WPARAM , LPARAM , BOOL& )
{
if (SUCCEEDED(QueryControl(&pWB2_)) &&
SUCCEEDED(pWB2_->get_Document(&doc_)) &&
</code><code>SUCCEEDED(</code><code>doc_->get_documentElement(&docElem_)))
{
HTMLElementEventsSink::DispEventAdvise(docElem_);
}
}
LRESULT OnDestroy(UINT msg, WPARAM wParam, LPARAM lParam, BOOL &)
{
if (docElem_)
{
HTMLElementEventsSink::DispEventUnadvise(docElem_);
docElem_.Release();
}
}
CComPtr<IWebBrowser2> pWB2_;
CComQIPtr<IHTMLDocument3> doc_;
CComPtr<IHTMLElement> docElem_;
};
You'll need to call HTMLElementEventsSink::DispEventAdvise to tell IE that you want to handle the events, using an appropriate IDispatch pointer to say which objects events you want.
|
|
|
|
|
Hello,
I've been trying to use a chevron is a toolband for IE. I've managed
to get the chevron up... But I'm facing a few problems.
1. When the browser is smaller than the specified size... The chevron
is shown. When I maximize it, the buttons which were shown in the
chevron aren't shown on the band. If I start the browser as a
maximized window, the buttons are shown properly in the chevron when I
reduce the size & the buttons are again shown properly when the size
is maximized. Basically, if the chevron is shown when the browser
comes up, the buttons aren't shown when the browser window is
maximized.
2. I'm unable to capture the RBN_CHEVRONPUSHED message. I've tried sub
classing using a ATL::CContainedWindow object. But I am unable to
initialize it's m_pObject data member... which is a CMessageMap
derived object. I haven't come across any help online which would help
me out with this.
Anyway, the chevron is shown as a dumb menu... Which doesn't function.
(which means that I'm not getting the WM_COMMAND messages)
Any help would be appreciated.
Vikhyat
|
|
|
|
|
Hi!
I need to pass a series of raw bitmaps in memory from c++ to VB (and then from VB to c++). Does anyone know how to do this? I am trying to encapsulate all the functions in a ActiveX, so i think i should pass my raw unmanaged c++ data to an Interface like IPicture or something like that.
Thanks a Lot!
JO.
JO
|
|
|
|
|
Ju@ncho wrote: Hi!
I need to pass a series of raw bitmaps in memory from c++ to VB (and then from VB to c++). Does anyone know how to do this? I am trying to encapsulate all the functions in a ActiveX, so i think i should pass my raw unmanaged c++ data to an Interface like IPicture or something like that.
You can use the function OleCreatePictureIndirect to create an IPicture wrapper around a bitmap. I think there are members of IPicture that allow you to render it to a bitmap to do the reverse.
Nathan
|
|
|
|
|
Hi All
I have developed an MMC sanp-in.there is a printer node in left pane,when I click on the printer,it displays jobs in that printer in right pane(result view).
I want to extract the index of the item selected in right pane(result view).I have to enable a menu on selecting a row in result view based on the value os a sub item in result view..
Plzzzz help me...
Thanks in Advance.
Rashmi Kushwaha
-- modified at 7:55 Monday 22nd October, 2007
|
|
|
|
|
It's not urgent for us so refrain from adding "Urgent", "please help me" or any one of a number of things which will guarantee you getting no answer.
|
|
|
|
|
Hi
I have some atl project with ctrl and I want to add CP support for this.
When I create project I don't set check for CP support and now I don't understant how to do it.
I try to implement interface. But after that in "add CP" menu VC2003 dont show this interface.
I try to create new project whith CP support and find differences, but this projects completely different. In project w/o CP I work with my ctrl directly in project with CP I must work throught CContainedWindow but I can't register (or something) my ctrl... overall CContainedWindow("MyCtrl", this, 1) - didn't create any window.
How to add CP support in project?
Thanks, Anton
|
|
|
|
|
Add support for the following Interfaces in yours coclass.h:
Class ATL_NO_VTABLE YourCoClass:
...
public IConnectionPointContainerImpl<yourcoclass>,
public CProxy_IXXXEvents<yourcoclass>,
...,
Public IXXX
{
....
//ADD THE CONNECTION POINT MAP
BEGIN_CONNECTION_POINT_MAP(CCoRectangle)
CONNECTION_POINT_ENTRY(__uuidof(_IXXXEvents))
END_CONNECTION_POINT_MAP()
Add also the following definitions in your .IDL File
library XXXX
{
[
uuid(/*GENERATE NEW UUID WITH CREATE GUID*/),
helpstring("_IDrawEvents Interface")
]
dispinterface _IDrawEvents
{
properties:
methods:
};
...
coclass YourCoClass
{
[default] interface IXXX;
[default, source] dispinterface _IXXXEvents;
}
}
I hope it was usefull
Any doubts, please ask
JO
|
|
|
|
|
Hi!
I've this problem.I've to do a in process COM server in C++;the server has to send in real time as fast as possible a vector of six elements produced by a stand alone application (written in C++) to a MATLAB client. MATLAB client can't read the new value of vector untill the application does not write new one.
Can you suggest me a possible solution?
Thanks.
DanyCode
DanyCode
|
|
|
|
|
Hi,
I think you can encapsulate the C++ code in an activeX, and pass the data like a VARIANT but i dont know if it will be fast enought.which is the Bandwith required?
See http://www.codeproject.com/cpp/variantarray.asp for a library to pass vectors from unmanaged c++ code to managed MATLAB code
If you are using MATLAB you can also try to make an sfunction with the c++ code (see
c++ sfunctions in the matlab help).
JO
|
|
|
|
|
Hi Im working on ListCtrl(ATL Controls) in which i need to add images(Icons) to subitem other than 0th index.I was trying from couple of dayz.Plz help me if u have any idea..
thanks & Regards,
srihari.
|
|
|
|
|
I don't think there's a built-in way that you can add images to sub-items in a list view. I suspect the only way you can draw the images that you want is by using custom draw - see this MSDN page[^].
|
|
|
|
|
|
Hi,
I want to convert the string into german currency format eg.
in US 21,666.56 in German 21.666,56
in US 177.66 in German 177,66
please revert me with a good solution.
vijay
|
|
|
|
|
If you're ignoring any currency symbols, just imbue input and output streams with appropriate locales:
std::string in("17,456.43");
std::istringstream in_us(in);
</code><code></code><code> in_us.imbue(</code><code>std::locale("English_USA")</code><code>);
double value;
in_us >> value;
std::ostringstream out_de;
out_de.imbue(</code><code>std::locale("German_germany")</code><code>);
out_de << std::fixed << std::setprecision(2) << value;
std::string out = out_de.str();
If you need to read and write currency symbols (by which I mean 'USD' for dollars, 'EUR' for Euros), then you need to use the money_get and money_put facets:
<code> std::string in("USD17,456.43");
std::istringstream in_us(in);
in_us.imbue(std::locale("English_USA"));
</code><code> long double value;
</code><code> std::ios_base::iostate state;
std::use_facet<std::money_get<char> >(std::locale("English_USA")).get(std::istreambuf_iterator<char>(in_us), std::istreambuf_iterator<char>(), true, in_us, state, value);
std::ostringstream out_de;
out_de.imbue(std::locale("German_germany"));
out_de.flags(out_de.flags()|std::ios_base::showbase);
std::use_facet<std::money_put<char> >(std::locale("German_germany")).put(std::ostreambuf_iterator<char>(out_de), true, out_de, out_de.fill(), value);
std::string out = out_de.str();</code><code>
|
|
|
|
|
Hi - I don't quite understand the last two arguments of STL Map constructor
template <<br />
class Key, <br />
class Type, <br />
class Traits = less<Key>, <br />
class Allocator = allocator<pair <const Key, Type> > <br />
> <br />
Reference hereclick here[^]
I am searching for "less" template function - but Google returns millions of returns.... ALso. I don't understand the syntax (I know template...some) but
pair<const key,="" type=""> .... why "const"? that "pair" cannot change "Key"? Is that what it means?
Thanks.
|
|
|
|
|
devvvy wrote: ALso. I don't understand the syntax (I know template...some) but
pair .... why "const"? that "pair" cannot change "Key"? Is that what it means?
Yes, the const means the key can't be changed in place. One of the design philosophies of STL’s contains is to only support efficient operations. A std::map is implemented as a binary tree and changing the key would require the entry to be removed from the tree and reinserted into a new position. This would also invalidate all iterators referring to the modified item. In short, it’s a consequence of the underlying data structures used.
Steve
|
|
|
|
|
less is a template structure implementing a function object, not a function - see the MSDN docs here[^].
|
|
|
|
|
Before I move to draw my owner draw combox I want some suggestion.
Is it possible to control/draw the arrow part of combobox?
Is it possible to control the color of arrow part?
Is it possible to control the width and height of comboxbox or just I have to accept what is supplied.
I know it is possible to change color of textbox part and listbox part.
Based on this answer I have decide do I need ownerdraw combobox or (make my own combobox by as edit box and list box linking together)
I will appreciate your thought.
Thank you
msc
|
|
|
|
|
Hi All
Is it possible to implement drag and drop of nodes in MMC snapins...
if yes..is there any clue..how..plz help me.,...
Thanks in Advance
Rashmi Kushwaha
|
|
|
|
|
|
Are you using VC++ 2005 Express? If so, you're out of luck - Microsoft don't ship ATL or MFC with the Express version - you need a paid-for version (Standard or Pro).
If you're not using VS2005 Express, try re-installing VS2005 - it does come with atlbase.h - I just checked.
|
|
|
|
|
|
Make sure the ATL/MFC include directory is in the include path:
1. Open Tools->Options
2. Expand the 'Projects and Solutions' branch of the tree in the options dialog.
3. Select VC++ Directories in the tree in the options dialog.
4. In the 'Show directories for:' combo-box, select 'Include files'
5. Check if the directory string '$(VCInstallDir)atlmfc\include' is in the list of include directories. If not, add it.
|
|
|
|