Autor Beitrag
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Fr 29.10.10 14:36 
Hi.

Ich stehe gerade vor dem Problem, dass ich eine Anwendung habe, in der der Benutzer Daten in modalen Fenstern bearbeiten kann. Diese werden ganz normal mit ShowModal; aufgerufen.
Nun gibt es in dem Programm aber noch ein kleines Tool-Fensterchen, das immer neben dran herum schwebt. Dieses ist natürlich nach dem modalen Aufruf eines anderen Fensters nicht mehr bedienbar.

Gibt es denn eine Möglichkeit, dass man das kleine Tool-Fenster trotz eines anderen aktiven modalen Fensters noch bedienbar machen kann?

Danke!
Matze

_________________
In the beginning was the word.
And the word was content-type: text/plain.
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Fr 29.10.10 15:34 
mhhh einen kleinen Fake könnte ich Dir anbieten, wenn Du die Vorlage Deiner Modalen Dialoge um ein Panel aufbohrst:
Form2 ist hier Dein Toolfenster, Form3 Deine Modalen, würde halt noch die ganze Assigned/Visible Prüfung fehlen....

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
procedure TForm1.Button2Click(Sender: TObject);
begin
  With TForm3. Create(self) do
    begin
    ShowModal;
    Free;
    end;
end;



procedure TForm3.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin

   Form2.Align := alnone;
   Form2.BoundsRect := FBounds;
   Form2.Parent := FP;

end;

procedure TForm3.FormShow(Sender: TObject);
begin
   FP := Form2.Parent;
   FBounds := Form2.BoundsRect;
   Form2.Parent := Panel1;
   Form2.Align := alClient;
end;
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Fr 29.10.10 17:04 
Werden die anderen Fenster bei Showmodal nicht nur auf Enabled:= false gesetzt?

Dann müsste man doch eigentlich auch im OnShow des modalen Fensters eins selektiv wieder enablen können... mal so ins blaue geraten.

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Fr 29.10.10 17:07 
user profile iconMartok hat folgendes geschrieben Zum zitierten Posting springen:
Werden die anderen Fenster bei Showmodal nicht nur auf Enabled:= false gesetzt?
Nein, so einfach ist das dann doch nicht. ;-)

Es gibt dafür glaube ich Möglichkeiten, welche sinnvoll ist, hängt vom Projekt ab. Ich schreibe nachher zu Hause mehr dazu.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Fr 29.10.10 23:03 
@Martok: Jep. Modal setzt ein DisableControls für alle sichtbaren Toplevel-Fenster. Müsste aber auch erst den Source dazu rauskramen, wo das in TCustomForm gemacht wird.

Man kann da durchaus was hacken an der Stelle, aber inwiefern das praktikabel ist, hängt stark von der App ab.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Fr 29.10.10 23:18 
Ist zwar eine unschöne Lösung aber, versuch mal procedure WMEnable(var Message: TMessage); message WM_ENABLE; + EnableWindow(Handle, True).
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 30.10.10 06:17 
Das wird denke ich nicht gehen, denn Delphi fängt genau diese Messages ab während modal aktiv ist. ;-)
Dafür gibt es eine entsprechende Fensterliste.

// EDIT:
Nein, ich habe mich geirrt, EnableWindow klappt, nur WM_ENABLE wird abgefangen und funktioniert daher nicht. :zustimm:
matze Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Sa 30.10.10 10:40 
Puh. Sieht also danach aus, als gäbe es nicht wirklich eine saubere praktikable Lösung, sehe ich das richtig?
In diesem Fall stampfe ich dann das Tool-Window einfach ein und mache das irgendwie anders in meinem Programm :-)

Danke euch für die vielen Antworten!

Matze

_________________
In the beginning was the word.
And the word was content-type: text/plain.
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Sa 30.10.10 10:48 
Die Lösung verdient zwar keinen Schönheitspreis, funktioniert aber eigentlich gut. Was spricht dagegen?

Du kannst die Änderung ja in eine eigene Klasse verlegen. Solange der Code gut getestet ist und das ganze gekapselt ist, kann dir die Implementation praktisch egal sein. Falls es doch mal zu Problemen führen sollte, kannst du dann einfach die Implementation durch was besseres austauschen.

Irgendwie so könnte das aussehen:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
unit ModalOverrideForms;

interface

uses Windows, Messages, Classes, Controls, Forms;

type
  TModalOverrideForm = class(TForm)
  private
    FInternalChanging: Integer;
    procedure WMEnable(var Message: TWMEnable); message WM_ENABLE;
    procedure CMEnabledChanged(var Message: TMessage); message CM_ENABLEDCHANGED;
  end;

implementation

procedure TModalOverrideForm.CMEnabledChanged(var Message: TMessage);
begin
  Inc(FInternalChanging);
  try
    inherited;
  finally
    Dec(FInternalChanging);
  end;
end;

procedure TModalOverrideForm.WMEnable(var Message: TWMEnable);
begin
  inherited;
  if Enabled and not Message.Enabled and (FInternalChanging = 0then
    EnableWindow(Handle, True);
end;

end.

Für diesen Beitrag haben gedankt: BenBE, FinnO, Martok
matze Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Di 02.11.10 21:46 
Vielen Dank an euch alle!

_________________
In the beginning was the word.
And the word was content-type: text/plain.