|
|
you'll need to use LVM_GETNEXTITEM with the LVIS_SELECTED param.
(you should probably say "non-MFC" in your questions. that way i won't give you MFC answers )
-c
Cheap oil. It's worth it!
|
|
|
|
|
Thankyou.
|
|
|
|
|
Is there any way to call a member function from another member function with for_each.... ie:
class foo {
void foo() {
// create vector of ints
std::for_each( vec.begin(), vec.end(), bar );
}
void bar( int val ) {
// do stuff with val
}
}
Ive tried various things for the third param to for_each, eg foo::bar, &foo::bar. It only works when the function is static.
Thanks
Ben
|
|
|
|
|
mem_fun_ref
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
Can you expand a little on your answer? I have never heard of mem_fun_ref, what does it do? How do you use it?
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
It allows you to provide a member function to for_each
www.sgi.com has excellent STL docs, I'd only quote them, so better you go to the horses mouth, so to speak
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
THanks, I will check it out.
Thats usually where I go for my STL documentation anyway.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
foo::bar must be static, if not it expects the this pointer, which for_each cannot supply.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
mem_fun_ref and relatives have severe design flaws as for the const ness of their arguments, so you'll have to write some code yourself. The basic idea is to have an object presenting a normalized interface to for_each that forwards the call to the appropriate foo object and method. Just like this:
class foo
{
void foo()
{
std::for_each(vec.begin(),vec.end(),bar_stub(this));
}
void bar(int val)
{
...
}
struct bar_stub
{
bar_stub(foo* f):f(f){}
void operator(int val)
{
f->bar(val);
}
private:
foo* f;
};
};
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
The problem is not mem_fun_ref, but the implimentation in VC, I thought.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
Hi Christian! Well, the problem actually lies in bind1st (necessary to bind the 1st argument of mem_fun_ref to the object used,) whose signature is, according to the Standard Template Library Programmer's Guide:
template <class AdaptableBinaryFunction, class T>
binder1st<AdaptableBinaryFunction>
bind1st(const AdaptableBinaryFunction& F, const T& c); The const ness of the second parameter is what causes the problem.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
OK. I read an article in last months CUJ that led me to believe otherwise. I obviously did not read closely enough, or was feeling anti VC after finding out it does not impliment Koenig lookup properly.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
This time it is not VC++'s fault, but don't worry, we've got still plenty of stuff to blame it for
The bind1st and mem_fun problem is very well known among C++ geeks since long (do a search on the Usenet.) As always, Boost provides a remedy, check its Member Function Adapters section.
PS: Your sig is a real quotation?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
Your sig is a real quotation?
Yup - verbatim
Joaquín M López Muñoz wrote:
As always, Boost provides a remedy
Yes, the article in CUJ linked to Boost ( not surprisingly, I'd have expected them to have a fix ), then somewhat redundantly provided their own. They wisely suggested people use the Boost one over theirs, but why include it then ?
Still, CUJ lost credibility in my eyes when Herb Sutter provided a glowing review of a book they had previously reviewed already, a book written by someone he happens to be coauthoring a book with at the moment. That it's a good book does not stop that from sucking IMO.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
Maybe (i hope) this is a easy task to preform for most VC++ programmers, but i'm having dificulties in changing this kind of object's backcolor.
Can anyone help me?
Thank for your time!
|
|
|
|
|
|
I checked it, but, maybe because i used to VB, i found it a bit confusing because all the data type and all! Isn't there a easy way to do this?
Thank you!
|
|
|
|
|
Yes, the way that Nish told you. Welcome to the world of real programming languages.
There is most certainly an article on CP that shows you how to do this. Nish probably wrote it.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
Hello,
In order to display some graphic stats (bars, pies, ...), I integrated a MsChart in a dialog and I works fine. But now, I would like to be able to print this chart, so how can I do this ?
Thanks in advance.
DD
|
|
|
|
|
I dunno if there is some other way, but you could certainly get the DC of the control and pass it to the printer DC.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
hello,
thanks for answer, but as I am a quite new in VC++, I have to admit that I am not sure to understand your explanation and that I need some more details or even example/part of code.
Thanks
DD
|
|
|
|
|
Do you know how to print at all ? If not, you should probably check out some articles on the site. That's a lot of info to impart in a forum post.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
I can't say I am an expert in printing (for sure), I have just printed the content of a RichEditText control, so I have the basis to do it.
But there are a lot of ways to perform a print depending of a lot of facts (control type, etc).
I found a way to do it using the clipboard, but is there any other simplier way ?
DD
|
|
|
|
|
I did this awhile back. I tried the grab the DC approach and had limited success. I ended up using the clipboard approach, the control copies a WMF image to the clipboard. I really disliked this approach but it seemed to be the prescribed approach. If you want send me an e-mail to nwilhelmi@attbi.com and I can send you some code when I get home. The app was done with WTL so it will be WIN32api based and not MFC based.
NW
|
|
|
|