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:

  • Print
  • Print Preview
  • Close without saving (in a more elegant manner than killing the process)

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


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.

Need Your Help

Excel INDEX MATCH when value may be in one of 3 columns

excel match

I am using INDEX/MATCH to find values in a single column and return the value from a different column using:

Is it possible to selectively build WinCE directories in parallel

windows-ce platform-builder

I was wondering if it is possible to build (via blddemo) some of the directories (i.e. their trees) in parallel while others not.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.