Subclassing problem... CROSS

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • WhiteRavenEye

    #1

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

  • Frank Adam

    #2
    Re: Subclassing problem... CROSS

    On Sat, 23 Aug 2003 22:16:30 +0200, WhiteRavenEye
    <whiteraveneye@ hotmail.com> wrote:
    [color=blue]
    >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?
    >[/color]
    SetWindowsHookE x, but you'll have to have it in a real DLL.

    --

    Regards, Frank

    Comment

    • Asperamanca

      #3
      Re: Subclassing problem... CROSS

      fajp@xxxxoptush ome.com.au (Frank Adam) wrote in message news:<3f47dbca. 101243249@news-vip.optusnet.co m.au>...[color=blue]
      > On Sat, 23 Aug 2003 22:16:30 +0200, WhiteRavenEye
      > <whiteraveneye@ hotmail.com> wrote:
      >[color=green]
      > >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?
      > >[/color]
      > SetWindowsHookE x, but you'll have to have it in a real DLL.[/color]

      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_WNDPRO C:
      [...] 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

      Comment

      • WhiteRavenEye

        #4
        Re: Subclassing problem... CROSS

        Asperamanca wrote:[color=blue]
        > fajp@xxxxoptush ome.com.au (Frank Adam) wrote in message news:<3f47dbca. 101243249@news-vip.optusnet.co m.au>...
        >[color=green]
        >>On Sat, 23 Aug 2003 22:16:30 +0200, WhiteRavenEye
        >><whiteraveney e@hotmail.com> wrote:
        >>
        >>[color=darkred]
        >>>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?
        >>>[/color]
        >>
        >>SetWindowsHoo kEx, but you'll have to have it in a real DLL.[/color]
        >
        >
        > 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_WNDPRO C:
        > [...] 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[/color]

        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

        Comment

        • J French

          #5
          Re: Subclassing problem... CROSS

          On Mon, 25 Aug 2003 12:00:12 +0200, WhiteRavenEye
          <whiteraveneye@ hotmail.com> wrote:
          <snip>[color=blue]
          >
          >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...[/color]

          I may be wrong, but I believe that the SetWindowsHookE x 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

          Comment

          • Frank Adam

            #6
            Re: Subclassing problem... CROSS

            On 25 Aug 2003 00:20:31 -0700, asperamanca@yah oo.com (Asperamanca)
            wrote:
            [color=blue]
            >fajp@xxxxoptus home.com.au (Frank Adam) wrote in message news:<3f47dbca. 101243249@news-vip.optusnet.co m.au>...[color=green]
            >> On Sat, 23 Aug 2003 22:16:30 +0200, WhiteRavenEye
            >> <whiteraveneye@ hotmail.com> wrote:
            >>[color=darkred]
            >> >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?
            >> >[/color]
            >> SetWindowsHookE x, but you'll have to have it in a real DLL.[/color]
            >
            >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).
            >[/color]
            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.
            [color=blue]
            >So you cannot subclass windows of other processes.
            >Seems like window hooking may be your only way to go.
            >[/color]
            Hm.. if only i would have thought of that.. ;-p

            --

            Regards, Frank

            Comment

            • Asperamanca

              #7
              Re: Subclassing problem... CROSS

              > SetwindowsHook installs a hook at the start of the chain, a subclass[color=blue]
              > 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.[/color]

              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

              Comment

              Working...