I want to display something in a dialog in MFC Dialog-Based but it doesnt display anything in my main dialog !
this is my code to display something in dialog, I put these in OnPaint() but when I build it there is nothing in my main dialog. I really appreciate it If anyone can tell me the code mistake.
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 ( R开发者_运维问答GB( 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 ) ;
Add ON_WM_PAINT() to your message map.
精彩评论