🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.ms.programmer
Article #400

Painting icons on the desktop

#400
From: Alan Phillips
Date: Wed, 15 Apr 1992 13:19
45 lines
2573 bytes
Can anyone give me some recipes for what _ought_ to be simple, but which I
just can't get to work?

Here's the (slightly simplified) background:

I have an app that runs (mostly) as an icon. I need to have two separate
icons to indicate the two possible states it can be in, and the app has to
be able to change them at will. I'm writing this for 3.1 (using the beta 61d
SDK, as my real 3.1 SDK isn't here yet)

My initial approach was to register the window class to use icon A, and then
use SetClassLong to change to whatever the icon needs to be.  (This is a single
instance app, so I don't have the problem of other instances finding their ions
changing too).  Problem is, the icon is only redrawn to the new one when the
icon is moved or when the window is restored and then iconised: I can't find
_any_ way of forcing a redraw on demand (InvalidateRect specifying a rect of
NULL does not do it). 

Windows does not send a WM_PAINT to the window icon, ever.

Second approach was to register the window class with a NULL hIcon, and then
trap WM_PAINT messages and use DrawIcon to put in the icon I want. This
works up to a point, but I have problems with the background. Using a desktop
pattern results in bits of it being misaligned, and if there's a wallpaper
bitmap it gets overlaid by the desktop colour.

Third approach was to register with a NULL hIcon in the class, get a DC to the
desktop window and draw the icon on _that_ on a WM_PAINT. Here, though,
windows seems to draw the desktop background _after_ I paint the icon.

So can anyone give me a good recipe for doing this? It has to be possible,
since the VB prototype for this app can do it! What am I missing?

[Possibly of interest is that the WM_PAINTICON message that 3.0 uses in
these cases does not seem to exist in 3.1. It's not in my windows.h file
(a bug, perhaps?) and SPY doesn't show it either]

If you could reply by mail it would be helpful, as a reply here will probably
be cleared before I get back from Easter holidays.  Incidentally, this is a
network MOTD file reader/monitor app: when it's done and this last little
problem is gone, I'll release it to public domain with source. 

Thanks in advance,

Alan
Technical Details
Message-ID: <1992Apr15.131911.12176@comp.lancs.ac.uk>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!uknet!dcl-cs!alan

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!uknet!dcl-cs!alan
From: alan@comp.lancs.ac.uk (Alan Phillips)
Newsgroups: comp.windows.ms.programmer
Subject: Painting icons on the desktop
Message-ID: <1992Apr15.131911.12176@comp.lancs.ac.uk>
Date: 15 Apr 92 13:19:11 GMT
Organization: Department of Computing at Lancaster University, UK.
Lines: 45