Piszę aplikacje MDI i mam taki problem:
Nie wiem jak zrobić aby istniająca forma stała się aktywna :/
Mam taką procedurę:
procedure TMainForm.UtworzMDIChild(Tekst: String);
var
I, Liczba: Integer;
Jest: Boolean;
begin
Jest := False;
for I:=0 to MDICHildCount-1 do //sprawdzam czy forma już istnieje
begin
if MDIChildren[I].Caption = Tekst then
begin
Liczba := I;
Jest := True;
Break;
end;
end;
if Jest = False then //jeśli forma nie istnieje to ją utwórz
begin
if Tekst = 'A' then TAForm.Create(Self);
if Tekst = 'B' then TBForm.Create(Self);
if Tekst = 'C' then TCForm.Create(Self);
end;
if Jest = True then //jeśli forma istnieje to ją uaktywnij
begin
SetForegroundWindow(MDIChildren[Liczba].Handle);
end;
end;
Myślałem, że dzięki SetForegroundWindow(MDIChildren[Liczba].Handle); forma stanie się aktywna. Tak się jednak nie dzieje :/
Co jest źle ? Co powinienem napisać aby istniejąca forma stała się aktywna ?
Z góry dzięki za pomoc
Pozdro