tags:

views:

56

answers:

1

Ok, If I cannot write on a dialog during oninit by:


You can't use the function SSTextOut() in OnInitDialog(). OnInitDialog() is called before your dialog is displayed, so you can't get a valid CDC inside of it (because the dialog hasn't been drawn yet).

From the looks of it, SSTextOut() is meant to be called from an OnPaint() override.


Is there any way I can write some text to the 1st dialog screen at startup. I want to put some info on the dialog screen under program control rather then by static text!

A: 

I'm not sure what SSTextOut is, but during OnInitDialog, the dialog does have a valid DC. It hasn't been displayed yet, but it does exist, and so do all the controls in the dialog, so putting text into a control (e.g. an Edit control) is perfectly valid, and when the user sees the dialog, the text will be there as soon as the user sees the dialog.

Jerry Coffin
SSTextOut does not work as you need pDC->SSTextOut which I could not get. BUT, I put up an Edit Box and used the following code to write into it: CEdit *Display; Display = reinterpret_cast<CEdit *>(GetDlgItem(IDC_LC_EDITBX)); Display->SetWindowText("Word Processing"); UpdateData(FALSE); Now I need to make the edit box so you can't see it so all you see is the text I put up! Thanks
You can just use `pDC->TextOut(x, y, "Your Text");`. Alternatively, you can set the edit control to have no border (or use a static control, but set its ID to something other than IDC_STATIC, and write to it the same way -- that keeps the user from editing it (even by accident). You don't really need the `reinterpret_cast` and `GetDlgItem` either -- it's much easier to associate a CEdit member variable with the item ahead of time.
Jerry Coffin