windowsdelphiwinapimessagewordpad

Controlling Wordpad in Windows using messages


I am trying to find a reliable way to control windows Wordpad, which I successfully embedded in application as a child window.

One command I would like to execute just after document was opened is "print preview". PostMessage seems to be a good tool to do it, yet I am struggling to find a reference of commands accepted by Wordpad without success, not to mention commands which will work on WindowsXP machines as well as Windows Vista, 7 and 8.

The list of commands I am particularly interested in is:

Can somebody share some hints about controlling Wordpad using messages, or possibly in a different way?


Solution

  • Post a WM_COMMAND message for the respective command of WordPad's menu (send it if you have to wait for the command to finish its job). For print preview:

    PostMessage(WPad, WM_COMMAND, 57609, 0);
    

    To find out the identifiers, open the application in a resource explorer and search for your items in menu resources. The above works in 2K and W7, so I guess command ID's are not changing frequently.


    Since there's no command for 'close without saving' your best bet may be to find a handle of the rich edit control of the application and send an EM_SETMODIFY before attempting to close.