|
It does indeed - well MFC deletes the CWinThread has died. There is an easier way than DuplicateHandle - set m_bAutoDelete in you CWinThread after its been created - just make sure you create it in suspended state
|
|
|
|
|
Hi.
Yeah, I have also just had a look at that.
Thanks for your reply.
Cheers.
|
|
|
|
|
Hi.
Thanks for all the replies.
Problem fixed, although I think that I might have to redesign the threads dispatch process when I need to use more than 64 threads, the current max defined on my system.
Thanks to all your responses...
|
|
|
|
|
you can set priority of ur thread so that they dont run so quickly using API SetThreadPriority()
Abhishek Srivastava
Software Engineer (VC++)
India ,Noida
Mobile no 9891492921
|
|
|
|
|
Hi All,
I just installed January 2004 MSDN help. I can use it from the start menu fine but not from the F1 key in visual studio. Am I missing a registry entry or something?
Appologies if this is the wrong forum, please redirect if it is.
Cheers,
Rob
<this signature="" intentionally="" left="" blank="">
|
|
|
|
|
IFAIK, newer versions of MSDN doesn't work with Visual Studio 6, only with 7.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
At one point during the MSDN install, they display a dialog box asking if you wish to integrate the MSDN with Visual Studio. If you have both VS.NET 2002 and 2003 installed, they have the 2002 checkbox cleared and the 2003 checkbox set by default. You may want to reinstall the MSDN and see if that's the problem.
As someone else has mentioned, versions of the MSDN Library after the October 2001 edition no longer integrate with Visual C++ 6.0.
Software Zen: delete this;
|
|
|
|
|
Hi Gary,
thanks for the reply, I hope you don't mind answering another question. Would you suggest that it is worthwhile upgrading from Visual Studio 6 (we have an MSDN subscription so I already have the software)? Can I continue to maintain VisualC++ 6 projects under vs.net, or can 6 and .net be installed on the same machine safely?
Cheers,
Rob
|
|
|
|
|
Rob Catterall wrote:
Would you suggest that it is worthwhile upgrading from Visual Studio 6 (we have an MSDN subscription so I already have the software)?
Yes. While VS.NET has significant differences in the IDE from VC6, for the most part the changes are worthwhile. A number of editor functions that you used to have to write macros for are now provided directly. Speaking of which, if you use macros a lot, you're going to be really pissed off. Any macros you had from VC6 will have to be rewritten, since the IDE object model is completely different. Also, VS.NET 2002 had some bugs in the resource editors, which supposedly 2003 has corrected. We're at the tail end of a development cycle, so we haven't upgraded to 2003 yet, and I have no direct experience.
Rob Catterall wrote:
Can I continue to maintain VisualC++ 6 projects under vs.net
Sort of. VC6 projects will import directly into VS.NET and can be recompiled with little or no changes. The compiler may issue a few warnings about features that have been deprecated, but those are easily fixed usually. But. Projects that have been upgraded to VS.NET cannot be easily downgraded to VC6. There was a tool here on Code Project at one time to do just that. The other, more significant, concern is that projects compiled under VS.NET require the VS.NET versions of the C++ runtime and MFC DLL's to be loaded onto the target machine, and those DLL's aren't installed unless you put them there. The VC6 DLL's were included in the OS install.
Rob Catterall wrote:
can 6 and .net be installed on the same machine safely?
Yes. I recommend installing things in the following order: VC6, MSDN Library October 2001 (the last version that integrated with VC6), VS.NET, and the latest MSDN Library.
Software Zen: delete this;
|
|
|
|
|
Hey all,
I'm currently making an editor for my latest game project. In order to make the application draw the OpenGL viewport each "frame" I'm currently using the OnTimer() message and then invalidating the view but I'm VERY interested in other ways to achieve this!
Do you guys have any experience doing this?
Thanks in advance,
Soren
|
|
|
|
|
You can use Multimedia Timer (see timeSetEvent) which has high precision. If you update the screen with high frequency, you may draw directly from timer message handler, without invalidating. OnDraw in this case should not be used.
Another way is using of idle time, you can see such applications here: http://nehe.gamedev.net/
However, this method doesn't look professional in Windows environment.
|
|
|
|
|
better use a loop with Sleep calls at the end.
Don't try it, just do it!
|
|
|
|
|
Alexander M. wrote:
better use a loop with Sleep calls at the end.
..in an MFC app? How's that?
Alex Farber wrote:
You can use Multimedia Timer (see timeSetEvent) which has high precision
Do I really need higher precision? I mean, I just need to constantly update the view.
Anyways, you're suggesting that I shouldn't use the OnDraw() message to do the drawing but rather my own function?
Any other suggestions?
|
|
|
|
|
Use idle time processing. This is the technique you're looking for. If this is an MFC app, override OnIdle in the application class, and adapt the following handler code:
BOOL CAnApp::OnIdle(LONG lCount) <br />
{<br />
CWinApp::OnIdle(lCount);<br />
<br />
if (lCount >= 2)<br />
DoSomething();<br />
<br />
return(TRUE);<br />
}
Only do your processing when the lCount parameter is >= 2; the framework is doing it's thing when it's 0 and 1. If you return TRUE, the application will continue to call your OnIdle as long as the message queue is empty, and will re-commence calls to OnIdle after processing any messages that are received. Return FALSE and OnIdle will be called once (and only once) each time the message queue is emptied.
|
|
|
|
|
First off, thanks for the great answer!
LunaticFringe wrote:
if (lCount >= 2)
DoSomething();
Would you recommend invalidating the view in order to update my OGL window or should I use a separate function? I mean, after all, I DO need the device context of the view which is automatically passed as a parameter to OnDraw().
|
|
|
|
|
Yes. Invalidate, and perhaps call UpdateWindow to force the issue.
|
|
|
|
|
Hi,
Is it possible to write a function which will take a variable number of arguments????
What i'm passing in is an array of doubles, and at the moment my function looks like
void func(int num, double* arr)
with "num" been the number of elements in the array.
So, can I pass just the array, and work out the number of elements inside the function??
any ideas??
thanks,
henry
|
|
|
|
|
Lookup va_start, va_arg and va_end in MSDN
int average( int first, ... )
{
int count = 0, sum = 0, i = first;
va_list marker;
va_start( marker, first ); /* Initialize variable arguments. */
while( i != -1 )
{
sum += i;
count++;
i = va_arg( marker, int);
}
va_end( marker ); /* Reset variable arguments. */
return( sum ? (sum / count) : 0 );
}
Michael
But you know when the truth is told,
That you can get what you want or you can just get old,
Your're going to kick off before you even get halfway through.
When will you realise... Vienna waits for you? - "The Stranger," Billy Joel
|
|
|
|
|
hdaly wrote:
So, can I pass just the array, and work out the number of elements inside the function??
Not when using a plain array. Because you can't pass a whole array to a function, just a pointer to the first element, the way you have it now is the correct way. The alternative is to use an STL vector or other container that knows its size.
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | 1ClickPicGrabber New v2.0! | RightClick-Encrypt
Actual sign at the laundromat I go to: "No tinting or dying."
|
|
|
|
|
Hi,
I need an idea to lock a MFC-Application after a specific time when no
user action happens.
The problem is:
The application has some internal messages like WM_TIMER, and some listctls get messages to display new text.
When the time is up the application has to lock itself and it appears a
login dialog.
|
|
|
|
|
Idefix wrote:
The problem is:
The application has some internal messages like WM_TIMER
Is this a problem?
You can have many timers. Each of them has an identifier.
I think that this should work:
void CMainFrame::OnStartTimer()
{
m_nTimer1 = SetTimer(1, 2000, 0);
m_nTimer2 = SetTimer(2, 2000, 0);
}
void CMainFrame::OnTimer(UINT nIDEvent)
{
switch(nIDEvent)
{
case 1:
break;
case 2:
break;
}
CMDIFrameWnd::OnTimer(nIDEvent);
}
Let me know if it helped.
modified on Monday, November 29, 2010 6:12 AM
|
|
|
|
|
Yes of course, the app can have many timer but how can I recognise
when the user has made no actions for e.g. 5 min. ?
At first I thought to use the OnIdle function but the internal WM_TIMER message
annul the idle state.
Another Problem is that the app is a client programm and get a lot of IP packets form the server and displays the data in controls. This are not user actions!
|
|
|
|
|
You can use GetLastInputInfo on Win2k to give you the time of the last "input" event - and compare that to the current time and then lock the app if the time out has gone
If you wanna run on 9x I think your into hook land - look up WH_FOREGROUNDIDLE - you might find this http://www.microsoft.com/msj/0200/c/c0200.aspx and this http://msdn.microsoft.com/msdnmag/issues/0500/c/default.aspx useful which do what you want.
|
|
|
|
|
I'd simply poll keyboard and mouse inputs in the message queue.
~RaGE();
|
|
|
|
|
One way would be to get the screen saver timeout value at the start of your application. Then set this value to whatever idle time you are interested in. Once that idle time has been reached, Windows will broadcast a SC_SCREENSAVE message. When your application ends, restore the screen saver timeout value to what it was.
Another idea that comes to mind would be to call SetWindowsHookEx() . As far as which type of hook to use, I don't know. Several of them look like they might work, but ultimately it'd probably be only one of them.
Classier ways may exist, but having never done this, I'm not familiar with them.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|