Article View: borland.public.cppbuilder.nativeapi
Article #1261Re: How to bring window (TForm) front
From: Richard Kavanagh
Date: Tue, 25 Sep 2007 09:29
Date: Tue, 25 Sep 2007 09:29
26 lines
2053 bytes
2053 bytes
Dennis,
Many thanks. I solved the problem by adding a PostMessage() command - see
below.
Richard.
// get the window handle of the other instance's main form
//(according to its class name)
HWND mainFormHWnd = ::FindWindow( "TMyMainForm", NULL );
// added the following line to show main form if running in tray
::PostMessage(mainFormHWnd, WM_SYSCOMMAND, SC_RESTORE, 0);
// still need the rest if program running 'normally'
// get the main form's parent window handle (we'll assume mainFormHWnd
// is not NULL, since we wouldn't even be here unless another instance
// of the application were actually running)
HWND hAppWnd = (HWND)::GetWindowLong( mainFormHWnd, GWL_HWNDPARENT );
if(::IsIconic( hAppWnd ) )
{
::ShowWindow( hAppWnd, SW_RESTORE );
}
::SetForegroundWindow( hAppWnd );
return 0;
Technical Details
Message-ID:
<46f8d507@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.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> <46f81de0$1@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 Reply-To: "Richard Kavanagh" <dd.foldhill[at]googlemail.com> From: "Richard Kavanagh" <dd.foldhill[at]googlemail.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> <46f81de0$1@newsgroups.borland.com> Subject: Re: How to bring window (TForm) front Date: Tue, 25 Sep 2007 10:29:40 +0100 Lines: 28 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: 84.92.225.65 Message-ID: <46f8d507@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1190712583 84.92.225.65 (25 Sep 2007 02:29:43 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.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