开发者

What can you do in ::OnInitDialog() Visual Studio 2008 C++

开发者 https://www.devze.com 2022-12-24 06:58 出处:网络
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 Iput the same code in a PUSH-BUTTON OnBnClicked it work

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号