|
No the thread will wakeup in the first time itself. the significance of a singal is in waiting state only.
Ninety-eight percent of the thrill comes from knowing that the thing you designed works, and works almost the way you expected it would. If that happens, part of you is in that machine.
|
|
|
|
|
No, SetEvent just sets the event to the signalled state, so the number of times you call SetEvent doesn't matter.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Try a semaphore if this is the desired behavior.
Bob Ciora
|
|
|
|
|
Thanks - Semaphore works great. Thanks for the info... Regards.
|
|
|
|
|
I have a set of menus in MyFrame, and for some reason I move the
ON_COMMAND()
ON_UPDATE_COMMAND_UI()
of one of them to another module. The problem is its menu item is automatically enabled initially. All the other menu item's message map local to the MyFrame are disabled. How can the previous menu item be disabled?
Here's what MSDN says about update handler
If the framework does not find an ON_UPDATE_COMMAND_UI entry during command routing, it automatically enables the user-interface object if there is an ON_COMMAND entry somewhere with the same command ID. Otherwise, it disables the user-interface object. Therefore, to ensure that a user-interface object is enabled, supply a handler for the command the object generates or supply an update handler for it.
It is possible to disable the default disabling of user-interface objects. For more information, see the m_bAutoMenuEnable member of class CFrameWnd.
So I guess initially the Framwork doesn't find the specific ON_UPDATE_COMMAND_UI macro in MyFrame, that menu item was enabled. And I tried m_bAutoMenuEnable, that doen't work either.
|
|
|
|
|
Hi,
How can I show a WMF file in a non-mfc application?
I need to handle the zooming also.
Thank you.
- NS -
|
|
|
|
|
The tooltips of slider control is the current positon if you set the "Tooltips" property True. How can I set a special tooltips of a slider control? Just like "The current positon: 13". Thank you!
There are innumerable stars in the sky, the smallest is me!
|
|
|
|
|
Hello,
I've created a subclass of the Button class and I can't figure out why my OnPaintBackground method never gets called. Have any of you ever encountered this problem?
Gus
|
|
|
|
|
I figured it out:
this->SetStyle(ControlStyles::Opaque, false);
Just FYI...
Gus
|
|
|
|
|
I know XML Docs are supported for C# is VS.NET but what about C++? If XML Docs aren't supported natively for C++, has anyone come out with an add-on that implements them?
Todd Smith
|
|
|
|
|
Let say I've written a MMO server. Then I write a small C++ class called Bot that emulates a typical client session. Next I write a small test harness which can launch instances of Bots in separate threads.
The questions is how can I determine the max viable number of bot threads for a given machine? Every machine will have a different CPU/RAM configuartion etc. Can I determine at run-time how many bot threads to launch? I've tested my app with 500 bots and it works fine. I crank it up to 1000 bots and my system comes to a crawl.
Todd Smith
|
|
|
|
|
good afternoon, could anyone see where is the leak from? thank you! I've checked the momory allocation, the leak is happening around here:
strcpy( FileName, BinPath );
strcat( FileName, "CALLSM" );
strcat( FileName, Cycle);
strcat( FileName, ".BIN" );
if ( _access ( FileName, 0 ) != 0 )
{
sprintf( ErrorText, "File does not exist -> %s", FileName );
Message( ErrorText, VD_ERROR );
return 0;
}
m_information_line = "Loading CALLSUM Binary File.";
PostUpdate();
CallSumBin = new CALLSUM_BIN( FileName );
if ( !CallSumBin )
{
Message( "Unable to allocate CallSumBin binfile.", VD_ERROR );
return 0;
}
here is the delete in closedown() function:
if ( CallSumBin )
{
if ( !IsStop() ) {
strcpy( FileName, BinPath );
strcat( FileName, "CALLSM" );
strcat( FileName, Cycle);
strcat( FileName, ".BIN" );
m_information_line = "Saving updated CALLSM binary file";
PostUpdate();
CallSumBin->Save( FileName );
fprintf( Report,"Updated CALLSM binary file saved.\r\n" );
}
delete CallSumBin;
}
m_information_line = " ";
PostUpdate();
-- modified at 17:23 Wednesday 2nd November, 2005
|
|
|
|
|
valerie99 wrote: strcpy( FileName, BinPath );
Where is Filename allocated ? Is it ever deleted ?
C style string handling is a messy pile of crap, and the perfect way to get memory leaks. Why are you not using C++ here ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
As far as I can see, the memory leak must be in the CALLSUM_BIN class.
|
|
|
|
|
i don't see any here...
you CallSumBin = new CALLSUM_BIN( FileName ); and always delete CallSumBin; it then...
so, you might have a look at the CALLSUM_BIN constructor... does it allocate some memory that is not deleted (at the end of the constructor or in the destructor ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
-- modified at 3:18 Thursday 3rd November, 2005
|
|
|
|
|
Is your code perhaps calling the function containing
CallSumBin = new CALLSUM_BIN( FileName );
more than once without having called the closedown() function?
If so, that will cause a memory leak. I would suggest the following:
if ( _access ( FileName, 0 ) != 0 )<br />
{<br />
sprintf( ErrorText, "File does not exist -> %s", FileName );<br />
Message( ErrorText, VD_ERROR );<br />
return 0;<br />
}<br />
m_information_line = "Loading CALLSUM Binary File.";<br />
PostUpdate();<br />
if (CallSumBin != NULL)<br />
{<br />
delete CallSumBin;<br />
CallSumBin = NULL;<br />
}<br />
CallSumBin = new CALLSUM_BIN( FileName );<br />
if ( !CallSumBin )<br />
{<br />
Message( "Unable to allocate CallSumBin binfile.", VD_ERROR );<br />
return 0;<br />
}
Karl - WK5M
PP-ASEL-IA (N43CS)
<kmedcalf@ev1.net>
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
As krmed already stated, make sure your allocation routine isn't being called multiple times. However, I wouldn't make krmed's change, since that might just be fixing the symptoms and not the real issue. It is the memory allocation version of the "off by one" error where someone fixes the problem by just adding one without tracking down the reason why the value is off by one.
Another problem might be that your closedown code isn't being invoked. I often see people spend endless amounts of time trying to figure out why are routine isn't working when in fact, the routine isn't even being invoked.
Both of those problems are the same class of problem, improper execution path.
Of course, this is all assuming that it is CallSumBin that is leaking. If you haven't verified that, then you might be looking at the wrong issue.
As to what Christian said, he is right. Constructing the filename like that is akin to running with scissors. As long as you are careful, things are "ok". But a slight mistake can cause memory corruption (which can manifest itself as a leak in some instances) and security issues. I won't go so far as saying C style is crap, mainly because I have seen far too many string processing systems created with managed strings that are just dogs. But you are playing with fire and really need to understand what you are doing when you do work with C strings.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
-- modified at 9:56 Thursday 3rd November, 2005
|
|
|
|
|
is there an equivalent function in c++ of the vb function AscW?
because I need to convert a unicode character into it's hexadecimal value.
|
|
|
|
|
hexadecimal is just a printing representation of an integer value...
just use the %x or %X format option in the format string of the printf() , sprintf() , .Format() functions...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I can convert an integer into hexadecimal, but i can't convert a wchar_t into an integer.
I tried: swprintf(iTest,"%d",wByteBuff);
but i always get the error :error C2665: 'swprintf' : none of the 2 overloads can convert parameter 1 from type 'int'
i also tried with %x,%X,%i,%u,%c but none of this is working.
|
|
|
|
|
i am trying to load the data from an xml document into a treeview control. i know how to write the xml document but do not know how to load all of the data into tree control.
any help would be greatly appreciated.
- Kyle
|
|
|
|
|
|
AskQuestion wrote: look this site
http://www.codeproject.com/atl/atl_persistxml.asp[^]
that is not vc++ is it??
- Kyle
|
|
|
|
|
Look, there is a *.dsw file in the demo download file. In Description the author (katasonov)wrote:
"I have created two Visual Studio 6.0 projects as an example of how easy it is to add XML support to ATL objects:........"
have a look, I hope I could help you
|
|
|
|
|
Hello everyone!
OK, I got VC++ 6 yesterday, and I'm trying to make a Windows app, but I got no idea how! I looked for tutorials but they're all either for command-line apps (which I already read one) or for VC++ 2003... I've coded in C++ before, but not for Windows... I need a basic introduction to how to create a GUI/form/window from scratch. Anyone know? Thanks!
Sulfurik K. Nosferathus (Darth_Sulfur)
www.SulfurMidis.com
www.SulfurSoft.tk
http://www.BeepXtreme.tk
[ftp://][http://][hotline://]tsfc.ath.cx
|
|
|
|