TIP: Click on subject to list as thread! ANSI
echo: delphi
to: ALL
from: JOAQUIM HOMRIGHAUSEN
date: 1997-10-31 12:20:00
subject: Icons (Delphi 1.x)

 JH> No - all I want to do is:
 JH> 1. Have an MDI parent
 JH> 2. Have none or more MDI children of that parent
 JH> 3. Be able to toggle the parent's titlebar on/off
 JH> 4. Be able to dynamically change the icon of the MDI children
 JH>     (to indicate a specific state)
OK - after a lot of testing, the following works:
To toggle the border of the (parent) window:
{-Determine if border is On or Off - works even if we have
  active/displayed MDI children}
PROCEDURE TMainForm.SetupBorder(IsOn :BOOLEAN);
VAR
  LongVal :LONGINT;
  UpdateRect :TRect;
BEGIN
  LongVal:=GetWindowLong(Handle, GWL_STYLE);
  if (not IsOn) then
    LongVal:=LongVal and not ws_Caption
  ELSE
    LongVal:=LongVal or ws_Caption;
  SetWindowLong(Handle, GWL_STYLE, LongVal);
  GetWindowRect(Handle, UpdateRect);
  LongVal:=GetSystemMetrics(SM_cyCaption);
  if (not IsOn) then
    MoveWindow(Handle, UpdateRect.Left,
                       UpdateRect.Top+LongVal,
                       Width, Height-LongVal,
                       TRUE)
  ELSE
    MoveWindow(Handle, UpdateRect.Left,
                       UpdateRect.Top-LongVal,
                       Width,
                       Height+LongVal,
                       TRUE);
END;
To change the icon of the MDI child:
PROCEDURE MDIchildWindow.ToggleIcon(IsFirstIcon :BOOLEAN);
VAR
  MDIicon :TIcon;
BEGIN
  if (IsFirstIcon) then
    BEGIN
      BorderIcons:=[];
      Caption:='Now using First icon';
      MDIicon:=TIcon.Create;
      MDIicon.Handle:=LoadIcon(HInstance, 'Icon1');
      Icon:=MDIicon;
      MDIicon.Free;
      BorderIcons:=[biSystemMenu, biMinimize];
    END
  ELSE
    BEGIN
      BorderIcons:=[];
      Caption:='Now using Second icon';
      MDIicon:=TIcon.Create;
      MDIicon.Handle:=LoadIcon(HInstance, 'Icon2');
      Icon:=MDIicon;
      MDIicon.Free;
      BorderIcons:=[biSystemMenu, biMinimize];
    END;
END;
  This has the "nasty" side effect of flashing the currently active MDI child 
window, but at least it works and nothing seems to barf on it. It appears 
that all MDI child windows are "visited", but I'm not sure about that. Either 
way, I'll use this until someone gives me a better suggestion :-)
  Thanks to everyone who offered their opinions/assistance!
            %JoHo%
            joho@defsol.se
---
---------------
* Origin: Definite Solutions ~/Stockholm, Sweden (2:201/330.3)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.