473,394 Members | 1,738 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,394 software developers and data experts.

Subclassing problem... CROSS

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 ANY window in VB?

Thanks...

Jul 17 '05 #1
6 2711
On Sat, 23 Aug 2003 22:16:30 +0200, WhiteRavenEye
<wh***********@hotmail.com> wrote:
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 ANY window in VB?

SetWindowsHookEx, but you'll have to have it in a real DLL.

--

Regards, Frank
Jul 17 '05 #2
fa**@xxxxoptushome.com.au (Frank Adam) wrote in message news:<3f****************@news-vip.optusnet.com.au>...
On Sat, 23 Aug 2003 22:16:30 +0200, WhiteRavenEye
<wh***********@hotmail.com> wrote:
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 ANY window in VB?

SetWindowsHookEx, but you'll have to have it in a real DLL.


That is not subclassing, that is window hooking (which has similar
effects, but essentially copies the window message, unlike subclassing
where it's your job to forward the message back to the original
procedure).

So why doesn't it work with SetWindowLong? Form MSDN: "GWL_WNDPROC:
[...] You cannot change this attribute if the window does not belong
to the same process as the calling thread."
So you cannot subclass windows of other processes.
Seems like window hooking may be your only way to go.

Robert
Jul 17 '05 #3
Asperamanca wrote:
fa**@xxxxoptushome.com.au (Frank Adam) wrote in message news:<3f****************@news-vip.optusnet.com.au>...
On Sat, 23 Aug 2003 22:16:30 +0200, WhiteRavenEye
<wh***********@hotmail.com> wrote:

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 ANY window in VB?


SetWindowsHookEx, but you'll have to have it in a real DLL.

That is not subclassing, that is window hooking (which has similar
effects, but essentially copies the window message, unlike subclassing
where it's your job to forward the message back to the original
procedure).

So why doesn't it work with SetWindowLong? Form MSDN: "GWL_WNDPROC:
[...] You cannot change this attribute if the window does not belong
to the same process as the calling thread."
So you cannot subclass windows of other processes.
Seems like window hooking may be your only way to go.

Robert


I must have missed that part of MSDN...
Looks like I'll have to write dll in Delphi...
Too bad it can't be written in VB... Damn ActiveX DLL...
Anyway thanks...

By WhiteRavenEye

Jul 17 '05 #4
On Mon, 25 Aug 2003 12:00:12 +0200, WhiteRavenEye
<wh***********@hotmail.com> wrote:
<snip>

I must have missed that part of MSDN...
Looks like I'll have to write dll in Delphi...
Too bad it can't be written in VB... Damn ActiveX DLL...
Anyway thanks...


I may be wrong, but I believe that the SetWindowsHookEx is mainly
about 'snooping' - not really subclassing

<snip>
Chaining to the next hook procedure (that is, calling the
CallNextHookEx function) is optional. An application or library can
call the next hook procedure either before or after any processing in
its own hook procedure. Although chaining to the next hook is
optional, it is highly recommended; otherwise, the other applications
that have installed hooks will not receive hook notifications and may
behave incorrectly as a result
</snip>

However the Help Files are a bit unclear on all this
Jul 17 '05 #5
On 25 Aug 2003 00:20:31 -0700, as*********@yahoo.com (Asperamanca)
wrote:
fa**@xxxxoptushome.com.au (Frank Adam) wrote in message news:<3f****************@news-vip.optusnet.com.au>...
On Sat, 23 Aug 2003 22:16:30 +0200, WhiteRavenEye
<wh***********@hotmail.com> wrote:
>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 ANY window in VB?
> SetWindowsHookEx, but you'll have to have it in a real DLL.


That is not subclassing, that is window hooking (which has similar
effects, but essentially copies the window message, unlike subclassing
where it's your job to forward the message back to the original
procedure).

So CallNextHookEx is just for kicks ?
SetwindowsHook installs a hook at the start of the chain, a subclass
replaces the procedure's address with an address of it's own handler.
IOW, it chains 'in', instead of in front. The difference is minimal up
to that point.
When it comes to handling and changing the messages it gets a litlle
trickier using the hook.. Blocking is easy enough.
So you cannot subclass windows of other processes.
Seems like window hooking may be your only way to go.

Hm.. if only i would have thought of that.. ;-p

--

Regards, Frank
Jul 17 '05 #6
> SetwindowsHook installs a hook at the start of the chain, a subclass
replaces the procedure's address with an address of it's own handler.
IOW, it chains 'in', instead of in front. The difference is minimal up
to that point.
When it comes to handling and changing the messages it gets a litlle
trickier using the hook.. Blocking is easy enough.


There are some serious differences in performance and stability.
Subclassing is somewhat faster than hooking (in my experience), and
some types of hooks are explicitly labeled "for debugging purposes
only" (but not the kind we're talking about). On the other hand, there
are things you can do with a hook that you cannot do with subclassing
(as we found out), also things like monitoring all keyboard / mouse
events.

Robert
Jul 17 '05 #7

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

Similar topics

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...
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
4
by: pietlinden | last post by:
Hi, I have the sort of standard Donors/Donations DB. The twist I have is that donations can be time, money (which are easy, because they're additive), but then a donor can make an in-kind pledge,...
11
by: Kevin Prichard | last post by:
Hi all, I've recently been following the object-oriented techiques discussed here and have been testing them for use in a web application. There is problem that I'd like to discuss with you...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.