CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Subclassing another thread's windows

    Hi,

    When I try to use SetWindowLong to subclass another thread's window it fails, but it works if the window is in the same thread as the call to SetWindowLong.

    The MSDN documentation does not mention that limitation, and I have seen programs that seem to subclass other programs so there must be a way.

    Any ideas?
    Thanks in advance,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  2. #2
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,452

    Re: Subclassing another thread's windows

    According to the MSDN

    "Remarks
    The SetWindowLong function fails if the window specified by the hWnd parameter does not belong to the same process as the calling thread."

    I have heard of people "injecting" a DLL into another process, but am unsure how this works. What do you need to do with the subclassing? You can intercept messages (keyboard/mouse input) with setwindowshook.


  3. #3
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: Subclassing another thread's windows

    I am preventing my own windows being resized outside certain restrictions by intercepting the WM_GETMINMAXINFO message, copying my min/max info in and sending it back but now a client wants a similar thing done with an explorer window.

    I tried installing a WH_CALLWNDPROC but that returns The parameter was incorrect if I set the thread to be explorer.

    Ho well, back to the drawing board.
    (Nobody knows about this injecting dlls thing?)

    Thanks,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  4. #4
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,452

    Re: Subclassing another thread's windows

    Ok, you might be able to try using SetWindowsHookEx with the WH_GETMESSAGE parameter to monitor messages sent to the window. If I recall correctly, you will need to place this in a .DLL in order for it to work. I don't have anything for working with windows messages, but here is a link for working with keystrokes. The source for the C++ .DLL is included so you might be able to change the code to fit your purposes. Or try the C++ forum and search the archives. You could probably find something in there.

    Hope this helps.


  5. #5
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,452

    Re: Subclassing another thread's windows

    Can you belive it, some moron forgot the link!

    http://www.vbnotes.com/KeyHook.zip




  6. #6
    Join Date
    Aug 2001
    Posts
    5

    Re: Subclassing another thread's windows

    If you are running under Win 2000, you can't subclass another's application using SetWindowsLong. Win 2000 Prevents it. SetWindowLngPtr(Listed in the MSDN), I think might be able to do it, but I can' find any documentation on it (C++ or VB Api).



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured