473,324 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

subclassing and SetWindowLongA

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
Sep 1 '08 #1
8 2835
On Sep 1, 11:29*pm, Alcibiade <panda...@libero.itwrote:
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/libr...91(VS.85).aspx

Hope this helps,

Onur G.
Sep 1 '08 #2
"Alcibiade" <pa******@libero.itschrieb:
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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Sep 1 '08 #3
On 1 Set, 22:43, kimiraikkonen <kimiraikkone...@gmail.comwrote:
Look at this MSDN link and scroll down to "Possible VB9 decleration"
if it works for SetWindowLong:http://msdn.microsoft.com/en-us/libr...91(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?
Sep 2 '08 #4
On 2 Set, 00:01, "Herfried K. Wagner [MVP]" <hirf-spam-me-h...@gmx.at>
wrote:
'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
Sep 3 '08 #5
"Alcibiade" <pa******@libero.itschrieb:
>'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?
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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Sep 3 '08 #6
On 4 Set, 00:57, "Herfried K. Wagner [MVP]" <hirf-spam-me-h...@gmx.at>
wrote:
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.

--
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

Sep 7 '08 #7
"Alcibiade" <pa******@libero.itschrieb:
>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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Sep 10 '08 #8
On 10 Set, 22:20, "Herfried K. Wagner [MVP]" <hirf-spam-me-
h...@gmx.atwrote:
"Alcibiade" <panda...@libero.itschrieb:
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.
Ok, thanks for your help ;)
Sep 11 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: WhiteRavenEye | last post by:
Why can't I subclass any window except mine in VB? Do I have to write dll for this? I've tried to subclass it with SetWindowLong but without success... Does anyone know how to subclass window...
4
by: GrelEns | last post by:
hello, i wonder if this possible to subclass a list or a tuple and add more attributes ? also does someone have a link to how well define is own iterable object ? what i was expecting was...
2
by: David Vaughan | last post by:
I'm using v2.3, and trying to write to text files, but with a maximum line length. So, if a line is getting too long, a suitable ' ' character is replaced by a new line. I'm subclassing the file...
2
by: BJörn Lindqvist | last post by:
A problem I have occured recently is that I want to subclass builtin types. Especially subclassing list is very troublesome to me. But I can't find the right syntax to use. Take for example this...
3
by: Peter Olsen | last post by:
I want to define a class "point" as a subclass of complex. When I create an instance sample = point(<arglist>) I want "sample" to "be" a complex number, but with its real and imaginary...
11
by: Brent | last post by:
I'd like to subclass the built-in str type. For example: -- class MyString(str): def __init__(self, txt, data): super(MyString,self).__init__(txt) self.data = data
3
by: alotcode | last post by:
Hello: What is 'interprocess subclassing'? To give more context, I am writing in reference to the following remark: With the advent of the Microsoft Win32 API, interprocess subclassing was...
16
by: manatlan | last post by:
I've got an instance of a class, ex : b=gtk.Button() I'd like to add methods and attributes to my instance "b". I know it's possible by hacking "b" with setattr() methods. But i'd like to do...
5
by: Ray | last post by:
Hi all, I am thinking of subclassing the standard string class so I can do something like: mystring str; .... str.toLower (); A quick search on this newsgroup has found messages by others
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.