求助!exe程序弹出一个对话框,怎么在里面显示文字?
我做了一个exe程序,想程序运行的时候弹出一个对话框,然后在里面显示一些文字,该怎么做?
我是照着http://hi.baidu.com/onejw/blog/item/e7b1a423264c0545ad34de9e.html这个里面写的做的。对话框可以弹出来了,但是怎么显示文字啊。他上面写的:
不过要显示文字就要先设定字体,具体操作如下:
先要建立一个CWsScreenDevice:
iScreen = new (ELeave) CWsScreenDevice(iWs);然后可以用GetNearestFontInTwips通过字体名字获得CFont:_LIT(FONT_CH16, "CombinedChinesePlain16");
TFontSpec myFontSpec(FONT_CH16, 200);
iScreen->GetNearestFontInTwips(iFont, myFontSpec);
这些东西是要加在哪里的?我添加到了void CWindow::Draw(const TRect& aRect)这个里面,但是运行到iScreen->GetNearestFontInTwips(iFont, myFontSpec);就报错,该怎么办?
这个是我加的
void CWindow::Draw(const TRect& aRect)
{
// Drawing to a window is done using functions supplied by
// the graphics context (CWindowGC), not the window.
CWindowGc* gc = SystemGc(); // get a gc
gc->SetClippingRect(aRect); // clip outside this rect
gc->Clear(aRect); // clear
TSize size=iWindow.Size();
TInt width=size.iWidth;
TInt height=size.iHeight;
// Draw a square border
gc->DrawLine(TPoint(0,0),TPoint(0,height-1));
gc->DrawLine (TPoint (0, height-1), TPoint (width-1, height-1));
gc->DrawLine(TPoint(width-1,height-1),TPoint(width-1,0));
gc->DrawLine (TPoint (width-1, 0), TPoint (0, 0));
//写字
_LIT(FONT_CH16, "Swiss");
TFontSpec myFontSpec(_L("Times New Roman"),200);
CWsScreenDevice *iScreen = new(ELeave)CWsScreenDevice(iClient->iWs);
iScreen->GetNearestFontInTwips(iFont, myFontSpec);
gc->UseFont(iFont);
gc->DrawText(_L("P"),TPoint(45,100));
}