Using std transform function

So what does std::transform function do? “Applies a specified function object to each element in a source range or to a pair of elements from two source ranges and copies the return values of the function object into a destination range.” Some general applications of using transform is as follows… For doing some kind of operation […]
Continue reading…

 

How to convert iterator to corresponding data pointer?

Well it was quite easy in VC6 to work with iterators since iterators were actual pointers to internal data, so they could be used interchangeably. For e.g. [sourcecode language=”cpp”]typedef std::vector IntVector; IntVector IntVecObj; // Push in a thousand ints for( int Index = 0; Index < 1000; ++Index ) {    IntVecObj.push_back( Index + 1 […]
Continue reading…

 

Turning monitor off

Wow man how to do this! Simple, just one line of code to send your monitor into standby mode. ::PostMessage( m_hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, 2 ); Do this using a timer and you will have your monitor turned off every 1 second which prevents anyone from turning your monitor on because it goes into standby mode […]
Continue reading…

 

Forward declaration

So what is forward declaration? It tells a compiler that a particular class name is valid, a declaration and definition of the class will follow soon and don’t worry or give errors about it now. Remember that compiler will give an error if you invoke any properties or methods of above class, for that you […]
Continue reading…

 

typedef a fixed length array

Let’s suppose you wanna create a typedef for a fixed length array, so first thing that you would do is this… [sourcecode language=’cpp’]typedef char[100] HundredChars;[/sourcecode] This will not work as typedefing an array requires different syntax, here is how we do it… [sourcecode language=’cpp’]typedef char HundredChars[100];[/sourcecode]
Continue reading…

 

How to register a Hotkey for your application?

Now what’s a hotkey? An easy definition would be a key that remains hot throughout the lifetime of an application. Whenever you press a hotkey it does it’s work no matter where the focus is or where the input is directed to, etc. Here is a screenshot and a sample application(Right click and save as […]
Continue reading…

 

To move a captionless dialog.

Have you ever wondered how do people move dialogs by simply clicking anywhere inside the dialog and dragging them. Have you ever wondered how caption-less dialogs can be dragged around. If it is so then let me tell you that you can do the same with just few lines of code… Here goes the code: […]
Continue reading…