使用消息控制 Windows 中的写字板
我正在尝试找到一种可靠的方法来控制Windows写字板,我成功地将其作为子窗口嵌入到应用程序中。
我想在打开文档后立即执行的一个命令是“打印预览”。 PostMessage 似乎是一个很好的工具,但我正在努力寻找写字板接受的命令参考,但没有成功,更不用说在 WindowsXP 计算机以及 Windows Vista、7 和 8 上运行的命令了
。我特别感兴趣的命令是:
- 打印
- 打印预览
- 关闭而不保存(以比终止进程更优雅的方式)
有人可以分享一些关于使用消息或可能以不同方式控制写字板的提示吗?
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 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
发布
WM_COMMAND
写字板菜单的相应命令的消息(如果您必须等待命令完成其工作,请发送该消息)。对于打印预览:要查找标识符,请在资源浏览器中打开应用程序,然后在菜单资源中搜索您的项目。上面的工作在 2K 和 W7 中,所以我猜命令 ID 不会经常改变。
由于没有“关闭而不保存”的命令,您最好的选择可能是找到应用程序的丰富编辑控件的句柄并发送
EM_SETMODIFY
在尝试关闭之前。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: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.