Thanks in advance.
--Joel Hendley
jhen...@hmc.edu
Don't have the code here, but it is possible, as Borland includes a
windows version of arty in bgidemo.pas that keeps drawing lines on the
iconized mdi children.
... Boku wa hon desu.
___ Blue Wave/QWK v2.12
SetClassWord( hWindow,
GCW_HICON,
MAKEINTRESOURCE( iYourNewIconID ) );
Roberto Soldi
In general the way you change icons or have different
icons for different windows of the same class is as
follows:
1) set the icon to NULL in the class before registering
the class.
:
:
wc.hIcon = NULL; /* No specified icon, loaded later*/
: ^^^^^
:
return (RegisterClass(&wc));
2) Load the icons by calling LoadIcon().
case WM_CREATE:
hIcon1 = LoadIcon(hInst, "OriginalIcon");
hIcon2 = LoadIcon(hInst, "ChangedIcon");
hIcon = hIcon1;
break;
3) Based on your design specification determine which
icon should be loaded and set the handle to the icon
to be displayed to that. For example this sample
changes the icon when the menu item is selected to
change the icon.
case WM_COMMAND:
// Change Icon
switch(wParam)
{
case IDM_CHANGEICON:
if (hIcon == hIcon1)
hIcon = hIcon2;
else hIcon = hIcon1;
break;
}
break;
3) Process the WM_PAINT message and check to see if the
window is minimized (by calling IsIconic()) then send
a WM_ICONERASEBKGND message via a call to SendMessage().
Then draw the icon by calling DrawIcon() passing it the
handle to the icon you want to draw.
case WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint(hWnd, &ps);
// Paint Icon
if (IsIconic(hWnd))
{
// Erase the background of the icon
SendMessage(hWnd, WM_ICONERASEBKGND, (WORD)ps.hdc, 0);
DrawIcon(ps.hdc, 0, 0, hIcon);
}
EndPaint(hWnd, &ps);
}
break;
4) In order to prevent flashing that is caused when
painting the icon, do not process the WM_ERASEBKGND.
Check to see if minimized (again by calling IsIconic())
then just return TRUE. Otherwise pass it to the
default window procedure for that particular type of
window.
case WM_ERASEBKGND:
{
if (IsIconic(hWnd))
return TRUE;
else
return (DefWindowProc(hWnd, message, wParam, lParam));
}
break;
5) To allow the correct cursor to be used when the icon is
dragged, process the WM_QUERYDRAGICON and return the
handle to the icon.
case WM_QUERYDRAGICON:
return hIcon;
Now there are some differences between regular windows, MDI
child windows and modeless dialog boxes.
Modeless Dialog Boxes:
======================
There are two differences: one is that you do not need to set
the icon to NULL since the default for the dialog class is
already NULL and the other is that you call DefDlgProc()
instead of DefWindowProc() in step (4).
MDI Child Windows:
==================
For MDI Children what you need to do differently is that you call
DefMDIChildProc() instead of DefWindowProc() in step (4). All
other steps are exactly the same.