Tool development question

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
pkeyzers
Posts: 2
Joined: Wed Mar 28, 2012 8:25 am

Tool development question

Post by pkeyzers »

Hi,

I'm currently trying to write a tool in C# to help with some formatting issues that I'd like to programatically solve. Following the XMLTidy route and getting the input text from the clipboard, I'm now struggling to write the output back out to the document window.

I've got the document window handle passed in, and have navigated to what I think is the correct handle to write to. I'm trying to use SendMessage from User32.dll, with a WM_SETTEXT param, but it doesn't seem to be working.

Is anyone able to offer any pointers?

Thanks,

PK.
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Years ago I tried to get a tool to write directly to a TextPad document window, but I failed and gave up.

Instead I use the clipboard.

I either:
 write the output to the clipboard and oblige the user (me) to paste it where required,
or,
 to manipulate and rewrite the current selection:
  1. Fetch the text currently on the clipboard and save it.
  2. Send <Ctrl+C> to TextPad to copy the selection to the clipboard.
  3. Fetch the text on the clipboard.
  4. Manipulate the fetched text.
  5. Copy the manipulated text to the clipboard.
  6. Send <Ctrl+V> to TextPad to copy the clipboard to the selection.
  7. Restore the original contents of the clipboard.

This is not the right way to do this: it's clunky and slow and requires the user not to change focus while the tool is running. But I've not been able to find another.
CarGuy37
Posts: 1
Joined: Mon May 14, 2012 6:54 pm

Post by CarGuy37 »

Has there been any further development or discussion on this?

I cannot for the life of me figure out how to access the text from the $DocWnd handle. I can run the exact same code for Notepad and it works fine. I can even send Notepad a character through a WM_CHAR message but no luck with TextPad (hence I cannot implement the second solution to the above reply).

Any help here would be greatly appreciated.
pkeyzers
Posts: 2
Joined: Wed Mar 28, 2012 8:25 am

Post by pkeyzers »

Is anyone able to offer any tips for doing this the right way?

Thanks,

PK.
Post Reply