Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2006 Nov : using FindWindowEx and Windows.RegisterClass

www.cryer.info
Managed Newsgroup Archive

using FindWindowEx and Windows.RegisterClass

Subject:using FindWindowEx and Windows.RegisterClass
Posted by:"Reiner" (slu..@yahoo.com)
Date:Wed, 8 Nov 2006 15:46:58

I am trying to debug a program written in VB. It finds a window then a child
of that. The VB has code similar to the following which it then uses to send
messages to.

  m_HWND = FindWindow(vbNullString, "Main")
  If m_HWND > 0 Then
    m_ReceiveHWND = FindWindowEx(m_HWND, 0, "SCx:10000000:0", "Caption")

How do I create a (child) window in Delphi to receive the messages sent to
m_ReceiveHWND (if its found)?

I have played around with Windows.RegisterClass but the VB program fails to
connect (find the child window), see below. As far as I can tell the
RegisterClass works (a non-zero value is returned) but I don't see that this
class is necessarily registered for this child window (does it need to be?).

My job is to inspect the messages this program (written in VB) is sending to
a third-party application so I was going to replace this third-party
application with my Delphi test application.

{ begin Delphi Code }
procedure ...
var
  lpWndClass: TWndClassA;
  e : DWORD;
begin
  FillChar(lpWndClass, SizeOf(lpWndClass), 0);
  lpWndClass.lpfnWndProc := @WindowProc;
  lpWndClass.hInstance := HInstance;
  lpWndClass.lpszClassName := SCx:10000000:0';

  FClassAtom := Windows.RegisterClass(lpWndClass);
  if FClassAtom = 0 then
  begin
    e := GetLastError;
    raise Exception.Create(Format('%d %s', [e, SysErrorMessage(e)]));
  end;
end;

Replies:

www.cryer.info
Managed Newsgroup Archive