What can you do in ::OnInitDialog() Visual Studio 2008 C++
What can or cannot you do in ::OnInitDialog() Visual Studio 2008 C++
I would like to write out some text on the dialog at the dialog startup. If I put the same code in a PUSH-BUTTON OnBnClicked it works. If I put it in the OnInit, it does not give me the text on the screen. I'm assuming at the OnInit, my dialog box is not completely up, so I cannot write on it?
CRect drawRect;
drawRect.left = 00; // Shifts text to right
drawRect.right = 300;
drawRect.top = 00; // How Far Down
drawRect.bottom = 300;
// Clear out any prev开发者_运维技巧ious name
CString strBlank = "Book Name";
SSTextOut(this->GetDC(), strBlank, &drawRect, DT_LEFT);
The function I am writing to is described in http://www.codeproject.com/KB/GDI/SSTextOut.aspx
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.
精彩评论