I have a MFC Application with Dialog Based. I created a GDI+ Object from resource by using this.
MyDlg.cpp:
BOOL CSetupDlg::OnInitDialog()
{
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);
...
}
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.
Now, Form/Dialog shows nothing. No image inserted nor attached.
Now, i tried few things to add this image to the dialog but i am unable to do it.
What i tried is GDIObject.Create(), CStatic.Create() and PictureControl.Create()
All i want to do is insert this image to the dialog.
Any idea or showing path is appreciated.
You will need to override the
OnPaintmethod that responds to theWM_PAINTmessage in your dialog. Normally you don’t need to do this because the dialog doesn’t need to paint anything, it just lets the controls that are contained on it paint themselves.Move the code you show into the OnPaint handler.
Do not call the default OnPaint from your own handler.
Do not call
Invalidatefrom within the OnPaint handler or you will get an infinite loop.