Board index » cppbuilder » Re: Memo not showing when Lines Added

Re: Memo not showing when Lines Added


2005-12-06 04:06:59 PM
cppbuilder97
Gert Kok < XXXX@XXXXX.COM >wrote:
Quote

An application that is using TrayIcon,
Do not use that component. Not only is it *very* buggy, two of
the bugs are fatal. Try this instead:
groups.google.com/group/borland.public.cppbuilder.vcl.components.using/msg/57af11b9a35689b0&
Quote
and is minimised at startup, has a TMemo instance. When the
window is shown before a line is added to the Lines of this
Memo, the memo is visible.

When a line is added before the window is shown, the Memo
remains hidden.
It sounds like a refresh problem which *might* be being caused
by the TrayIcon but I doubt that. You'll need to reduce your
code to a minimal example that illustrates the problem and
post that.
~ JD
 
 

Re:Re: Memo not showing when Lines Added

An application that is using TrayIcon, and is minimised at startup, has
a TMemo instance. When the window is shown before a line is added to the
Lines of this Memo, the memo is visible.
When a line is added before the window is shown, the Memo remains hidden.
Can the Memo be forced to become/stay visible?
 

Re:Re: Memo not showing when Lines Added

JD wrote:
Quote
Gert Kok < XXXX@XXXXX.COM >wrote:

>An application that is using TrayIcon,

Do not use that component. Not only is it *very* buggy, two of
the bugs are fatal.
I have developed at least three non-animated TTrayIcon apps and they all work absolutely
fine. What are these fatal bugs you talk about? Here is the only TTrayIcon event I handle
(called when OnRestore is fired) :-
//---------------------------------------------------------------------------
void __fastcall TForm1::Show1Click(TObject *Sender)
{
if (Visible) { Visible=false; TrayIcon1->Minimize(); return;}
Visible=true; Application->Restore();
Memo1->SetFocus(); Memo1->Perform(EM_SCROLLCARET,0,0);
}
//---------------------------------------------------------------------------
--
Mark Jacobs
www.dkcomputing.co.uk
 

{smallsort}

Re:Re: Memo not showing when Lines Added

Mark Jacobs <www.jacobsm.com/mjmsg.htm?mj@critical>wrote:
Quote

I have developed at least three non-animated TTrayIcon apps
and they all work absolutely fine.
Then you've been quite lucky ... so far.
Quote
What are these fatal bugs you talk about?
The first one Gambit pointed out and can be seen when Windows
(for what ever reason) restarts Explorer. What happens is that
Windows broadcasts a message so that applications can re-add
themselves to the tray. TTrayIcon does not acdount for this
possibility so the application can be left loaded with no
means to activate it.
Is this fatal? Perhaps not but my tray applications only allow
a single instance to be launched so in my case, the user would
have to reboot and this is worse than a crash because the user
is left scratching their head.
The second one I found. TTrayIcon doesn't account for the fact
that the form's underlying HWND *can* be recreated. If it ever
is, the form's Handle will change which will result in the
TrayIcon becoming non-responsive because it's sending messages
to an invalid handle.
Is this fatal? I'd say so. Anything that makes my application
stop working is fatal - including users <g>.
Quote
Here is the only TTrayIcon event I handle
If you insist on continuing to use TTrayIcon, you need to add
more code to make it safe. Both of the issues noted above can
be handled by you but you'll have to duplicate the code
manually in all of your applications.
Use AllocateHWnd so that you can get a stable Handle to pass
to the object. The net result will be that the hosting form
will have 2 Handles and 2 WndProcs but the ones that you add
will have to have a (slightly) different names and they will
be used only with the TTrayIcon.
Then to handle when Explorer is restarted, you'll have to
subclass the main form's WndProc method and listen for when
this happens but there's a trick to it. Windows does not use
a predefined message to broadcast this event. Rather, every
time Windows starts it uses RegisterWindowMessage with the
string constant "TaskbarCreated" to create (on-the-fly)
the numeric value for the message. So ... you have to do this
as well.
Sample code for both can be found in the code from the link
that I posted.
~ JD
 

Re:Re: Memo not showing when Lines Added

"JD" < XXXX@XXXXX.COM >wrote:
Quote

If you insist on continuing to use TTrayIcon, you need to add
more code to make it safe.
On second thought ... I think your stuck with what it is but
I'm not inclined to dive into it when I'll only get stink on
me.
~ JD
 

Re:Re: Memo not showing when Lines Added

JD wrote:
Quote
"JD" < XXXX@XXXXX.COM >wrote:

>If you insist on continuing to use TTrayIcon, you need to add
>more code to make it safe.

On second thought ... I think your stuck with what it is but
I'm not inclined to dive into it when I'll only get stink on
me.

Thanks for your advice. The main form's handle is a worry, but I'm not too bothered about
Explorer being restarted, because so many other commercial apps don't handle this
properly. If it ain't broke, don't fix it, so to speak.
--
Mark Jacobs
www.dkcomputing.co.uk