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

Categories

0 votes
235 views
in Technique[技术] by (71.8m points)

Visual Studio C++ how to display a dynamic message (i.e., string) in my About box?

Should be trivial . . . when editing via the VS resource editor.... the tools/objects list only shows 'static text' and the create an event handler wizard has all fields and [next] button dimmed (disabled).

I have a lovely About box -- it all works -- but instead of static text fields to display --

I want/need to display several lines (strings) of current runtime status info.....

I just do know Visual Studio well enough (I'm using 2008). . .

If any one has a simple example -- that really is all I need.

Thanks in advance.

best regards, Kevin Waite

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

If you put a static text box in your dialog you can set its text to anything you want at runtime. First you need to get the window handle of the text box:

HWND hwndText = GetDlgItem(hwndDialog, IDC_MYTEXT);

Then you can set the new text into it:

SetWindowText(hwndText, L"Hi mom, this is my first text box!");

Static text isn't meant to change, so Windows doesn't always do the right thing when you change it. You need to tell it to erase and repaint so that the new text is properly displayed.

InvalidateRect(hwndText, NULL, true);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...