|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Taskbar Icon AnimationTitlebar Icon AnimationIntroductionI have came across many solutions to display an icon on the system tray, taskbar, or the title bar, but I could not find code for animating the icon without using MFC. When I started to work with animating system tray icons, I examined the possibility of doing the same on the taskbar and titlebar icons. You can find many “classes” to integrate with your project to do the same. This project is developed without using MFC; it’s a pure Win32 “C” code which has the following features. Feature
System Tray IconFirst, a simple Win32 application is created by registering a local class. Create a set of custom icons (.ico files) using the workspace. void DrawGraph(HDC hdc, RECT Rect);
The void AnimateIcon(HINSTANCE hInstance, HWND hWnd,
DWORD dwMsgType,UINT nIndexOfIcon);
The user defined function
void AnimateIcon(HINSTANCE hInstance, HWND hWnd, DWORD dwMsgType,UINT nIndexOfIcon) { HICON hIconAtIndex = LoadIcon(hInstance, (LPCTSTR) MAKEINTRESOURCE(IconResourceArray[nIndexOfIcon])); NOTIFYICONDATA IconData; IconData.cbSize = sizeof(NOTIFYICONDATA); IconData.hIcon = hIconAtIndex; IconData.hWnd = hWnd; lstrcpyn(IconData.szTip,"Animated Icons - Demo", (int) strlen("Animated Icons - Demo")+1); IconData.uCallbackMessage = MYMSG_NOTIFYICON; IconData.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; Shell_NotifyIcon(dwMsgType, &IconData); SendMessage(hWnd, WM_SETICON, NULL, (long) hIconAtIndex); if(hIconAtIndex) DestroyIcon(hIconAtIndex); }
case MYMSG_NOTIFYICON: OnTrayNotification(hInst, hWnd, wParam, lParam); break; In this message handler, the
The functionality of the menu action should be handled in the Taskbar Icon and Titlebar IconTo draw a custom icon on the taskbar and the titlebar, send a void TimerAnimationIcon(HINSTANCE hInst, HWND hWnd)
{
AnimateIcon(hInst, hWnd, NIM_MODIFY, nCounter);
m_nCounter = nCounter;
nCounter++;
nCounter = nCounter%(NUM_ICON_FOR_ANIMATION);
}
|
||||||||||||||||||||||