How can I change text on a win32 window?(如何更改 win32 窗口上的文本?)
问题描述
寻找从 C# 更改 win32 窗口上的文本的提示、技巧和搜索词.
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?
这里有一个类似的问题,但它指向的 CodeProject 文章比需要的要复杂得多,而且我花费的时间比我想花的时间要长一些.TIA.
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.
推荐答案
您应该使用 Spy++ 来查看对话框.类名和按钮的控件 ID 很重要.如果它是本机 Windows 对话框,则类名应为#32770".在这种情况下,您将在 this线程.这是C#中的另一个.您可以通过 P/Invoking 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.
用法:
这篇关于如何更改 win32 窗口上的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!