subclassing and SetWindowLongA

  • Thread starter Thread starter Alcibiade
  • Start date Start date
A

Alcibiade

HI, I should intercept messages of external windows.
I have same problem descripted here http://bytes.com/forum/
thread515335.html
I can't find declaration of SetWindowLongA for vb2005/2008 and some
example for using it.
Anyone could help me please?
Thanks
 
HI, I should intercept messages of external windows.
I have same problem descripted herehttp://bytes.com/forum/
thread515335.html
I can't find declaration of SetWindowLongA for vb2005/2008 and some
example for using it.
Anyone could help me please?
Thanks

Look at this MSDN link and scroll down to "Possible VB9 decleration"
if it works for SetWindowLong:
http://msdn.microsoft.com/en-us/library/ms633591(VS.85).aspx

Hope this helps,

Onur G.
 
Alcibiade said:
HI, I should intercept messages of external windows.
I have same problem descripted here http://bytes.com/forum/
thread515335.html
I can't find declaration of SetWindowLongA for vb2005/2008 and some
example for using it.

'SetWindowLong' + "subclassing" won't help here because it does not work
with other processes' windows. You need an appropriate message hook
instead, which cannot be implemented in a managed language.
 
Look at this MSDN link and scroll down to "Possible VB9 decleration"
if it works for SetWindowLong:http://msdn.microsoft.com/en-us/library/ms633591(VS.85).aspx

Hope this helps,

Onur G.

I'm trying:
<DllImport("user32.dll", EntryPoint:="SetWindowLongA")> _
Public Function SetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex
As Integer, ByVal dwNewLong As [Delegate]) As IntPtr
End Function

<DllImport("user32.dll", EntryPoint:="SetWindowLongA")> _
Function SetWindowLong(ByVal hwnd As Integer, ByVal nIndex As
Integer, ByVal dwNewLong As Integer) As Integer
End Function

lProcOld = SetWindowLong(CType(Me.TextBox1.Text, IntPtr), GWL_WNDPROC,
AddressOf WndProcz)

I receive error: can't convert addressof in system.delegate because
system.delegate is declared as "mustinherit" and it is impossible to
create it....
Any ideas?
 
'SetWindowLong' + "subclassing" won't help here because it does not work
with other processes' windows.  You need an appropriate message hook
instead, which cannot be implemented in a managed language.
Thanks, you are right!!!( unfortunately :( )
I've created the program but it works only with its own window....
could I use a .net with a external dll written in C?
Thanks
 
Alcibiade said:
Thanks, you are right!!!( unfortunately :( )
I've created the program but it works only with its own window....
could I use a .net with a external dll written in C?

Yes, this would work. You need an IPC mechanism like a named pipe to send
the messages from the DLL (which is injected into each process) to your
process.
 
Yes, this would work.  You need an IPC mechanism like a named pipe to send
the messages from the DLL (which is injected into each process) to your
process.

--

Ok, I'have created my Dll in c:
my vb program finds hwnd and sendit to myfunction in dll
In dll I call SetWindowLong and I create callback proc.

Problem is: it works only if hwnd is same of my Vb exe.
Why? Thanks
 
Alcibiade said:
Ok, I'have created my Dll in c:
my vb program finds hwnd and sendit to myfunction in dll
In dll I call SetWindowLong and I create callback proc.

Problem is: it works only if hwnd is same of my Vb exe.
Why? Thanks

'SetWindowLong' doesn't help here as it only works within the process.
Instead, use 'SetWindowsHook'/'SetWindowsHookEx'. Make sure you read and
understand the MSDN chapter about Windows hooks, as hooks can easily block
the system.
 
'SetWindowLong' doesn't help here as it only works within the process.
Instead, use 'SetWindowsHook'/'SetWindowsHookEx'.  Make sure you read and
understand the MSDN chapter about Windows hooks, as hooks can easily block
the system.

Ok, thanks for your help ;)
 
Back
Top