Article View: borland.public.cppbuilder.nativeapi
Article #1259Re: How to bring window (TForm) front
From: Dennis Jones
Date: Mon, 24 Sep 2007 20:28
Date: Mon, 24 Sep 2007 20:28
58 lines
2912 bytes
2912 bytes
"Richard Kavanagh" <dd.foldhill[at]googlemail.com> wrote in message
news:46f80367@newsgroups.borland.com...
>> Well, my application, which is often in the system tray, gets restored to
>> the desktop when the second instance executes the code I posted earlier.
>> Does it not work for you? How are you minimizing your app to the tray?
>> - Dennis
>
> Dennis, I modified a TrayIcon component I found, (Apologies to the
> writer - I did not save your name) I think thev relevant function is:-
>
>
> void __fastcall TrkTrayIcon::MainFormVisible(bool AVisible)
> {
> // Do not change at Designtime...
> if(!ComponentState.Contains(csDesigning))
> {
> if((Application->MainForm != NULL) &&
> Application->MainForm->HandleAllocated())
> Application->MainForm->Visible = AVisible;
> }
> }
Okay. When I send my application to the tray, I do something similar:
void __fastcall TMyMainForm::MinimizeToTray(TObject* /*Sender*/)
{
ShowWindow(Application->Handle,SW_HIDE);
}
In my case,
if ( IsIconic( hAppWnd ) )
{
ShowWindow( hAppWnd, SW_RESTORE );
}
is sufficient to bring the application out of the tray and put it back onto
the desktop. So, you might try hiding the form with ShowWindow() instead of
using MainForm->Visible=false (I am not sure, but I think the two methods
work differently). Or, if you don't want to do that, you may be able to set
Visible=true in an OnRestore handler:
TMyMainForm::TMyMainForm(TComponent* Owner)
: TForm(Owner)
{
// call RestoreFromTray if the GUI is restored from a minimized/iconized
state
Application->OnRestore = RestoreFromTray;
}
void __fastcall TMyMainForm::RestoreFromTray(TObject* /*Sender*/)
{
Application->MainForm->Visible = true;
}
- Dennis
Technical Details
Message-ID:
<46f81de0$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<46eecb19@newsgroups.borland.com> <46f793b2$1@newsgroups.borland.com> <46f7ea4e$1@newsgroups.borland.com> <46f80367@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,67bd98c5f67e7407 X-Google-Attributes: gid10cc67,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Dennis Jones" <nospam@nospam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <46eecb19@newsgroups.borland.com> <46f793b2$1@newsgroups.borland.com> <46f7ea4e$1@newsgroups.borland.com> <46f80367@newsgroups.borland.com> Subject: Re: How to bring window (TForm) front Date: Mon, 24 Sep 2007 13:28:17 -0700 Lines: 60 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138 X-RFC2646: Format=Flowed; Response NNTP-Posting-Host: 71.245.109.58 Message-ID: <46f81de0$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1190665696 71.245.109.58 (24 Sep 2007 13:28:16 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail