Article View: borland.public.cppbuilder.nativeapi
Article #5618Re: Send WM-msgs to an app
From: Jonathan Benedicto
Date: Thu, 04 Aug 2005 15:25
Date: Thu, 04 Aug 2005 15:25
46 lines
2497 bytes
2497 bytes
"Roland" <neubert_nospam_@wst-gmbh.de> wrote in message
news:42f1bb81$1@newsgroups.borland.com...
> I try to find a way to make sure that my main app never lost the focus,
> because it is driven by a wheel only which only generates KeyUp and down
> messages and The Enter msg.Sometimes it may happen that a background
> app like pcAnywhere grabs the focus and the main app is then not longer
> accessible.
>
> At the moment the main app is started and controlled by a second
> app,so I can control some start conditions and I can watch the main app
> if it is
> alive.
>
> My suggestion is to use this second app to send some 'vitual mouse clicks๏ฟฝ
> to the main app when some other app has stolen the focus. I already
> obtained
> the processID of the main app and create the handle using OpenProcess to
> use
> the handle in SendMessage. But my main app does not receive these
> messages.
>
> Does anybody know the right way to send some WM_ messages to another app
> or does someone have another better idea to prevent my app from losing
> the focus. (The settings of TwaekUIXP do not solve the problem.)
Maybe using TApplication::OnDeactivate would help. Like this:
// In the form's constructor.
Application->OnDeactivate = HandleDeactivate;
void __fastcall TForm1::HandleDeactivate( TObject *Sender )
{
PostMessage( Handle, WM_APP + 1001, 0, 0 );
}
void __fastcall TForm1::WndProc( TMessage &Message )
{
if( Message.Msg == WM_APP + 1001 )
{
Application->BringToFront();
}
}
HTH
Jonathan
Technical Details
Message-ID:
<42f23355$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!newsstand.newsread.com!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<42f1bb81$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,faf37b23b2eaa8b1 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII From: "Jonathan Benedicto" <incorrect@no.server> Newsgroups: borland.public.cppbuilder.nativeapi References: <42f1bb81$1@newsgroups.borland.com> Subject: Re: Send WM-msgs to an app Date: Thu, 4 Aug 2005 11:25:09 -0400 Lines: 48 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2670 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 64.231.6.234 Message-ID: <42f23355$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1123169109 64.231.6.234 (4 Aug 2005 08:25:09 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!newsstand.newsread.com!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail