🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.ms-windows.programmer.misc
Article #1863

Re: how to animate icon of minimised window ?

#1863
From: Rob Ryan
Date: Fri, 25 Dec 1992 06:20
53 lines
2651 bytes
In <25DEC199200040150@vms1.iscs.nus.sg> nuscss1@vms1.iscs.nus.sg (Vax BULLET-IN-Board SysOps) writes:

>	I would like to animate the icon of a minimised window. I guess
>	this can be done by continually changing the hIcon of the
>	window class. So what I did is to set a timer, and upon the
>	reception of WM_TIMER, I check if the window is iconic. If it
>	is, I use SetClassWord to change the hicon.
>
>	problem : the dang thing doesn't seem to be working.
>	can someone give me an idea on how to go about implementing it ?
>	am I on the wrong track ? I've check the API, and there doesn't seem
>	to be a function for this purpose.

Are you invalidating your window in your WM_TIMER message?  As well as telling
Windows what the new icon is, you'd probably want to tell it to redraw it (and
you do this by invalidating the appropriate window).

Personally, I wouldn't do the SetClassWord(), but rather manually take over
the processing of the paint command.  So, I'd have something like:

  1. my WM_TIMER code would invalidate the window for the application and set
     a static, hIcon to be the handle of my new icon; and
  2. have a WM_PAINT (Microsoft doesn't recommend using WM_PAINTICON anymore)
     check to see if IsIconic().  So, I'd have something like:
       case WM_PAINT:
         if (IsIconic(hWnd)) {
             BeginPaint(hWnd, &ps);
             DefWindowProc(hWnd, WM_ICONERASEBKGND, (WORD) ps.hdc, 0L);
             DrawIcon(ps.hdc, 0, 0, hIcon);
             EndPaint(hWnd, &ps);
             return 0;
         } else 
             return DefWindowProc(hWnd, message, wParam, lParam);
       case WM_ERASEBKGND:
         if (IsIconic(hWnd))
             return TRUE;
         else
             return DefWindowProc(hWnd, message, wParam, lParam);

  3. Microsoft also recommends taking over the WM_QUERYDRAGICON too:
       case WM_QUERYDRAGICON:
         return (LONG) (WORD) hIcon;

The key is that you invalidate the window to instruct Windows to redraw it.
Just changing the icon isn't enough.

If you have a copy, see the Fall '92 issue of the Microsoft Develop Network
News on how to deal with the painting of icons.  Notably, they discuss the
disappearance of the WM_PAINTICON.

-- 
 Rob Ryan
    rryan@panix.com
Technical Details
Message-ID: <1992Dec25.062010.6731@panix.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!psinntp!panix!rryan
References: <25DEC199200040150@vms1.iscs.nus.sg>

Show Full Headers
Complete Article Headers
Newsgroups: comp.os.ms-windows.programmer.misc
Path: arc1-ca.pugleaf.net!sparky!uunet!psinntp!panix!rryan
From: rryan@panix.com (Rob Ryan)
Subject: Re: how to animate icon of minimised window ?
Message-ID: <1992Dec25.062010.6731@panix.com>
Date: Fri, 25 Dec 1992 06:20:10 GMT
References: <25DEC199200040150@vms1.iscs.nus.sg>
Organization: Panix, NYC
Lines: 53