Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-03

Main Form Visibility problems (Was Should TTrayIcon Work)

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Tommi Prami

OK,

This was not issue of the TTrayIcon at all,..

First I forgot the Release Compiling option so Brake points did not work, I mainly work with Delphi and not been using Lazarus for awhile... Even it is very familiar, but some things are different (and that is OK...)

And couple other issues that I did not see coming...

If I had code like this

// Idea is to get rid of app from the Task Bar
Self.WindowsState := wsMinimized;
Self.Visible := False;

And then I had in TTrayIcon event

if not Self.Visible then
begin
   .. Try Show the form here
end;

The Seems that form thought it would be visible even I set it False just before...

So I took the If out of there, so it works... (Did not check WindowsState, maybe that would work???)

And then the final Gotcha...

I added Start Minimized Functionality to Program and if I set minimize the Form and set visible to False on Forms.OnCreate Event. Form never comes back again.

I made Hack to start timer with Short delay, and do the minimizing of the Form there. After the form has been shown, then it works...

Not sure are these bugs, (In FPC/Lazarus level or even Windows) or how I could hide the Window without showing the Glimpse of it before...

And if I set forms Visible to False, one could think you can trust it stays that way

I can file bug reports if these seems to be bugs... I have simple test App attached, if someone what to tinker with it...

-tee-
-------------- next part --------------
A non-text attachment was scrubbed...
Name: LazarusTrayIconTest.7z
Type: application/octet-stream
Size: 124701 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130321/db9bcb88/attachment-0001.obj>

Reply by email

Flávio Etrusco
to Tommi Prami
Tommi Prami wrote 17 lines
(...) If I had code like this // Idea is to get rid of app from the Task Bar Self.WindowsState := wsMinimized; Self.Visible := False; And then I had in TTrayIcon event if not Self.Visible then begin .. Try Show the form here end; The Seems that form thought it would be visible even I set it False just before...

Like in Delphi, TApplication always shows the "main form" (the first form registered with App.AddForm) when Application.Run is called. You must toggle Application.ShowMainForm
(http://lazarus-ccr.sourceforge.net/docs/lcl/forms/tapplication.showmainform.html). I guess it's preferable to call it just after Application.Initialize (in the .lpr), but maybe just calling it before Application.Run is enough.

(...) -tee-

-Fl?vio

Reply by email