Hook and Subclass Wordpad from C++11 : How to do this?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SwissProgrammer
    New Member
    • Jun 2020
    • 220

    Hook and Subclass Wordpad from C++11 : How to do this?

    I would like to know how to hook and subclass Wordpad (a MS Windows 32 bit common program) with a C++11 program.

    I start my program; and it opens up Wordpad; then my program gets control of Wordpad, it controls the information going into and comming out of Wordpad. I do not quite recall how to do that. It should be really simple. I am having some difficulty with this.

    Help?

    Thank you.
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Erm, what springs to mind is: Why?

    Look, WordPad is basic and I suspect it's writers never intended that it be integrated into or with any other application. That means that you may be able to reverse engineer some control of it by working out what messages to send it but that will be hard and laborious and on top of that you have no guarantee that your reversed engineered interface won't change with each new version of WordPad.

    There are other, probably better, options. For example .NET includes a RichTextBox class that embodies most of the functionality you'd find in WordPad anyway. With that you can just build the editor straight into your own app, assuming you have access to the required .NET version. Even if it is important that the editor is a separate app (for C++11 program is pure C++11?) it may still be worth creating your own editor program as then you have control of the interface between your 2 programs.

    Rather generic advice I'm afraid but without a better idea of what you are trying to achieve it is hard to be more precise.

    Comment

    • dev7060
      Recognized Expert Contributor
      • Mar 2017
      • 656

      #3
      I start my program; and it opens up Wordpad; then my program gets control of Wordpad, it controls the information going into and comming out of Wordpad.
      What kind of control?

      To handle the information flow somewhat maybe
      - I'd look for any helpful switches/options/parameters/flags the program accepts.
      - One could make use of intermediate files to transfer data to/from the program. It'd require a restart to reflect the changes made. Like $ write myfile.txt can be run after the changes have been made to the file (from the code).
      - Functions like SendMessage and SendInput may prove useful.

      If by 'control' you mean something like the code to be able to command WordPad in real-time, I'm not sure if that's even possible.

      Comment

      Working...