about 6 months ago - 3 comments
In multi-threaded environments, sometimes we need to check whether a given thread is alive or not. But how can we check it?
Picture courtesy – Erica Marshall
You can use the function – GetExitCodeThread(). If thread is alive, the function returns STILL_ACTIVE. Have a look at the code snippet.
// Checks whether given thread is alive.
bool IsThreadAlive(const HANDLE
about 6 months ago - 1 comment
Do you want to set the focus to another control on displaying Dialog? Or tried SetFocus() to another control in OnInitDialog() and want to know why its not working? The answer for your ‘Focus’ question is here.
If you are setting the default focus to another control in dialog, then OnInitDialog() should return FALSE. Have a
about 6 months ago - No comments
Many times i lost my temper by waiting for the re-build to be finished. So i just attempted to tune and reduce the build time by removing unnecessary includes. At that time I just wondered how to get the build time?
Just follow the steps to enable the ‘Build Time’.
1) Take – Tools > Options.
2) Now
about 9 months ago - 2 comments
Ever tried VisualAssist? Yes man, Its a killer product. The feature that I like most is its Symbol Search. You can specify words and it will list symbols that contain those words. Its very useful if you have a vague idea about the function name that you’re searching for. Have a look at the following
about 10 months ago - 2 comments
Background information
Pointer is a variable which holds the address of another variable. Where, function pointer is again a variable which holds the address of a function.
If you think pointers are evil, then function pointers must be Satan for you. Well, is there any easy way to create function pointers from function prototype?
about 10 months ago - No comments
I always wondered about popularity of Winamp. It has rich custom drawn UI, which made it stand out of the crowd. Did you noticed its “Always on top” feature and wondered about how its implemented? Its time to reveal the secret – How winamp implemented that feature – Staying at the top?
You can use –
about 1 year ago - 6 comments
How to watch the this pointer? Just add ‘this’ to watch window. Everyone does like that. Isn’t it? But how Visual C++ wizards watch ‘this’ pointer?
The secret is, visual C++ compiler passes this pointer via ECX register. So add (ClassName*)(@ECX) to watch window will give you this pointer. Have a look at the
about 1 year ago - 3 comments
While taking the System properties, you have noticed the processor name string. For instance, in my laptop it is – “Intel(R) Core(TM)2 Duo CPU T5250 @ 1.50GHz“. Ever though about how to get this processor name string?
Image Courtesy – Wallpaper Mania.
You can use the function – __cpuid(), which generates the
about 1 year ago - 4 comments
Are you using Windows XP? Press Ctrl+Atl+DownArrow, and then Ctrl+Atl+UpArrow. The screen changes its orientation upside down. isn’t it? But how to turn the screen, upside down programmatically?
Image Courtesy – marieforleo.com
Get the current DEVMODE by calling -EnumDisplaySettings(). Then change orientation by setting DEVMODE.dmDisplayOrientation and calling ChangeDisplaySettings(). Have a look at the code snippet. Code taken
about 1 year ago - 4 comments
If you want to remove duplicate items, you can go for stl::set. But what to do if you want to delete duplicate data from other containers?
Picture Courtesy – Squidoo
You can use std::unique() algorithm to remove adjacent duplicate items. So at first, sort your data, then call std::unique(). Now all the duplicate data will be rearranged