Article View: borland.public.cppbuilder.nativeapi
Article #6485[Remy] SendMessage() from a DLL to APP
From: Vladimir Stefanovic
Date: Tue, 03 May 2005 09:48
Date: Tue, 03 May 2005 09:48
66 lines
2874 bytes
2874 bytes
Hi Remy,
I wanted to avoid getting HWND of some APP from my DLL
by FindWindow() because of some problems I reported before.
Then you suggested me to pass the APP HWND to a DLL directly,
and so avoid determining the APP HWND all the time by
FindWindow().
You also suggested me to store the HWND in the shared memory
because that every DLL instance can have a valid HWND, but in my
case the APP can have in fact only *one* instance, so I suppose that
is not necessary.
That concept works *almost* fine for me, but... The funy thing
is that if my APP is in tray - nothing happens, ie. my APP
KeyHook() function that should be triggered by DLL's:
// Send key information to the main window
SendMessage( hAppWnd, WM_KEYHOOK, 0, lParam );
... simply is not executed. I placed a fake ShowMessage("?"),
but it's not reached if the APP is in tray.
If the app is on screen, it is triggered.
Whay I'm missing? Is there anything I can do to avoid FindWindow()
which indeed works if the APP is in tray?
--- DLL ---
// ...
HWND hAppWnd;
// ...
void __stdcall SetHook( HWND hWnd )
{
ghhookKB = SetWindowsHookEx( WH_KEYBOARD, (HOOKPROC)CheckKey, ghInst,
NULL );
hAppWnd = hWnd;
}
// ...
DWORD __stdcall CheckKey( int nCode, WORD wParam, LONG lParam )
{
if ( ( nCode < 0 ) || ( nCode == HC_NOREMOVE ) )
return CallNextHookEx( ghhookKB, nCode, wParam, lParam );
// Skip if it's a repeat
if ( lParam & 0x40000000 )
return CallNextHookEx( ghhookKB, nCode, wParam, lParam );
// Check if Alt is pressed
if ( !( lParam & ( 1<<29 ) ) )
return CallNextHookEx( ghhookKB, nCode, wParam, lParam );
// Send key information to the main window
SendMessage( hAppWnd, WM_KEYHOOK, 0, lParam );
return CallNextHookEx( ghhookKB, nCode, wParam, lParam );
}
/************************************************************/
--
Best regards,
Vladimir Stefanovic
Technical Details
Message-ID:
<427748eb@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!news-in.nuthinbutnews.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,94b1d46dd644a85c,start X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Vladimir Stefanovic" <antivari@po.sbb.co.yu> Newsgroups: borland.public.cppbuilder.nativeapi Subject: [Remy] SendMessage() from a DLL to APP Date: Tue, 3 May 2005 11:48:30 +0200 Lines: 68 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 NNTP-Posting-Host: 82.117.212.65 Message-ID: <427748eb@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1115113707 82.117.212.65 (3 May 2005 02:48:27 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!news-in.nuthinbutnews.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail