I have this systray-application.
From within this app I want to show a form, but this form must not get the
focus, something like the message form in MSN messenger.
The problem is that the app does take the focus away from the app I was
currently working in but this only the second time i show the form.
So, does anyone know how can i show the form without losing focus of the app
i am working in?
The form is an auto-create form. In the create and destroy I do'n do a
thing.
I have a public Init method for showing the form.
My Init method on the form is as followed
function TMessengerForm.Init(const Caption : string;
const Message : string; const MessageType : integer;
const BalloonHintTime : integer) : Boolean;
begin
Result := False;
try // statements to try
FormStyle := fsNormal;
Visible := False;
ShowWindow( handle, SW_SHOWNA );
Visible := True;
Result := True;
except
on e:Exception do
begin
ObjectModule.Logbook.Message := 'Except tijdens Init';
ObjectModule.Logbook.Message := e.Message;
end;
end; // try/except
end;
procedure TMessengerForm.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.Style := (Params.Style OR WS_POPUP) AND (NOT
WS_DLGFRAME);
Params.ExStyle := WS_EX_TOOLWINDOW;
AddBiDiModeExStyle(Params.ExStyle);
Params.WindowClass.Style := CS_SAVEBITS;
end;
Setting Visible or calling Show/Hide internally calls ShowWindow, which
will bring the form forward. Use the ShowWindow API alone, don't sync
Visible and don't call Show/Hide. Actually, by doing Hide and then Show you
effectively rendered the ShowWindow call useless.
Let me know how it works out. I see no other reason for this to happen
(yet:).
--
Andrei "Ndi" Dobrin
Brainbench MVP
www.Brainbench.com
I think the strange behaviour has something to do with the fact that i'm
showing the form from within a systray application.
I use the CoolTrayIcon component for this. Perhaps this is what's causing
all the trouble but I haven't found out yet what exactly is the problem
then.
Marco van Kimmenade
"Ndi" <Ndi...@Yahoo.com> wrote in message
news:4123...@newsgroups.borland.com...
Because mine doesn't.