Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

What Windows API function can I use to get text within a dialog? For example, if I had the handle of an error message dialog, how could I get the displayed error message?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
303 views
Welcome To Ask or Share your Answers For Others

1 Answer

If I correctly understand your question, your problem is very easy. Open Spy++ from the Visual Studio Tools menu. Then press Ctrl + F to receive a dialog for finding windows. Drag & drop the "Finder tool" on the control inside the dialog box from which you want to read the text; look at properties of the window, the field "Control ID" is what you need.

If you have a handle of the Dialog Window (HWND hDlg) you should use the GetDlgItemText function (see http://msdn.microsoft.com/en-us/library/ms645489(VS.85).aspx)

UINT GetDlgItemText(HWND hDlg,
    int nIDDlgItem,
    LPTSTR lpString,
    int nMaxCount
);

to read the text. As a nIDDlgItem parameter you should place the identifier of the control. It is the value which you have found using Spy++.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...