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…

 

A round dialog box!

Ever wondered how those cute little round dialog boxes are created. I too wondered for some time. But let me tell you it is easy, take a look: Do this from OnInitDialog! [sourcecode language=’cpp’]//Create a region object globally. CRgn m_EllipticRegion; //a rect object CRect crDialogRect; //get your dialog size this->GetClientRect(crDialogRect); //Now create the elliptic region […]
Continue reading…

 

How to convert ANSI string to UNICODE string and vice versa?

Well quite simple,ย  but still quite frequently asked in forums… ๐Ÿ™‚ There are two macros that does this for us. They are as follows. Note: You must include atlconv.h A2W – ANSI to UNICODE W2A – UNICODE to ANSI Before using these two macros you have to use this macro too… USES_CONVERSION Here is a […]
Continue reading…

 

How to create a GUID programmatically?

Do the following… [sourcecode language=’cpp’]GUID guId = { 0 }; CoCreateGuid( &guId ); // or UUID uid = { 0 }; UuidCreate( &uid );[/sourcecode] For converting to string use… [sourcecode language=’cpp’]PUCHAR pChar = 0; // Convert to string UuidToString( &uid, &pChar ); MessageBox( NULL, (char*)pChar, NULL, MB_OK ); //Don’t forget to free allocated string RpcStringFree( […]
Continue reading…

 

Replacement for CString::Format in standard C++

std::stringstream can be used as a replacement for CString::Format, if you are using CString just for the sake of Format, caveat being that it could be slow, I’ve heard a user mentioning this but not sure, I haven’t tested it out, but should be definitely better that using CString::Format and then assigning to std::string. [sourcecode […]
Continue reading…