|
Take a look at ShellExecuteEx() in MSDN.
(Hint: you need the _T("open") verb.)
|
|
|
|
|
hi
do u know how can i disable expansion of what i've collapsed to definition which automatically occurs when i wait remaining on the line? i need not it to expand and want it to remain in the definition and collapsed until i manually toggle outlining.
thx
|
|
|
|
|
When determining if the value stored in an object is less than that stored in another object we define the operator ‘<’; how it is defined is very important. But how do you define the operator for a class with multiple data items, so that you get the correct results?
For reasons that I am not going to go into, we do not care what data is stored or what its actual value is. We simply need to be able to determine whether one object is less than another for the purpose of adding it to an STL container that requires the information.
One solution is to just do a simple ‘memcmp()’ , which does work under normal usage of this particular class. The reason it works is because the ‘data_type’ is normally an integral type.
The problem is that the data type is unknown, as the class is a template and the type is supplied by the user. If the data type is a class that contains no memory pointers, the above solution will still work. But if the data type is a class that contains a memory pointer, such as a ‘std::string’, then the above solution is invalid because comparing data pointers is not the same as comparing the data pointed to.
For the purposes of comparison, every piece of data (data_, f1_,…, and id_) must be used. The ‘memcmp()’ method produces the correct results for integral types, but every other method I have tried fails. The results of the comparison must be the same as that produced by the ‘memcmp()’ method.
Note that “(data_ < rhs.data_ || f1_ < rhs.f1_ || f2_ < rhs.f2_ || f3_ < rhs.f3_ || id _ < rhs.id _) ” does not work, nor other variations on that theme.
Example class:
class this_class
{
data_type data_;
bool f1_, f2_, f3_;
int id_;
public:
…
bool operator<(const this_class& rhs) const
{ return( memcmp(this,&rhs,sizeof(class)) < 0 ); }
};
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
try also sizof .
But, of course, you can't know the size of objects related to the class through pointers.
There isn't a solution, ... or, if you want, the solution is do not implement this operator, because it can't work correcty (as you tell) everytime.
Russell
|
|
|
|
|
Try the following:
data_<rhs.data_ ||<br>
(data_==rhs.data_ && f1_<rhs.f1_) ||<br>
(data_==rhs.data_ && f1_==rhs.f1 && f2_<rhs.f2_) ||<br>
(data_==rhs.data_ && f1_==rhs.f1 && f2_==rhs.f2_ && f3_<rhs.f3_) ||<br>
(data_==rhs.data_ && f1_==rhs.f1 && f2_==rhs.f2_ && f3_==rhs.f3_ && id_<rhs.id_)
Steve
|
|
|
|
|
Thanks, I was afraid something like that would be required. It works in debug mode, as it should, but fails in some cases in the release version; I need to look into why that is. Since the “operator<” may get called thousands of times in some cases I may make it a compile time option and stick to the “memcmp()” solution, as I suspect the call is cheaper than all those tests. I’ll need to run some tests to be sure.
I see no reason why anyone would use anything but built in data types in this class, but I would still like to leave the option open.
Thanks again.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
You could get the best of both worlds using something like Boost[^]'s TypeTraits[^] library. See this[^] example for an example of something similar (although not exactly what you want).
Steve
|
|
|
|
|
Thanks, I decided to go with the current solution (memcmp) and restrict the usage to integral types as per my original specifications. I tend to let my imagination run wild at times and was trying to add flexibility that even I would never use.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
I've been known to fall into that trap myself.
Steve
|
|
|
|
|
i've looked thru the official guid, very brief though...
|
|
|
|
|
Does this a c++ question ?
|
|
|
|
|
Hi every1, I need help related to image recognition using Genetic Algorithm.(GA)
Would greatly appreciate if anyone can send me any related information eg source code or notes that I can read or used as I am quite confused by the GA implementation in C++.
How an image is recognize/identified using GA?
Simple comparison like character recogntion, Neural network can performed task by training to identified the character, do GA able to perform similar task?
Can email to ray_luee@yahoo.com
Thanks
RayLuee
|
|
|
|
|
I have decided to bite the bullet and find out how to convince MFC that passing parameters to implement IMPLEMENT_DYNCREATE is feasible.
In a nutshell - IMPLEMENT_DYNCREATE access only the default constructor which has no parameters. Tiring to hack the RUNTIME_CLASS and the whole chain down to creation of the object is a nightmare.
The basic for this is that I have a need / want to use same view class with different "parameter". I am basically tired of building a copy of the view class and modifying its methods as required.
There are few articles in here which accomplish this using various approaches - RTTI, "Generic Class Factory" (no longer supported by the author) etc.
I am asking the forum to share experiences with these approaches.
Recommendations, comments etc.
Thanks for your help.
Vaclav
|
|
|
|
|
Hello all. So I have these three combo boxes. According to certain validations, I have to select one of them. I thought that simply calling CComboBox::SetFocus would be enough, yet it is not working. I also tried sending a WM_ACTIVATE messages to the combos, with the same results.
Any thoughts would be really appreciated. Thanks in advance.
FG.
Hope is the negation of reality - Raistlin Majere
|
|
|
|
|
From where you call this?
- NS -
|
|
|
|
|
From the CDialog::OnInitDialog method.
Hope is the negation of reality - Raistlin Majere
|
|
|
|
|
You should retun FALSE from OnInitDialog, if you explicitly set the focus. And use GotoDlgCtrl instead of SetFocus in Dialogs.
- NS -
|
|
|
|
|
I feel a little stupid now. I don't use wizads, but now that you mentioned it, I remebered this "return TRUE unless you're setting the focus" comment that the wizards places in the "return" of the OnInitDialog .
Thanks a lot!
Hope is the negation of reality - Raistlin Majere
|
|
|
|
|
This[^] article may interest you.
Steve
|
|
|
|
|
Thanks, very interesting indeed.
Hope is the negation of reality - Raistlin Majere
|
|
|
|
|
Hi,
I have a dialog based application, which should act as a CSocket server.
In short my need is, if some client is connected to the server, OnAccept of the CSocket should be directed to the dialog class member function.
I am not sure about the right method to do so.
Thanks in advance.
- NS -
|
|
|
|
|
You can store a CWnd*, HWND, or whatever is appropriate in your socket class and use
that to send messages to the window/dialog.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for the replay. Is this the only way?
I tried to dervie my dialog class from CDialog and CSocket. But failed...
- NS -
|
|
|
|
|
Do you really need them to be together? Why not separate another class and make that one your CSocket derived class? If your concerned on the variables/objects you need in your dlg class, just pass the class pointer to the CSocket class.
|
|
|
|
|
My concern is that then there will be a mapping from csocket class to the dialog class. I like to avoid it.
- NS -
|
|
|
|