How to place an image using the SDI application when the dialog box appears for the first time?


I am developing MFC based SDI application using CFormView class in VC++. My problem is that I need to load image when the dialog initially appears. How to place image in an SDI application..I know for dialog based applications it can be done using OnInitDialog application.But for SDI application there is no such function. I tried placing the image using OnInitialUpdate() and OnPaint() function. But it failed..What should I do to place the image to dialog when it first appears? Please Help

Thanks in advance

Code as I placed in OnInitialUpdate()

void CECUSimulatorView::OnInitialUpdate()
hBitmap = LoadImage(0,_T("F:/ECUSimulator/ECUSimulator_New/res/LedOff.bmp"),               IMAGE_BITMAP,0,0,LR_LOADFROMFILE);

Code for the function ImageLoading()

void CECUSimulatorView::OnInitialUpdate()
HDC hDC, hDCToDisplay = NULL;
hDC = CreateCompatibleDC(hDCToDisplay);
hDCToDisplay = ::GetDC(m_picture.m_hWnd);
BitBlt(hDCToDisplay,0 , 0, (picRect.right - picRect.left), (picRect.bottom, hDC, 0 ,0 ,SRCCOPY);


HANDLE hBitmap; CStatic m_picture; //Picture Control CRect picRect; //Picture Control Rect

I removed the code from OnInitialUpdate() and placed it in OnPaint() function as follows:

void CECUSimulatorView::OnPaint() { CPaintDC dc(this); // device context for painting

hBitmap = LoadImage(0,_T("F:/ECUSimulator/ECUSimulator_New/res/LedOff.bmp"), IMAGE_BITMAP,0,0,LR_LOADFROMFILE);


Calling LoadImage() in OnInitialUpdate() is ok, the actual painting needs to be done in one of the two following ways:

a) in CECUSimulatorView::OnDraw() -- easier, but may introduce flickering

b) override the OnPaint() function of the m_picture control using ClassWizard and draw the picture there