๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #5564

Send WM-msgs to an app

#5564
From: Roland
Date: Mon, 08 Aug 2005 13:24
52 lines
2766 bytes
"Jonathan Benedicto" <incorrect@no.server> wrote:
>"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.)
>
>
>// 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 
>
>
Hello Jonathan,

I've done it in principe in this way. Before I tell my second app that the main app has lost the focus I transmitt the name of the last topmost window of the main app and the the 'Lost focus' message ... it runs.
Technical Details
Message-ID: <42f75d2b$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!border1.nntp.dca.giganews.com!feed5.newsreader.com!newsreader.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <42f1bb81$1@newsgroups.borland.com> <42f23355$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: "Roland" <neubert_nospam_@wst-gmbh.de>
Sender: "Roland" <neubert_nospam_@wst-gmbh.de>
Reply-To: "Roland" <neubert_nospam_@wst-gmbh.de>
Subject: Send WM-msgs to an app
Newsgroups: borland.public.cppbuilder.nativeapi
X-User-Info: 84.135.24.4     
References: <42f1bb81$1@newsgroups.borland.com> <42f23355$1@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <42f75d2b$1@newsgroups.borland.com>
Date: 8 Aug 2005 06:24:59 -0700
X-Trace: newsgroups.borland.com 1123507499 207.105.83.66 (8 Aug 2005 06:24:59 -0700)
Lines: 54
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!border1.nntp.dca.giganews.com!feed5.newsreader.com!newsreader.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail