Gold mine of Visual C++ tricks!
Expand/Collapse System Notification Area programmatically.
![]()
Windows system task bar have System notification area. There is an arrow button nearby that by which we can Expand or collapse the System notification Area. Did you notice that while minimizing yahoo messenger, it displays a message that “Yahoo messenger will be still running in the system tray”. While displaying such as message, it will be nice to animate the Notification area by expanding and collapsing it.
![]()
See the code snippet. I guess, its self explanatory.
// Find the Shell Tray Window.
HWND hTrayWnd = ::FindWindowEx( 0,
0,
_T("Shell_TrayWnd"),
_T(""));
// Find the Tray notification window,
// which is a child of ShellTrayWidnow.
HWND hTrayNotifyWnd = ::FindWindowEx( hTrayWnd,
0,
_T("TrayNotifyWnd"),
_T(""));
// Find the Button which is a child of ShellTrayWidnow.
HWND hButton = ::FindWindowEx( hTrayNotifyWnd,
0,
_T("Button"),
_T(""));
// Now get the DialogControlID of the button.
UINT DlgId = ::GetDlgCtrlID( hButton );
// Send a WM_COMMAND message, so the button reacts.
::SendMessage( hTrayNotifyWnd, WM_COMMAND, DlgId, 0 );
// Wait a bit to have an animation effect.
Sleep( 1000 );
// Send WM_COMMAND message once again.
::SendMessage( hTrayNotifyWnd, WM_COMMAND, DlgId, 0 );
![]()
Targeted Audiance – Intermediate
| Print article | This entry was posted by Jijo Raj on April 9, 2008 at 4:05 pm, and is filed under Codeproject, MFC. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
No trackbacks yet.
How to check whether the thread is alive or dead?
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
How to set Focus to Different Control on Dialog Startup?
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
How to Get Project Build Time?
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
Search for Symbols in Visual Studio more Easily
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
C++ Function Pointers Simplified!
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?
How to Set Dialog as TopMost Window?
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 –
How to Watch this Pointer – The Wizards Way!
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
How to get the CPU Name String?
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
How to Change the Display Orientation?
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
How to Delete Duplicate entries from STL containers?
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
about 1 year ago
Hello webmaster
I would like to share with you a link to your site
write me here preonrelt@mail.ru
about 1 year ago
Hi Pal,
You mean that – you would like to link to my site? With Pleasure.
For We.See.Tips,
Jijo.