How to get the string that is used to register a message using RegisterWindowMessage

It’s quite common that we use RegisterWindowMessage to register a message that is used for all instances of this application. Have you ever wondered how to get the text back from from the message number that is returned by RegisterWindowMessage? This will make it more clear… [sourcecode language=’cpp’]const UINT uMyWndMessageReg = ::RegisterWindowMessage( _T( “Nibu is […]
Continue reading…

 

Comparing two float values

I’ve heard people say that they don’t get expected results when comparing two float numbers… One of the reasons that I found is this… [sourcecode language=’cpp’]const float fSomeFloat = 0.2; if( fSomeFloat == 0.2 ) { printf( “The two floating point numbers are equal, blahn” ); }[/sourcecode] This is bad programming, if condition won’t return […]
Continue reading…

 

Print substrings using printf

We can use printf and it’s family of functions to print substrings, real nice. Have a look [sourcecode language=’cpp’]char* pStars = “***************”; int nStarLength = strlen( pStars ); while( nStarLength ) {   –nStarLength;   printf( “%.*sn”, nStarLength, pStars ); }[/sourcecode] ‘*’ will be replaced by value of nStarLength. Number after ‘.’ specifies length of […]
Continue reading…