|
Hi Kuphryn,
I will grab these two references that you noted. And thanks for the comment on the way I'm doing it now, I appreciate your input!
Thanks very much,
Eric
|
|
|
|
|
Cloaca wrote:
Is it the case that I need to add additional structs under the private section of CFoo for each comparison CFoo member function I want to write [...]?
Yes. AFAIK every comparison need its own comparer (like you have with the NameComparer )
Cloaca wrote:
3) Why do I need to wrap the comparison functions in a struct? How does that fact relate to operator(), etc.?
struct does mean the same as class, but everything is public by default .
As you only want a class with only one public operator, writing struct instead of class does save you a whopping 6 keystrokes (7 for 'public' plus the ':', minus one because struct is longer than class .
I think that is the only reason.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
Hi jhwurmbach,
Thanks for your reply. That makes sense, but it then makes me wonder why I need a class (or struct) at all to hold the comparison function.
Why is it that I just can't declare the comparison function (just as a 'simple' member of CFoo ) and pass it to the stable_sort() call? I have been reading about operator() and functors, but I am not putting it all together yet, I guess. Does it have someting to do with the fact that functions passed to the algorithms can only have one parameter?
I appreciate your help, thanks again!
Eric
|
|
|
|
|
stds::sort is a template function. That means the arguments for the function determines what kind of code the compiler generates for the function (as opposed to a regular function, where the compiler always generates the same code). A template argument must be either a type or a constant--the compiler must be able to determine what the argument is at compile time, so it knows what code to generate. For the sort function, the template argument might have been a functor type or it might have been a constant that resolves to a function pointer. If you think about it, you can see how making the argument a type gives much more flexibility to the user of the template function, so that is the choice that the template designer made.
|
|
|
|
|
Hi antlers,
Ahh. I think that puts it together for me. A function is of course not a type. But by using the 'struct method', you kind-of wrap the function in a type. And so it is acceptable to the algorithm at compile time. The syntax of operator() is the way a wrapped function can be exposed to the algorithm for use in, for example, a sort call as a comparison.
And this minimal extra work is the small price to pay for a very flexible system of getting whatever might be needed into the templated algorithms. I see. Thanks very much for your help, I appreciate it!
Best,
Eric
|
|
|
|
|
Hello all
I've an application which is working well on win2000 & winXP. But when I ran the same application in win98 & winMe, it's leading to fatal crash and giving me blue screen.
In the case of fatal crash, how can we detect to which part of the application is causing it? I'm not able to debug this problem on win98 and winMe.
If anyone know abt any tools or techniques which can help me in debugging the problem, pls help me.
Many thanks for your help.
Hari.
|
|
|
|
|
haritadala wrote:
In the case of fatal crash, how can we detect to which part of the application is causing it?
Are you using/assuming something that is not available on non-NT machines?
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Hello David
Thanks for the reply. I'm not using or assuming something that's not on NT machines. My application is taking to devices connected to usb port. I'm using the driver supplied by third party vendor(this driver works on all windows machines, according to vendor). I'm able to send/receive data even on win98/winMe. But when I try to disconnect I'm experiencing fatal crash.
Any ideas as on how to debug this problem will be very much appreciated.
Many thanks for your help.
Hari.
|
|
|
|
|
It sounds like you need to contact the vender of the driver.
If all else fails try to find a memory validator or crash protect program, that can generate a report, even if the code is not available.
Once upon a time, I kept rejecting the release of a program based on the reports generated by Bounds Checker, since our sister would not release the
code to me in order to find the multple problems. Eventualy, they just turned the whole project over to me and it took months to find and fix all the problems.
INTP
|
|
|
|
|
How is it that you are unable to debug this on 98/ME?
Are you using .net/2003? If so, look into the remote debugging features of it, you should be able to debug that way....
Or is the blue-screen coming before any exceptions are trapped?
-p
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
Hello all
Thanks for the replies. I'm not using .Net/2003. I'm getting blue screen before any exceptions are trapped. I'm getting the following error
fatal error 0E at 0028:C0003E8C
I looked at microsoft knowledge base for these error but couldn't find the solution
Any ideas?
Thanks for the help.
Hari.
|
|
|
|
|
I think that there are many causes -- what exactly does your program do?
You can check out this site (click here)[^]-- for possible answers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
Hello,
I need to loop through a directory and pull each file name from the given directory.. This should be easy but I have no idea where to start.. Can someone point me in the right direction..
Thanks,
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
SDK: FindFirstFile, FindNextFile
MFC: CFileFind
Steve S
|
|
|
|
|
I looked at CFindFile earlier but this looks like a search function to me.. I don't see anywhy to tell it where to start looking.. I dont want to find all .rtf files on my machine just .rtf files given a directory to loop through.. Am I missing something? Can you set the init directory on CFindFile?
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Never mind my last post.. CFileFind works perfectly...
Thank you!
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Whew! I was beginning to think we were going to have to send it back for repair.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
|
is it possible to put a checkbox in CListCtrl header ? if so how can i do that?
Thanks in advance.
|
|
|
|
|
Subclass it and you can do almost whaterver you want with the control
For instance, make it custom draw, and draw a checkbox along with the header text. Or just set image list that has a checkbox images (checked/unchecked) and change header item image when necessary (check/uncheck). Then you'd have to process WM_LBUTTODNDOWN to detect if user clicked the check box and change the checkbox state. Handling keyboard messages might be good idea (WM_SETFOCUS/WM_KILLFOCUS/WM_KEYDOWN), to allow user navigate the control via keyboard
Edward
|
|
|
|
|
I recently wrote an application with multiple custom controls all of which are derived from CWnd. My problem is that when I resize one of the controls the internal controls overlap which is ok. My problem is that I want to set the order in which they are drawn(z-order) but can't seem to get it. Anyone?
|
|
|
|
|
Try to set WS_CLIPSIBLINGS style for the child windows
Edward
|
|
|
|
|
I understand the concept of clipping children when repainting child components. The problem in more detail is as follows. I have two child custom controls inside a parent custom control(all derived from CWnd). When I move or resize the parent window I also move the inner controls.
When they overlap I want to be able to set one of the components to be always on top, even when another control gets focus. The code is roughly as follows, when I move the parent window..
void CParentCrl::OnSize(UINT nType, int cx, int cy)
{
CRect aRect,bRect;
// Calculate new child rects(not shown)
.
.
.
child1.MoveWindow(aRect);
child2.MoveWindow(bRect);
}
now from here how do I endure that child1(or two) will always be drawn on top of the other control?
|
|
|
|
|
The CWnd::SetWindowPos() function allows you to specify z-order of windows.
Robert-Antonio
"Love without sex is like a fish without antlers"
|
|
|
|