|
? What kind of scheme are you thinking about (just curious)?
PS: Of course I'm with you in preferring STL over CArray , but you already knew that
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Just a function object that calls delete, combined with for_each. Nothing fancy.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
I was looking into using the STL Vector template. But I read somwhere that compiling the STL with VC++ (I'm using the .NET version, but writing unmanaged code) gives a lot of warning, and because of compliance issues the MS compiler has problems with STL.
However, I also recall from some time ago that Dinkunware is the supplier of the MS STL library, however, doesn't the latest version of Dink, compile fine in VC++?!?!
But let me reevaluate my current design I may still switch over to "vector" if it greatly eases writing code and maintainence.
Code4Food
----
"There is no try; only do or do not"
-Yoda
|
|
|
|
|
Code4Food wrote:
But I read somwhere that compiling the STL with VC++ (I'm using the .NET version, but writing unmanaged code) gives a lot of warning, and because of compliance issues the MS compiler has problems with STL.
Um... no. The warnings you can get rid of with a pragma, and I doubt they exist in VC.NET, they have made major improvements to their STL implimentation. The major problem VC has is partial template specialisation, which STL does not rely on.
Code4Food wrote:
However, I also recall from some time ago that Dinkunware is the supplier of the MS STL library, however, doesn't the latest version of Dink, compile fine in VC++?!?!
Dinkumware learned to write an STL implimentation by providing one in VC6, and then made a fortune out of selling one that fixed all the bugs they wrote the first time around. I don't know if Dinkum wrote the newer STL in VC.NET, but it is overhauled and improved, not least being the addition of a hash_map.
Code4Food wrote:
But let me reevaluate my current design I may still switch over to "vector" if it greatly eases writing code and maintainence.
If you can still do that, I would certainly encourage it. I have written several STL articles on CP, as have others. That should get you pointed in the right direction. www.sgi.com/tech/stl ( from memory ) is the best online source of STL docs.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Christian and Joaquin I just want to say thank you to the both of you for your help and excellent advice. I currently evaluating my first project and think I can implement it without drastic changes.
The only thing I may have concern with is the reason I think I chose CArray is the built in Serialization support for MFC (I know MFC please don't look down upon me ) But if that was the case it must really be really lazy for me not to go out and just right my own file i/o function for the class... But as I get older I get lazier
Code4Food
----
"There is no try; only do or do not"
-Yoda
|
|
|
|
|
Code4Food wrote:
(I know MFC please don't look down upon me )
*grin* I did MFC work for about 18 months. I don't think it's ALL terrible, but the container classes were only ever written as a stopgap while the STL came to VC.
Code4Food wrote:
But as I get older I get lazier
Choosing the best solution is half the problem, but the best solution should be the one which will work best, and hopefully that means it provides the most built in support. That's the reason I recommend STL - I'm too lazy to write my own functions for sorting, etc.....
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
How can I do do for using it in a structured project ?
Best Regards
youssef
|
|
|
|
|
I am looking to make a view in my MFC MDI application that is a list of bitmaps that have captions under them. This would be a dockable window that opens up when the program starts. I have a dockable toolset that I can use, but I'm not sure how to go about making a scrollable window that has these bitmap icons in them. I want to be able to have this view on the left side, and when you click on a particular bitmap the right side view changes to reflect your selection. I'd also like to be able to grey out certain icons to disable them from my program. Any ideas?
Jeff Rothenberg
Project Engineer
Vector CANtech, Inc.
|
|
|
|
|
Maybe Rex Fong's Thumbnail Picture Control[^] could be a good starting point.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
In a UI thread..
I was wondering if I am doing this correctly... In run() I call a function.. at the end of that function I call AfxEndThread(0,TRUE); Is this what I am supposed to do to close the thread from with-in it's self? If I do it this way how can I tell if ExitInstance() is being called?
BOOL CMyThread::InitInstance()
{
return TRUE;
}
int CMyThread::Run()
{
SomeFunction();
return CWinThread::Run();
}
void CMyThread::SomeFunction()
{
AfxEndThread(0,TRUE);
}
int CMyThread::ExitInstance()
{
return CWinThread::ExitInstance();
}
Thanks!
Rob
|
|
|
|
|
I think UI is the wrong thread model to use it here, and probably you're better off launching a worker thread. CWinThread::Run is almost never overriden, as it implements by default a message pump: UI threads are expected to do whatever stuff they're required in message handlers just the same way as regular CWnd objects in the main thread. If all you want to do is run some task involving no UI and then exit, use a worker thread like this:
UINT SomeFunction()
{
}
...
AfxBeginThread(SomeFunction,NULL);
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I use winsockets in my UI thread.. I need the message pump (I think).. Should I call the SomeFunction() in my OnInit instead of run? If so whats the best way to have the thread self terminate?
|
|
|
|
|
Yes, CSocket s need to be used inside UI threads, but your approach won't work (IMHO) for the following reason: if all the processing is to be done inside SomeFunction (as it seems your intention since you mean to terminate the thread when SomeFunction exits), the message pump implemented by the thread won't have a chance to process any message, thus CSocket s just won't do anything.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I have a server setup like this already and everything seems to be working fine.. listening, accepting, sending, receiving etc.. It's a little more complicated that what I posted.. I was basically just wondering how to close the thread properly so that all my clean up code runs on the ExitInstance()..
I have read that AfxEndThread is the way to go and I have also read that you are not supposed to use it.. I'm just a little confused.
|
|
|
|
|
Well, if you say your scheme is working, I guess I'm missing something Anyway, AfxEndThread is the perfect way to end the thread. ExitInstance should be called: to make sure, just put a breakpoint there and check it out.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for taking the time to respond
I really appreciate it.
Rob
|
|
|
|
|
Wait wait. Seems I've given advice too carelessly. After googling around, the subject is not entirely clear to me either. My (tentative) conclusion is that AfxEndThread should be called if CWinThread::Run has not run yet (i.e. in InitInstance ) and PostQuitMessage should be called otherwise. I think this could be ascertained by looking at the source code for CWinThread , alas I don't have it handy right now. I'll check it out tomorrow morning (CET). Regards,
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I have an application running on a different virtual desktop than the default one. Somehow, I need to open a browser on the default virtual desktop to a URL.
I can get a handle to the default desktop by doing this:
HDESK hdesk = OpenDesktop("default",0,FALSE,DESKTOP_ENUMERATE);
if( hdesk )
{
CloseDesktop(hdesk);
} I'm wondering if there is something I can do with hdesk to accomplish this. Or if there is another method that might work better (short of writing a desktop taskbar tray application, and posting a custom message to it)?
Any ideas appreciated!
|
|
|
|
|
Not sure if this will work but you could try..
ShellExecute(hDesk->GetSafeHwnd(),NULL,"www.yahoo.com",NULL,NULL,SW_SHOW);
Rob
|
|
|
|
|
Hi all.
I'm working on a large project that does two things I wouldn't do, it if were up to me:
1 -- Radio buttons remain enabled even when conditions exist that prevent the selection of the corresponding option
2 -- When users select an enabled radio button and the corresponding option is not available, a message box is genereated from within the radio button handler, informing the user that he/she cannot make that choice. After this, selection is returned to the previous radio button.
Although non-standard, this works fine when the user CLICKS the radio button in question. If, however, the user uses an arrow key to move from an adjacent radio button, the action sets off a recursive loop. Strangely, this loop repeats a limited number of times (14, in the case I'm working on).
Using breakpoints to step through the code, I can see that the flow goes directly from the dismissal of the message box to the top of the radio button handler, without executing the rest of the handler code. The recursion has nothing to do with the code that re-selects the previous radio button.
Again -- this happens ONLY when using an arrow key to select the radio button. It does NOT happen with a mouse click on the radio button.
Any ideas on what is causing this, or how I can prevent it?
Thanks!
David
|
|
|
|
|
Hmmmm, I find it tough to decipher what's causing the problem without looking at your code. Any chance you can post it?
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
|
|
|
|
|
I just tried out your scenario on a "doodle" dialog box I have and amazingly was able to reproduce your problem exactly! .
I don't have an answer as to why it's happening, but my guess is that it has to do with the fact that when you use the arrow key the focus is also changed and that also causes the handler to be called. After you click OK on the message box, the focus goes back to the radio button and it causes the handler to be called again...
Anyway, the way I fixed it is:
void CDoodleDlg::OnRadio2()
{
UpdateData();
if (m_nRadioTest == 1)
{
m_nRadioTest = 0;
UpdateData(FALSE);
MessageBox("Hey, isn't it obvious that you shouldn't click on Radio 2?");
}
}
Note that I assigned m_nRadioTest inside the Class Wizard for Radio1 and Radio2 (which are grouped together).
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
|
|
|
|
|
Hi Alvaro.
Thanks! You put me on the right track.
I had already tried returning the button selection before popping the message, but your example reminded me that the established routine for this resets the "check" without using a member variable for the radio button group (ah, legacy code!). When I do it your way, the handler repeats once, but not recursively, so I can use a static variable and GetTickCount() to filter out the second call. Kludgy, but it will do.
At least three good-karma credits for you!
David
|
|
|
|
|
Can anyone tell me how to go about resizing a static control according to text size dynamically? Thanks in advance...btw using SDK and not MFC.
|
|
|
|
|
Use DrawText() with DT_CALCRECT to determine the required dimensions.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|