DownloadSourceCode
If you run the demo code, and click the left mouse button in the program
window it will change your start button from 'Start' to an alternative image
as show on the right. Don't worry, its only temporary...as if you
click on your start button it will change back.
Its a nice effect and shows you how you can easily grad the handle for
almost any window and draw to it. You could modify the code to display
an animation to the start button... its upto you.
Below shows the snippet of code that does all the work. |
|
....
//Get the handld to the Start Button
hStart = GetWindow(FindWindow("Shell_TrayWnd",""),GW_CHILD);
//or use instead
//hStart =
FindWindowEx(FindWindowEx(NULL,NULL,"Shell_TrayWnd",""),NULL,"Button","");
//Get the DC for the window, so we can
draw on it ;)
hdc = GetDC(hStart);
//Repaint the Start window for a second...until
the mosue moves ;)
//Find out how big the start button is
;)
GetClientRect(hStart,&rect);
memdc = ::CreateCompatibleDC(GetDC(hwnd));
hBitmap = (HBITMAP)::LoadImage(NULL,"button.bmp",IMAGE_BITMAP,0,0,
LR_LOADFROMFILE);
SelectObject(memdc,hBitmap);
BitBlt(hdc,0,0,rect.right,rect.bottom,
memdc,0,0,SRCCOPY);
ReleaseDC(hwnd,memdc);
ReleaseDC(hStart,hdc);
.... |