我有一个基于Dialog的MFC应用程序.我使用它从资源创建了一个GDI +对象.
MyDlg.cpp:
BOOL CSetupDlg::OnInitDialog()
{
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);
...
}
Run Code Online (Sandbox Code Playgroud)
void MyFunction():
CGdiPlusBitmapResource* pBitmap = new CGdiPlusBitmapResource;
if (pBitmap->Load(ID_SPL_LG))
{
CPaintDC dc(this);
Gdiplus::Graphics graphics(dc);
graphics.DrawImage(*pBitmap, 0, 0);
//It is loaded . I checked with messagebox and its in here.
}
Invalidate(); //Not sure if necessary.
Run Code Online (Sandbox Code Playgroud)
现在,Form/Dialog什么都没显示.没有图像插入或附加.
现在,我尝试了一些事情来将这个图像添加到对话框中,但我无法做到.
我尝试的是GDIObject.Create()
,CStatic.Create()
和PictureControl.Create()
我想要做的就是将此图像插入对话框.
任何想法或显示路径表示赞赏.
您需要覆盖在对话框OnPaint
中响应WM_PAINT
消息的方法.通常你不需要这样做,因为对话框不需要绘制任何东西,它只是让它包含的控件自己绘制.
将显示的代码移动到OnPaint处理程序中.
难道不是从自己的处理程序调用默认的OnPaint.
难道不叫Invalidate
从OnPaint处理中,否则你会得到一个无限循环.
归档时间: |
|
查看次数: |
3932 次 |
最近记录: |