Article View: borland.public.cppbuilder.nativeapi
Article #1326Re: How to bring window (TForm) front
From: Vladimir Stefanovic
Date: Mon, 17 Sep 2007 19:34
Date: Mon, 17 Sep 2007 19:34
84 lines
3429 bytes
3429 bytes
> [...] The running program must bring it's window to the
> front, but that seems to be difficult under Windows XP.
I know exactly what you are talking about, becasue I've
developed similar software few years ago. I experienced
the very same issues. Every single code which worked in
one scenariio faild in other and vice versa.
Now, I've looked in the code which I beleave was a solution
in my case. You can try and check if it can help in your case.
I tried everything, and stopped with this silly code.
--- Service EXE which calls other EXE ---
// function C(...) is my internal, and it returns just an AnsiString
// from crypted resource file.
// Just use simple "...some appropriate text ..." instead
// ...
HANDLE lanmsg = FindWindow(
C(IDS_SER_MAIN_NT_SERVICE_INVOKING_CLASS).c_str(), NULL );
if ( lanmsg != NULL )
{
// These three lines helped.
// Of course I could bundle all this in just one call but then
// things just didn't work (flickering in status bar)
PostMessage ( lanmsg, WM_USER + 1010, 0, 0 );
PostMessage ( lanmsg, WM_USER + 1011, 0, 0 );
PostMessage ( lanmsg, WM_USER + 1012, 0, 0 );
}
else
{
AnsiString Exe = ExtractFilePath( ParamStr(0) ) +
C(IDS_SER_MAIN_NT_SERVICE_INVOKING_EXE_FILE);
STARTUPINFO StartInfo;
PROCESS_INFORMATION ProcInfo;
memset(&ProcInfo, 0, sizeof(ProcInfo));
memset(&StartInfo, 0 , sizeof(StartInfo));
StartInfo.cb = sizeof(StartInfo);
if ( ! CreateProcess( Exe.c_str(),NULL, NULL, NULL, NULL, NULL, NULL,
NULL,
&StartInfo, &ProcInfo ) )
{
SystemOk = false;
GoSendMessageToLog( SERVICE_CREATE_PROCESS_FAILED );
}
}
// ...
--- EXE which is called ---
(btw, it was FormStyle = fsStayOnTop)
void __fastcall TLanMsgMainForm::WndProc( TMessage &Msg )
{
switch ( Msg.Msg )
{
// ...
case WM_USER + 1010:
ReloadView(); //<--- Data to be shown in TreeView
break;
case WM_USER + 1011:
Application->Restore();
break;
case WM_USER + 1012:
Application->BringToFront();
break;
// ...
}
TForm::WndProc( Msg );
}
All this tels me that some Application->ProcessMessages()
placed in appropriate place could help in preventing flashing
app in status bar, but never had time to investigate further.
--
Best Regards,
Vladimir Stefanovic
Technical Details
Message-ID:
<46eed6a9$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<46eecb19@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: "Vladimir Stefanovic" <antivari@sbb.co.yu> Newsgroups: borland.public.cppbuilder.nativeapi References: <46eecb19@newsgroups.borland.com> Subject: Re: How to bring window (TForm) front Date: Mon, 17 Sep 2007 21:34:02 +0200 Lines: 86 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 NNTP-Posting-Host: 87.116.181.111 Message-ID: <46eed6a9$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1190057641 87.116.181.111 (17 Sep 2007 12:34:01 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail