这是我在对话框中显示内容的代码,我将它们放在OnPaint()中,但是当我构建它时,我的主对话框中没有任何内容。 我真的很感激如果有人能告诉我代码错误。
CmyDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
dc.MoveTo ( 10, 10 ) ;
dc.LineTo ( 200, 10 ) ;
CPen mypen ( PS_SOLID, 3, RGB( 0, 0, 255)) ;
CPen *oldpen = dc.SelectObject ( &mypen ) ;
dc.Rectangle ( 10, 20, 200, 100 ) ;
dc.SelectObject ( oldpen ) ;
mypen.DeleteObject( ) ;
mypen.CreatePen ( PS_DOT, 1, RGB ( 0, 0, 255));
oldpen = dc.SelectObject ( &mypen ) ;
CBrush mybrush ( RGB( 255,0,0)) ;
CBrush *oldbrush = dc.SelectObject ( &mybrush ) ;
dc.RoundRect ( 10, 120, 200, 220, 20, 20 ) ;
dc.SelectObject ( oldbrush ) ;
dc.SelectObject ( oldpen ) ;
mypen.DeleteObject( ) ;
mypen.CreatePen ( PS_DASH, 1, RGB(0,0,255)) ;
oldpen = dc.SelectObject ( &mypen ) ;
mybrush.DeleteObject( ) ;
mybrush.CreateHatchBrush ( HS_CROSS, RGB ( 255, 0, 255 ) ) ;
oldbrush = dc.SelectObject ( &mybrush ) ;
dc.Ellipse ( 10, 240, 200, 340 ) ;
dc.SelectObject ( oldbrush ) ;
dc.SelectObject ( oldpen ) ;
mypen.DeleteObject( ) ;
mypen.CreatePen ( PS_DOT, 1, RGB (0, 0, 255)) ;
oldpen = dc.SelectObject ( &mypen ) ;
CBitmap mybitmap ;
mybitmap.LoadBitmap ( IDB_BITMAP1 ) ;
mybrush.DeleteObject( ) ;
mybrush.CreatePatternBrush ( &mybitmap ) ;
oldbrush = dc.SelectObject ( &mybrush ) ;
dc.Pie ( 250, 10, 350, 110, 350, 110, 350, 10 ) ;
oldpen = ( CPen* ) dc.SelectStockObject ( WHITE_PEN ) ;
oldbrush = ( CBrush* ) dc.SelectStockObject ( NULL_BRUSH ) ;
POINT pt[5] = { 250, 150, 250, 300, 300, 350, 400, 300, 320, 190 } ;
dc.Polygon ( pt, 5 ) ;
dc.SelectObject ( oldpen ) ;
dc.SelectObject ( oldbrush ) ;
CRect r ;
GetClientRect ( &r ) ;
dc.TextOut ( 100, 200, "Raindrops on roses & whiskers on kittens", strlen ( "Raindrop on roses & whiskers on kittens" ) ) ;
dc.DrawText ( "Of Words'n Figures", -1, &r, DT_SINGLELINE | DT_VCENTER | DT_CENTER ) ;
答案 0 :(得分:2)
将ON_WM_PAINT()添加到您的留言地图。