🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Icons for minimized Dialog Boxes

#1605
From: Tom W. Brown
Date: Wed, 14 Oct 1992 21:14
53 lines
2916 bytes
In article <92288.175936HELLER@DMSWWU1A.UNI-MUENSTER.DE>, HELLER@DMSWWU1A.UNI-MUENSTER.DE (Thomas Heller) writes:
|> How can associate Icons to Dialog Boxes?
|> 
|> Hint: SetClassWord(GCW_HICON) does work, but not as intended, 'cause all
|> Dailogs will display the same icon then. I want different icons, and only for
|> MY dialogs.
|> 
|> Thomas Heller

This may be tricky.  I know that if you register a window class with a NULL
icon then you can use GDI calls to paint into the icon area.  Effectively
a call to GetClientArea returns the correct information when iconic and you
can always call IsIconic() in your paint procedure to determine whether to
do normal stuff or do icon stuff.  This simplest thing is then to load your
icon from the resource file and do a DrawIcon().

However, you have no control over the call to RegisterClass in the case of
a dialog box and replacing the class icon with a NULL handle will affect
all dialogs as you've seen.

This sounds like a hack, but it's the only way I can think of to get around
this:

   - Register your own window class, one that has the desired icon.

   - When you want a dialog box, create a window of the above class and
     a dialog box for it that will be positioned to fit exactly in the
     window.  The window has the caption bar, etc. and the dialog box should
     be completely borderless.

   - I think there are only two messages you need to handle in the window
     procedure:

        WM_SIZE : handle this by doing a MoveWindow on the dialog to keep it
                  positioned in the parent window.

        WM_CLOSE: Send a CANCEL message to the dialog box and then, if ok,
                  destroy the window (not the dialog, the parent window).

   - If the dialog box procedure relies on doing things with the parent
     window handle (thinking it's your application window) you'll need to
     add another GetParent() call.

Since the parent window is fully under your control it displays your icon
when minimized.  It should look identical to a dialog that has its own caption
bar and system buttons.


----------------------------------------------------------------------------
Tom Brown               |  "Strange women, lying in ponds, distributing
PE Nelson Systems       |   swords is no basis for a system of government."
twbrown@pe-nelson.com   |                    Monty Python and the Holy Grail
----------------------------------------------------------------------------
Technical Details
Message-ID: <636@lax.lax.pe-nelson.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!lax.pe-nelson.com!lax!twbrown
References: <92288.175936HELLER@DMSWWU1A.UNI-MUENSTER.DE>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!lax.pe-nelson.com!lax!twbrown
From: twbrown@PE-Nelson.COM (Tom W. Brown)
Newsgroups: comp.os.ms-windows.programmer.misc
Subject: Re: Icons for minimized Dialog Boxes
Message-ID: <636@lax.lax.pe-nelson.com>
Date: 14 Oct 92 21:14:01 GMT
References: <92288.175936HELLER@DMSWWU1A.UNI-MUENSTER.DE>
Sender: news@lax.pe-nelson.com
Organization: PE-Nelson
Lines: 53