Article View: borland.public.cppbuilder.nativeapi
Article #8072Re: Wierd CBTHook problem
From: mike
Date: Wed, 01 Dec 2004 21:36
Date: Wed, 01 Dec 2004 21:36
156 lines
4450 bytes
4450 bytes
Remy,
Thanks for responding. Here is the code that I am using to send the message
to the window of my control application. The hWnd within the sendmessage is
set through another call that initialzes the memory map file. I do get
messages to the control application so I assume that part is working ok. But
Internet Explorer ends up crashing after a number of message have been
received.
Thanks for any additional help on this.
Mike
LRESULT CALLBACK CBTProc( int nCode, WPARAM wParam, LPARAM lParam)
{
bool ByPassKey = false
;
bool RetValue = true
;
HANDLE hFileMapHandle = NULL
;
LPVOID lpFileMapAddress = NULL
;
AnsiString NameVal
;
AnsiString WindowClass
;
COPYDATASTRUCT cds
;
char buffer[MAX_PATH]
;
while ( true )
{
memset( buffer, 0x00, strlen( buffer ) )
;
hFileMapHandle = OpenFileMap()
;
if (hFileMapHandle == NULL)
{
RetValue = false
;
break ;
}
lpFileMapAddress = MapFile( hFileMapHandle )
;
if (lpFileMapAddress == NULL)
{
RetValue = false
;
break ;
}
tagMemoryFileDefinition *MyMemoryFile = (tagMemoryFileDefinition
*)((LPDWORD) lpFileMapAddress);
if( nCode < 0 )
{
UnmapViewOfFile( lpFileMapAddress )
;
CloseHandle( hFileMapHandle )
;
return CallNextHookEx( hMsgHook,
nCode,
wParam,
lParam) ;
}
HWND hWnd = MyMemoryFile->hWindowForMessages
;
hMsgHook = MyMemoryFile->hMessageHook
;
if ( ( nCode >= 0 ) && ( nCode == HCBT_CREATEWND ) )
{
HWND hWndCreate = ( HWND )wParam
;
LPCBT_CREATEWND pcbt = ( LPCBT_CREATEWND )lParam
;
CREATESTRUCT *pcs = (( CBT_CREATEWND * )lParam)->lpcs
;
NameVal = pcs->lpszName
;
::GetClassName( hWndCreate, buffer, 256 )
;
WindowClass = AnsiString( buffer )
;
NameVal = "Class "
;
NameVal += WindowClass
;
cds.dwData = 10000
;
cds.cbData = 0
;
cds.lpData = NameVal.c_str()
;
::SendMessage(hWnd, WM_COPYDATA, 0, (LPARAM)&cds)
;
break ;
}
UnmapViewOfFile( lpFileMapAddress )
;
CloseHandle( hFileMapHandle )
;
if ( ByPassKey )
{
return 1 ;
}
else
{
return CallNextHookEx ( hMsgHook, nCode, wParam, lParam )
;
}
}
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:41ae2598$1@newsgroups.borland.com...
>
> "mike" <mfbrowne@earthlink.net> wrote in message
> news:41ae07e2$1@newsgroups.borland.com...
>
> > everything works well except for when I open Internet Explorer.
> > When I do Internet Explorer starts its window creation and then
> > for no reason just crashes and asks to send the error report to
> > Microsoft. Now this onlt happens when I am sending the WMCOPY
> > message to my controlling program. If I stop the message send then
> > all works fine in respect to no crash from Internet Explorer.
>
> Please show your actual code.
>
>
> Gambit
>
>
Technical Details
Message-ID:
<41ae3911@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<41ae07e2$1@newsgroups.borland.com> <41ae2598$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,80a054b0854861c4 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "mike" <mfbrowne@earthlink.net> Newsgroups: borland.public.cppbuilder.nativeapi References: <41ae07e2$1@newsgroups.borland.com> <41ae2598$1@newsgroups.borland.com> Subject: Re: Wierd CBTHook problem Date: Wed, 1 Dec 2004 16:36:20 -0500 Lines: 158 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 68.204.189.169 Message-ID: <41ae3911@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1101936913 68.204.189.169 (1 Dec 2004 13:35:13 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail