Autor Beitrag
DiamondDog
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 460



BeitragVerfasst: Di 22.07.08 12:02 
Hallo Leute,
Hab da folgendes Problem:
Also meine Form1 wird über einen Button aufgerufen, Problem dabei ist das die Form1 komischerweise 2 mal aufgerufen wird.
In der Form1 hab ich nen Timer der die Form automatisch wieder schließst.
Also wenn ich selber auf den Button klicke funktioniert das ganze.
Nur wenn ich den klick simuliere über (NeedMessage) dann macht er die Form1 immer doppelt auf.
Wie kann ich es verhindern das sie Doppelt geöffnet wird?
Und am Rande wieso wird sie 2 mal geöffnet?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
function TQipPlugin.NeedMessage: boolean;
begin
  if not HotKeyOn then
  begin
    MuteSound:=false;
    if assigned(fmDBoxOptions) then fmDBoxOptions.ShowMuteMode;
  end;
  if MuteSound then
  begin
    result:=false;
    exit;
  end;
   fmDBoxOptions.Button1.Enabled:=False;
   fmDBoxOptions.Button1.Click;
   Result:=true;
end;

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
procedure TfmDBoxOptions.Button1Click(Sender: TObject);
begin
  Button1.Enabled:=False;
  Timer2.Enabled:=True;
  {Wenn DBox erreichbar}
  if Ping.Execute(Edit1.Text) >= 0 then // IP-Adressen = Edit1.Text
   begin
    {Form1 erzeugen}
    Form1:=TForm1.Create(Application);
    {Starte Timer zum Schließen von Form1 (Browser)}
    Form1.Timer1.Enabled:=True;

    Form1.WebBrowser1.Navigate('http://' + Edit1.Text + '/control/message?popup=' + Edit2.Text);  // Browser öffnet Seite (Edit1.text)
    {Form1 anzeigen}
    Form1.Show;
    {Browser Focus setzen}
    Form1.WebBrowser1.SetFocus
    end;
end;



Moderiert von user profile iconNarses: Topic aus Sonstiges (Delphi) verschoben am Di 22.07.2008 um 15:46
DiamondDog Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 460



BeitragVerfasst: Do 24.07.08 14:40 
Weiß den niemand wie ich das verhindern kann?
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Do 24.07.08 16:20 
Hast du das Formular in den automatisch erzeugten rausgeschmissen? (Projektoptionen -> Formulare)
DiamondDog Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 460



BeitragVerfasst: Do 24.07.08 17:50 
Ahh hab den Fehler gefunden,
hatte mein Plugin von eines SDK Version abegleitet und hatte da übersehn das in der 2 mal die function NeedMessage aufgerufen wurd.
Aber wie kann ich den trozdem verhindern das Form1 2mal offen ist?
Aber nicht so das dann wenn der 2te aufruf kommt auf Form1 die offen ist gewechselt wird, se soll wenn Form1 auf ist keine neue Form1 aufgemacht werden oder auf Form1 gewechselt werden.
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Do 24.07.08 18:57 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
If not assigned(Form1) then
begin
  ...
  Form1.Show;
  ...
end;


setzt vorraus, dass du Form1 beim schließen auf nil setzt.