Page 3 of 3 FirstFirst 123
Results 81 to 105 of 105

Thread: Subclass External Programs done for you

  1. #81
    Fanatic Member MikkyThomeon's Avatar
    Join Date
    Oct 02
    Location
    At work...
    Posts
    648

    Re: Subclass External Programs done for you

    The demo works, but...

    How do I adapt this to only catch messages sent from the form in the external app? I have tried (somewhat wishfully) passing the forms hwnd in instead of using findwindowex to no avail....

  2. #82
    Junior Member
    Join Date
    Dec 06
    Posts
    28

    Question Subclass External Programs done for you

    Hi..
    This is a great code. The DLL works good. But it cant get the web applications. Is it possible to get data in web application using this DLL?
    SG

  3. #83
    New Member
    Join Date
    Apr 07
    Posts
    2

    Re: Subclass External Programs done for you

    Hi,

    Very great work! Thanks.

    Quote Originally Posted by moeur
    Although the title of this thread mentions "subclassing" it deals with hooking and not subclassing.
    If you could actually subclass the external app, then you should be able to block the WM_DESTROY messages.

    There is a way to truly subclass an external app. What you need to do is execute the code that initiates the subclassing from within the external process. A simple way to do this would be to first set a hook in the external process, then when the hook procedure is called, it will be running in the external process so you can then subclass the window you want to prevent from closing.
    I think that might be why i cannot do what I'm trying to do: I installed a hook and can deal with the message when it occurs. Using CopyMemory I can receive data sent along, but I'd like to *modify* those date, so I need to use CopyMemory again with my modified values.
    It "looks like" it to work, as in no crash or anything, but the external app actualy behaves as if I didnot send back any new values

    Could this be the reason why, and if so could anyone help me with how to "subclass" an external app then (would another DLL be required instead of this one??), or am I missing something here/should it work fine with such hooks ?

    Thanks for your help!

  4. #84
    Old Member moeur's Avatar
    Join Date
    Nov 04
    Location
    Wait'n for Free Stuff
    Posts
    2,712

  5. #85
    New Member
    Join Date
    Apr 07
    Posts
    2

    Re: Subclass External Programs done for you

    Thanks!

    I've done some more reading & testing, but I'm getting more confused than anything else.
    Here's what I'm trying to do: add a menuitem to the menu of another app, eg. notepad, but with "complete control" over it.

    Adding the menu and getting it just a few API calls, no problem. But I set it ownerdrawn, because I want to actually draw it myself. And my problem is when dealing with the WM_MEASUREITEM, etc messages. I did it on my VB app and it that went well.

    So I tried using your great DLL to set up a hook to get the notepad's messages. I did got the message, but as I mentionned in my previous post setting my data on WM_MEASUREITEM seems to be ignored by notepad :S

    So I tried a few different ways, like instead of a CopyMemory I used a OpenProcess/VirtualAllocEx/WriteProcessMemory, because I thought that might have been the problem.
    Seems not. I got the same results. But it seems that the data are written (according to lpNumOfBytesWritten for WriteProcessMemory), actually both times: even with a single CopyMemory, I think, because if afterwards I do another CopyMemory to get back the data (like the first time, when I got the menuitem's index, etc) the new width/height I set are returned.

    I not an expert of all this, but I tried reading different posts/articles/etc but I have no idea what's happening here. To me it looks like the data are written, yet ignored by notepad??


    Even more confusing (to me), I did on WM_DRAWITEM draw my menuitem all red, to see if I could actually draw on notepad or not.
    And I can, but I'm not drawing where I should be (on menubar) but below it, within the edit area!! The horizontal position is right though, and the vertical space makes me say it looks like the problem is that I'm not draing on notepad's non-client area!! Like I got the "wrong" hDc or something...
    Again, I'm not even sure what I just said make sense, but that's all I can see.

    Does anyone ever done something like this? Or has an idea of what's the problem/how to fix this?

    Thanks.

  6. #86
    New Member
    Join Date
    Nov 07
    Posts
    1

    Re: Subclass External Programs done for you

    How would I use this to hook all requests to shell32.dll's SHBrowseForFolder API so that the BrowseForFolder window displays shortcuts to folders (or even all files)?

  7. #87
    Lively Member
    Join Date
    May 04
    Location
    Home
    Posts
    97

    Re: Subclass External Programs done for you

    Does your DLL support WH_CBT?

  8. #88
    New Member
    Join Date
    Mar 08
    Posts
    8

    Question Re: Subclass External Programs done for you

    You may be tired of questions about your post “Subclass External Programs done for you” from Jan 2005. I see that your last post to this thread was just days away from being one year ago. This is probably the best example I have ever seen on line, and is probably the closest to answering my quest. I am desperately seeking a way to read a popup menu (class name "#32768). I can get the handle, I can manipulate it (activate, scroll, select) without a problem. The problem is, I am blind to the text in this type of menu and what I am selecting. I have a post “Read from Popup Menu” looking for something like your dll, ocx. Is it capable of reading this type of menu and or which selection is highlighted? I would be extremely grateful for any help! I have been seeking a solution everywhere and it appears you are my best hope in weeks. I consider myself a reasonably good VB coder but subclassing I just can’t seem to get down.
    Last edited by SDG101; Mar 6th, 2008 at 10:14 PM.

  9. #89
    PowerPoster Fazi's Avatar
    Join Date
    Aug 05
    Location
    Underworld
    Posts
    2,525

    Re: Subclass External Programs done for you

    Hai,,

    hook and unhook when mouse move over the windows
    i am getting an error (some time).

    Runtime Error "5"
    Error Setting Dll Filter. 5 (5&h): Access Denied.

    Whats wrong ?

    part of my code
    Code:
        'monitor the following message(s)
        .AddMessage WM_LBUTTONDOWN, "WM_LBUTTONDOWN"
        .AddMessage WM_MOUSEMOVE, "WM_MOUSEMOVE"
    Code:
      If uMsg = WM_LBUTTONDOWN Or uMsg = WM_MOUSEMOVE Then
         uMsg = WM_NULL
      End If
    Some time when the mouse move form one window to another, this error happens.
    but not all the time .
    Last edited by Fazi; Oct 1st, 2008 at 02:18 AM.

  10. #90
    New Member
    Join Date
    Apr 08
    Posts
    6

    Re: Subclass External Programs done for you

    Hello,
    First of all, thanks for the great dll.
    However, I'm trying to make it run on a Windows Mobile device, with the compact framework 3.5...with no success.. I've managed to modify the VB part but with my limited knowledge in C I was unsuccessful in recompiling the dll for the compact framework. I know that the functions SendMessage and SetWindowsHookEx exist in the CF (even if not documented), so it should be possible to make the project run in CF.
    Can someone with VC knowledge help me recompile the dll for the Compact Framework 3.5, please.

  11. #91
    New Member
    Join Date
    Feb 09
    Posts
    1

    Re: Subclass External Programs done for you

    How can I hook into a program's file output. Basically I want to intercept what a program is outputing to a file and modify it before it gets there.

    Thanks

  12. #92
    Fanatic Member ididntdoit's Avatar
    Join Date
    Apr 06
    Location
    :uoıʇɐɔoן
    Posts
    765

    Talking Re: Subclass External Programs done for you

    I just HAD to post to say - AWESOME CODING!!! THANKS MAN!!

    *rates*
    Visit here to learn to make the VB interface fit you!.
    "I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison
    "The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners" -- Ernst Jan Plugge

  13. #93
    New Member
    Join Date
    Mar 09
    Posts
    3

    Re: Subclass External Programs done for you

    I actually have another dll which doesn't have any bugs, as there are some bugs in the dll that u have used. But I don't have the code for that dll. I have tried a thousand time to search the code of that dll in the internet but have failed. And also that dll let me capture all kind of messages from the notepad window
    Last edited by Chanakya69; Mar 8th, 2009 at 08:53 AM.

  14. #94
    Frenzied Member
    Join Date
    Mar 09
    Posts
    1,182

    Re: Subclass External Programs done for you

    Good Day Mr. Moeur,

    I am wondering if it is possible to use your dll, or some version of it, to capture the WM_CREATE message and alter the CREATESTRUCT UDT so that the lpCreateParams would contain a pointer to the MDICREATESTRUCT UDT to make an external program an actual child of a VB MDI application.
    Option Explicit should not be an Option!

  15. #95
    New Member
    Join Date
    Mar 10
    Posts
    1

    Re: Subclass External Programs done for you

    Hello Moeur,
    when you say: To Get the string value pointed to by lParam you can use a function like this: Public Function StrFromPtr(pStr As Long) As String ...
    Where can I do the call to this funcion? In the Form or the module...

    Thanks

  16. #96
    Hyperactive Member TTn's Avatar
    Join Date
    Jul 04
    Posts
    464

    Re: Subclass External Programs done for you

    In the hook Demo 2 posted(post 2) here, I'm getting a crash when mousing down over the notepads scrollbar.
    http://www.vbforums.com/showpost.php...48&postcount=2

    To reproduce:
    Add some carriage returns, so that the scrollbar is visible.
    Press L Button down to scroll on the scrollbar.

    Am I using it wrong, or should that be filtered?

  17. #97
    Addicted Member cc2^^'s Avatar
    Join Date
    Apr 08
    Location
    Right behind you.
    Posts
    165

    Re: Subclass External Programs done for you

    What's the childclassname? And why should it be "Edit" when i hook notepad?
    I need to know because when i hook another application with a different Parentcaption i get an error saying i must set handle before setting hook.
    I think I am, therefore, I am. I think.

  18. #98
    Addicted Member cc2^^'s Avatar
    Join Date
    Apr 08
    Location
    Right behind you.
    Posts
    165

    Re: Subclass External Programs done for you

    Anyone?
    I think I am, therefore, I am. I think.

  19. #99
    New Member
    Join Date
    Jun 12
    Posts
    1

    Re: Subclass External Programs done for you

    I've a new labtop working with windows 7.
    The file hookcontrol.ocx seems to be not compatible with version x86 (32bits) or X86(64bits) of regsvr32.exe.
    Is it possible to have an updated version of this ocx file or a way to compile myself on my labtop.
    Thanks in advance

  20. #100
    Addicted Member
    Join Date
    Aug 10
    Posts
    149

    Re: Subclass External Programs done for you

    Try pressing the Windows key+R, then copy and paste:

    Code:
    c:\windows\syswow64\regsvr32.exe hookcontrol.ocx
    If this doesn't work, what error message are you getting?

  21. #101
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 08
    Location
    *****
    Posts
    963

    Re: Subclass External Programs done for you

    @moeur
    i need to fill fields of an embedded webbrowser in another app from my app, how can i acheive this with your dll?
    thanks
    Programming is all about good logic. Spend more time here


    (vHost for Apache) (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

  22. #102
    New Member
    Join Date
    Oct 12
    Posts
    7

    Re: Subclass External Programs done for you

    Hi moeur, excellent work.

    I tried the .NET version you posted, in VB and C#, but in both cases the events don't fire from the hook. All appears to set up ok, window handle obtained, messages added, etc. An instance of EditHook (clsHook) exists and is visible in watch window. Any ideas if I have missed something? Thanks.

  23. #103
    New Member
    Join Date
    Oct 12
    Posts
    7

    Re: Subclass External Programs done for you

    ADDENDUM it works on a Win32-only machine, but not on a Win64 machine when targeted to x86. IDEAS?

    I tried the .NET version you posted, in VB and C#, but in both cases the events don't fire from the hook. All appears to set up ok, window handle obtained, messages added, etc. An instance of EditHook (clsHook) exists and is visible in watch window. Any ideas if I have missed something? Thanks.[/QUOTE]

  24. #104
    Web developer Nightwalker83's Avatar
    Join Date
    Dec 01
    Location
    Adelaide, Australia
    Posts
    9,834

    Re: Subclass External Programs done for you

    Quote Originally Posted by K-C-S View Post
    Hi moeur, excellent work.

    I tried the .NET version you posted, in VB and C#, but in both cases the events don't fire from the hook. All appears to set up ok, window handle obtained, messages added, etc. An instance of EditHook (clsHook) exists and is visible in watch window. Any ideas if I have missed something? Thanks.
    Try using the "Run As Administrator" option when running the program. You might need to do that on both the test program and the actual hook program to get it to work correctly.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    Please consider giving me some rep points if I help you a lot.
    DON'T BUMP YOUR POSTS!!! Links to my code examples can now be found on my website: My websites
    Please rate my post if you find it helpful!
    Technology is a dangerous thing in the hands of an idiot! I am that idiot.

  25. #105
    New Member
    Join Date
    Oct 12
    Posts
    7

    Re: Subclass External Programs done for you

    Quote Originally Posted by Nightwalker83 View Post
    Try using the "Run As Administrator" option when running the program. You might need to do that on both the test program and the actual hook program to get it to work correctly.
    No, I was running in VS2010 in admin mode anyway. It DOES work on a Win32 machine, but not a Win64 machine (targeted to either x86 or 64bit). I think I read somewhere the unmanaged DLL has to be changed with regard to DWORDs. Shame, I guess I will have to keep looking....

Page 3 of 3 FirstFirst 123

Posting Permissions

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