|
|
Hi,
So here's my problem:
I have a child dialog on my main window. I use double-buffering in my application and I'd like the dialog to draw on my back-buffered HDC instead of my front HDC (the HDC of the main window) to prevent flicker when it invalidates.
How can I change the HDC that the child window draws to?
Thanks!
KR
|
|
|
|
|
KellyR wrote: How can I change the HDC that the child window draws to?
Try specifiing the CS_OWNDC style to the child dialog.( using the SetClassLong() function )
|
|
|
|
|
long iv=0;
function InterlockedIncrement(&iv) is used for locking iv according its name, but variable iv is not locked after the function call.
could u explain in which case the iv is locked by the function call?
|
|
|
|
|
|
I explained this to the OP in another post.
While you're correct about locking (probably) not needed on a simple increment,
InterlockedIncrement does more:
SomeCriticalSection.Lock();
iy = (++iv);
returnval = iv;
SomeCriticalSection.Unlock();
return returnval;
Aother thread incrementing iv after the first thread increments it but before the first thread
has copied it could have an undesired effect
Especially on reference counters, which is (probably) most often the reason InterlockedIncrement
and InterlockedDecrement are used.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
The variable is locked DURING the call, not after the call completes.
See here[^].
As Matthew mentioned, what's going on in the call is something like:
LONG InterlockedIncrement(LONG volatile* lpAddend)
{
SomeCriticalSection.Lock();
++(*lpAddend);
LONG returnval = *lpAddend;
SomeCriticalSection.Unlock();
return returnval;
}
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi All,
I know this has come up in the context of non-English speaking contributors in an effort to improve article quality. I'm all for it. I submit that the non-English speaking author has a better command of English than I have of his native tongue. So I am humbled by my own ignorance...
However, Subject Matter is a different story. I have a good understanding in some arenas. This knowledge extends sufficiently so that I feel I can provide feedbck and advice. One such area is Cryptography.
I am appaled at some of the articles submitted on Cryptography. In the following, I am not singling out the authors. I am trying to make a succint point.
The latest is TrueCrypt Explorer[^]. This library is using source code and presumably home grown ciphers from the notorius Tom St. Dennis of sci.crypt. Single handedly, he nearly ruined the usenet group with his arrogance and ignorance.
I assume the author is not versed on Cryptography, and as such has fallen victim to TSD's 'Proof by Intimidation' of his cryptosystem. I am not aware of a Cryptanalytic effort by any reputable cryptographer on his work.
Build your own cryptographically safe server/client protocol[^] is misleading because the author states something to the nature he is collecting 'true randomness', which is generally not possible in software.
CTrueRandom - Getting True Random Numbers[^] claims it generates 'True Random Numbers'. I assume the author meant nondeterminsitic method, similar to the noise resisitor placed on the hardware based PRNG board of a RS6000.
As a final example, I point you toward The Art & Science of Storing Passwords[^], where the article claims the practice of storing a password for recover on disk unencrypted is OK.
Jeff
|
|
|
|
|
This is an interesting idea, and I too have felt really aggravated by some of the poor articles posted here. I'm sure you know that historically, the CP editors take care of compliance with formatting, etc., but rarely get involved with content, unless there is a serious concern about plagiarism or something similar. I think that over time, the better articles are recognized and get better ratings.
But SMEs are a whole new thing. I can see how putting content responsibility in the hands of a few anointed SMEs could lead to personality problems just like the one you described. A heavy-handed SME could cause huge damage to the site's collaborative spirit (I'm thinking of another Usenet newsgroup, which is dominated by an obnoxious person who was beaten off when he tried the same stuff here). I think I would rather risk a few bad articles than having to contend with a situation like that.
Why don't you think that submitting (positive) comments on the article forums is the way to go?
|
|
|
|
|
Could the voting system be tweeked so that an article can be voted into oblivion by, for example, 'nill point' votes from 3 separate experts/moderators/SME? This might stop or at least slow down one bad egg from causing trouble but would allow a way to can really bad articles.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Hans
Apologies, I intended to vote your comment 5, but somehow managed to click 1 by mistake - do you know any way to retract a vote?
I didn't particularly want to participate in this debate, but I agree that the submission of positive comments is a good strategy.
Best Regards
Cliff
|
|
|
|
|
Cliff Hatch wrote: do you know any way to retract a vote?
I think you have to send an email to sean@codeproject.com.
Thanks for telling me - now I won't think that Jeff is being mean.
|
|
|
|
|
Cliff Hatch wrote: Apologies, I intended to vote your comment 5, but somehow managed to click 1 by mistake - do you know any way to retract a vote?
Perhaps Chris can help. I would post a questiion on the suggestion board (where this suggestion should have gone - I don't know how I managed to insert it into C++).
Jeff
|
|
|
|
|
Hi Hans,
Hans Dietrich wrote: I can see how putting content responsibility in the hands of a few anointed SMEs could lead to personality problems just like the one you described. A heavy-handed SME could cause huge damage to the site's collaborative spirit (I'm thinking of another Usenet newsgroup, which is dominated by an obnoxious person who was beaten off when he tried the same stuff here). I think I would rather risk a few bad articles than having to contend with a situation like that.
As Gary raised the same issue below, I was not not trying to create censorship.
I was thinking more the way a Book Proofer work: Make suggestions and comment on tecnical correctness. The author can choose to incorporate.
Jeff
|
|
|
|
|
The CodeProject is an informal, open, collaborative site. The approach you describe would convert it to a formal, closed, scholastic one. Demi-gods would 'vet' articles based on their own notion of accuracy, usefulness, and appropriateness.
I think the current approach with the article voting system and each article having its own forum is sufficient.
If you think these articles are poor articles, vote them down. Post a message in their forum stating THIS ARTICLE IS CRAP and explain why. Write a response article.
Software Zen: delete this;
|
|
|
|
|
Hi Gary,
Gary R. Wheeler wrote: The CodeProject is an informal, open, collaborative site. The approach you describe would convert it to a formal, closed, scholastic one. Demi-gods would 'vet' articles based on their own notion of accuracy, usefulness, and appropriateness.
The situation you describe (censorship) is worst than the current. I was not imagining an involuntary system.
Perhaps middle ground is the solution: the Content Editor makes suggestions. If the author chooses, he or she can incorporate the suggestions.
Gary R. Wheeler wrote: If you think these articles are poor articles, vote them down. Post a message in their forum stating THIS ARTICLE IS CRAP and explain why.
I try not to do this (I think it is very unprofessional). Again, I'd rather correct the problem at the source...
Gary R. Wheeler wrote: Write a response article.
In my case, I did: A Survey of Pseudo Random Number Generators[^]. Also, I did try to solicit feedback from two PhD's. Neither would comment. In either case, I tried by going to someone who knows more then me.
Humorously, the beginner article has only garnered a 4/5 rating
Jeff
|
|
|
|
|
I want to get buffers of all streams of a file. I searched msdn then i found ready functions
FindFirstStream and FindNextStream which i ve found in Windows Platform SDK.
These functions give me name of streams. So how can get data in these streams using their name ?
I guess i will use CreateFile and ReadFile again but , what must the parameter given to CreateFile , must it be only stream name or "filenametreamname" ??
Thank you very much...
|
|
|
|
|
Akin Ocal wrote: These functions give me name of streams. So how can get data in these streams using their name ?
You can append a colon and the stream name to the pathname of the file.
filenamename.ext:streamname
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hello in my code i have this
double idf[50];
for (int zz = 0 ; zz < m_QueryWords ; zz++ )
{
idf[zz] = log10 ( (double)(nDoc/df[zz]) );
-> }
While i debug i have :
<code>name Value
df[zz] 2
idf[zz] 0.00000 (red colour just took the value)
nDoc 3
+this etc :P
zz 0 </code>
what i do wrong ?
I changed the code with
int location = f + (m_QueryWords*ii);
SCs = SCs + nArray.GetAt(location)*idf[f]*idf[f] ;
and now works
-- modified at 14:32 Saturday 2nd June, 2007
|
|
|
|
|
Immunity18 wrote: idf[zz] = log10 ( (double)(nDoc/df[zz]) );
Change to log10 ( (nDoc/(double)df[zz]) );
df[zz] needs to be a double in order to provide a floating point result.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I posted a question before and got hint of "managed/unmanaged code".
I do heard "Managed C++", I guess it is another language - at least it is different from c++ hear.
my question is:
how to generate "managed code" in our C++, such as in MFC or Win32?
any samples if it is possible?
thx
|
|
|
|
|
Hope this article will help you.
Managed Code[^]
Regards,
Satips.
|
|
|
|
|
...or this article
Managed Extensions for C++ Programming[^]
It's not another language. It's an extension to Microsoft's C++ which allows you to use the
Common Language Runtime and the .NET framework.
Managed code is not compiled to processor machine code like regular C++ is. It is compiled to
an intermediate language that can run on an implementation of the Common Language Infrastructure
(CLI). At runtime, the intermediate language code is compiled to CPU-specific machine code and
executed. On a Windows machine with the .NET framework installed, this is done by the Common
Language Runtime (CLR), which is Microsoft's implementation of CLI.
In order for this to be possible from C++, it was necessary to extend the language to be able to
work with the common data types of the CLI specification and to work with the managed, garbage-
collected heap of the .NET framework.
The biggest impact IMO with managed C++ programming is with managed pointers. Objects allocated
on the managed heap can be moved at any time by the runtime. Objects allocated with malloc/new
don't move - that's what we're used to as C++ programmers. Also, managed objects are
automatically destroyed by the runtime.This means there's rules to follow when mixing managed and
unmanaged C++ code (mixed-mode programming).
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
//global
long i_Lock=0;
//use it in thread
int MyTread(void*p)
{
InterlockedIncrement(&i_Lock);
}
--------------------------
I am really confused, what is difference with
int MyTread(void*p)
{
i_Lock++;
}
???
it sounds nothing related to sinycronization, could u explain?
thx
|
|
|
|
|
The InterlockedIncrement() version is thread safe, the i_Lock++ version is not.
InterlockedIncrement() prevents any other thread from using i_Lock while it's being incremented.
InterlockedIncrement() also checks the result and gives a return value based on the result.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|