如何更改 win32 窗口上的文本?
寻找从 C# 更改 win32 窗口上文本的提示、技巧和搜索词。
更具体地说,我试图将打印对话框上的文本从“打印”更改为“确定”,因为我正在使用该对话框创建打印票证而不进行任何打印。
如何找到对话框的窗口句柄?一旦我得到了它,我将如何在表单的子窗口中找到该按钮?一旦我发现了这一点,我将如何更改按钮上的文本?在显示对话框之前我怎样才能完成所有这些?
这里有一个类似的问题,但它指向一篇 CodeProject 文章,该文章比需要的更复杂,并且花费我更长的时间来解析,而不是我愿意花在这上面的时间。 TIA。
Looking for hints, tips and search terms for changing the text on a win32 window from C#.
More specifically, I'm trying to change the text on the print dialog from "Print" to "OK", as I am using the dialog to create a print ticket and not do any printing.
How can I find the dialog's window handle? Once I've got it, how would I go about finding the button in the child windows of the form? Once I've found that, how would I change the text on the button? And how can I do all this before the dialog is shown?
There's a similar question here, but it points to a CodeProject article that is waaay more complex than needed and is taking me a bit longer to parse through than I'd like to spend on this. TIA.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该使用 Spy++ 查看该对话框。类名和按钮的控件 ID 都很重要。如果它是本机 Windows 对话框,则类名称应为“#32770”。在这种情况下,您将在 这个帖子中得到很多用处线程。这是另一个 C# 。您可以通过在按钮手柄上调用 SetWindowText() 来更改按钮文本。
用法:
You should use Spy++ to take a look at the dialog. The class name is important and the control ID of the button. If it is a native Windows dialog then the class name should be "#32770". In which case you'll have a lot of use for my post in this thread. Here is another in C#. You change the button text by P/Invoking SetWindowText() on the button handle.
Usage: