Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to place image using SDI application when the dialog first appears?
    primarykey
    data
    text
    <p>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</p> <p>Thanks in advance</p> <p>Code as I placed in OnInitialUpdate()</p> <pre><code>void CECUSimulatorView::OnInitialUpdate() { CFormView::OnInitialUpdate(); GetParentFrame()-&gt;RecalcLayout(); ResizeParentToFit(); hBitmap = LoadImage(0,_T("F:/ECUSimulator/ECUSimulator_New/res/LedOff.bmp"), IMAGE_BITMAP,0,0,LR_LOADFROMFILE); ImageLoading(); } </code></pre> <p>Code for the function ImageLoading()</p> <pre><code>void CECUSimulatorView::OnInitialUpdate() { HDC hDC, hDCToDisplay = NULL; hDC = CreateCompatibleDC(hDCToDisplay); SelectObject(hDC,hBitmap); hDCToDisplay = ::GetDC(m_picture.m_hWnd); m_picture.GetWindowRect(&amp;picRect); BitBlt(hDCToDisplay,0 , 0, (picRect.right - picRect.left), (picRect.bottom -picRect.top), hDC, 0 ,0 ,SRCCOPY); DeleteDC(hDC); DeleteDC(hDCToDisplay); } </code></pre> <p>Here </p> <p>HANDLE hBitmap; CStatic m_picture; //Picture Control CRect picRect; //Picture Control Rect</p> <p>I removed the code from OnInitialUpdate() and placed it in OnPaint() function as follows:</p> <p>void CECUSimulatorView::OnPaint() { CPaintDC dc(this); // device context for painting</p> <pre><code>hBitmap = LoadImage(0,_T("F:/ECUSimulator/ECUSimulator_New/res/LedOff.bmp"), IMAGE_BITMAP,0,0,LR_LOADFROMFILE); ImageLoading(); </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload