gpt4 book ai didi

c++ - 我想在基于 MFC 对话框的对话框中显示一些内容,但它在我的主对话框中没有显示任何内容!

转载 作者:行者123 更新时间:2023-11-28 03:48:28 26 4
gpt4 key购买 nike

这是我在对话框中显示内容的代码,我将它们放在 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 ) ;

最佳答案

将 ON_WM_PAINT() 添加到您的消息映射。

关于c++ - 我想在基于 MFC 对话框的对话框中显示一些内容,但它在我的主对话框中没有显示任何内容!,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6607726/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com