|
Try handling the keystroke in the IOleInPlaceActiveObject::TranslateAccelerator method of your control. To test if this is the problem make an implementation that just returns S_OK and see if this stops IE from processing the keystroke when your control is active (it will...). I'm not sure how you've implemented your control (ATL, MFC, straight Win32, etc) so I can't be more specific.
Steve
|
|
|
|
|
thanks steve i will evaluate the posibility that u suggested
Azam
|
|
|
|
|
Hi All,
Can anyone tell me if a vector automatically sorts all its string entries in alphabetical order?
Thanks and Regards,
Anil
|
|
|
|
|
No it doesn't. You can sort it manually like this:
sort(vec.begin(), vec.end());
Or you could use a set or multiset .
Steve
|
|
|
|
|
Anil_vvs wrote: Can anyone tell me if a vector automatically sorts all its string entries in alphabetical order?
Try std::set instead of std::vector
|
|
|
|
|
std::set holds unique values. use std::multiset to emulate a sorted vector more closely..
Regards
Angel
*********************************************
The sooner you fall behind, the longer you have to catch up.
|
|
|
|
|
Do I need to create a window for an ActiveX component to display directshow video? If yes, what is the simplest way?
I have a directshow player, that I want to turn into an activex component.
The directshow player needs a windows handle of type HWND to display its image in that window.
I'm using ATL to create the ActiveX component. Currently I try to figure out, how to output my image on the surface of the activeX component.
- create a window or not?
- which handle to use?
// hand over the window handle
myVideo.setHwnd(hwnd);
// int the player
myVideo.initGraph();
// play
myVideo.playGraph();
|
|
|
|
|
Hi all,
I know STL enough to understand containers and iterators but going from Predicates to Unary/Binary and vice versa is a bit unclear to me.
I have
<br />
class CMyClass<br />
{<br />
public:<br />
inline CString GetID() const {return m_csID;}<br />
protected:<br />
CString m_csID;<br />
};<br />
Now suppose I want an array of CMyClass* and detect whether an object of a specified ID already exist. How can I use find_if ?
<br />
vector<CMyClass*> myarray;<br />
LPCTSTR lpszNewID = _T("NEWID");<br />
if (find_if(myarray.begin(), myarray.end(), IsID(lpszNewID)???) != myarray.end())<br />
Any idea how to implement and properly use the "IsID(LPCTSTR lpszID)" part?
Thank you
|
|
|
|
|
|
Thanks for the link, I have been looking for such reading material. And the download is free
|
|
|
|
|
Here's how I'd do it:
class IsID : public unary_function<CMyClass*, bool>
{
public:
IsID(LPCTSTR pID) : m_pID(pID) {}
bool operator()(const CMyClass *pClass) const
{
return pClass->GetID() == m_pID;
}
private:
LPCTSTR m_pID;
};
This code assumes the following (in addition to what you must already have):
#include <functional>
This is called a functor - It has a few important advantages over a normal function:
- It's can be called like a function but it can have state.
- It's faster - Most compilers can't inline through a function pointer but have no trouble doing do so via operator() (the application operator).
Steve
|
|
|
|
|
Wouldn't a "normal" function object work just as well? E.g.:
struct IsID
{
LPCTSTR id_;
IsID(LPCTSTR id) : id_(id) { }
bool operator()(const CMyClass* p) const
{
return pClass->GetID() == id_;
}
};
}
...
if (find_if(myarray.begin(), myarray.end(), IsID(string)) == myarray.end())
{
}
I am still relatively new to STL, so am keen to learn what advantages deriving from unary_function will give you. Do you have more details and examples?
|
|
|
|
|
Yeah this would work just fine but it's not "adaptable". STL functions such as bind1st and bind2st reply on certain typedef s (metadata if you like) being present to work. The simplest way to supply them is to derive from unary_function or binary_function .
Steve
|
|
|
|
|
True. I would just add that boost::bind does not require the typedefs, so if you are using boost, this is not an issue.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
Yeah, Boost's Bind and Lambda libraries add considerably to what can be done with STL alone.
Steve
|
|
|
|
|
Oh that's what I was missing! I have seen a lot of functors examples but they rarely had their own constructor. Thanks!
|
|
|
|
|
The find_if can work if you use a good smart pointer that uses value semantics for the comparison.
Check out the following link:
http://axter.com/smartptr
The above smart pointer uses value semantics, so that the pointee is compated instead of the pointer address.
Top ten member of C++ Expert Exchange.
http://www.experts-exchange.com/Cplusplus
|
|
|
|
|
hi all
i had make drawing. now i want that these drawing should be saved in bmp file or the jpeg file tell me how to do that or any other place such as picturebox where i can draw ans save as bmp file.
ddd
|
|
|
|
|
I found when I have subclassed a child control( like tree view control), the child cannot be sure it can receive all the WM_CONTEXTMENU message, sometimes the WM_CONTEXTMENU gone. but the parent dialog can always receive the WM_CONTEXTMENU. the message like notify message can be sent to child all the time.
Now I handle the WM_CONTEXTMENU in the parent, and then pass it to the child, this way is a little sucks.
Someone can help me to pass the WM_CONTEXTMENU to child?;P;P;)
Single Simple
Double Trouble
|
|
|
|
|
|
|
Hi
I want to pass a member function to the std::for_each algorithm but strguggling. I've seen where you can use std::mem_fun to bind a member function of the 'contained' class, but I want a member function of a different class...code below shows what I want to do and code after that shows my work around.
I could use a for..next loop, but don't think I should when these algorithms are so d*** neat!
What I want to do....
class myClass
{
private:
void DoSomethingWithString( std::string *pString );
public:
void Go()
{
std::set <std::string > myStrings;
myStrings.insert("ABC");
myStrings.insert("DEF");
myStrings.insert("GHI");
std::for_each(myStrings.begin() , myStrings.end() , );
}
};
and a work around....
class myClass
{
class DoStringThing
{
private:
myClass* m_class;
public:
DoStringThing( myClass* class_param) : m_class( class_param)
{
}
void operator()( std::string &filename)
{
m_class->DoSomethingWithString( &filename );
}
};
friend class DoStringThing;
private:
void DoSomethingWithString( std::string *pString );
public:
void Go()
{
std::set <std::string> myStrings;
myStrings.insert("ABC");
myStrings.insert("DEF");
myStrings.insert("GHI");
std::for_each(myStrings.begin() , myStrings.end() , DoStringThing(this) );
}
};
So, how can I call a member of the class that is executing the for_each...?
Regards
Angel
*********************************************
The sooner you fall behind, the longer you have to catch up.
|
|
|
|
|
Correct. Function object is a good solution in this example.
Kuphryn
|
|
|
|
|
Hi - thanks for the answer. I really want to know how to call a member function instead of using a functor.
Is it possible?
Cheers
Regards
Angel
*********************************************
The sooner you fall behind, the longer you have to catch up.
|
|
|
|
|
There are more elegant solutions with function objects.
Kuphryn
|
|
|
|