AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

AlwaysOnTop mit mehreren Formularen

Ein Thema von Dalai · begonnen am 8. Mai 2020 · letzter Beitrag vom 14. Mai 2020
 
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.372 Beiträge
 
Delphi 12 Athens
 
#11

AW: AlwaysOnTop mit mehreren Formularen

  Alt 9. Mai 2020, 22:18
siehe #5 ?

[edit]
Hab's aber grad nochmal probiert ... ich glaub Delphi bzw. die VCL ist Schuld.

Vorhin falsch geguckt, denn so ist es aktuell in Windows 10 + Delphi 10.3:
* das zweite Fenster ist immer über dem Ersten
* wären Beide gleich (StayOnTop oder nicht), müsste jeweils das Aktive oben sein
* vermutlich irgendwas in Richtung PopupMode, aber das steht (standardmäßig) eigentlich auf pmNone :grueble:

[edit2]
Delphi-Quellcode:
procedure TCustomForm.CreateParams(var Params: TCreateParams);
...
        case LPopupMode of
          pmNone:
            begin
              if Application.MainFormOnTaskBar then
              begin
                // FCreatingMainForm is True when the MainForm is
                // being created, Self = Application.MainForm during CM_RECREATEWND.
                if FCreatingMainForm or (Self = Application.MainForm) then
                  WndParent := 0
                else
                  if Assigned(Application.MainForm) and Application.MainForm.HandleAllocated then
                  begin
                    WndParent := Application.MainFormHandle;
                    if WndParent = Application.MainForm.Handle then
                    begin
                      if Application.MainForm.PopupChildren.IndexOf(Self) < 0 then
                        Application.MainForm.PopupChildren.Add(Self); <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                      FreeNotification(Application.MainForm);
                    end;
                  end
                  else
                    WndParent := Application.Handle;
              end
              else
              begin
                WndParent := Application.Handle;
                SetWindowLong(WndParent, GWL_EXSTYLE, GetWindowLong(WndParent, GWL_EXSTYLE) and not WS_EX_TOOLWINDOW);
              end;
            end;
          pmAuto:
            begin
              if FCreatingMainForm then
                WndParent := 0 // A main form can't be parented to another form
              else
Keine Ahnung wer auf diese bescheuerte Idee gekommen ist auch bei NONE etwas zu machen.

Lösung:
Und statt OnActivate, ist sowieso CreateWnd besser. (auch wenn Beides geht)
Delphi-Quellcode:
type
  TForm3 = class(TForm)
    procedure FormCreate(Sender: TObject);
  protected
    procedure CreateWnd; override;
  end;

var
  Form3: TForm3;

implementation

{$R *.dfm}

procedure TForm3.CreateWnd;
begin
  inherited;
  SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE);
end;

procedure TForm3.FormCreate(Sender: TObject);
begin
  PopupMode := TPopupMode(9);
end;
[Edit3]
Oder Application.OnGetMainFormHandle benutzen und dort HWND(-1) zurückgeben.
Ein Therapeut entspricht 1024 Gigapeut.

Geändert von himitsu ( 9. Mai 2020 um 22:48 Uhr)
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 08:36 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz