title: LoadImage() in MFC Dialog loads the previously saved image. but, fails to load newly generated image to display as result?
body: <p>I am working on an  MFC Dialog in VC++. In my code I have to display the processed image on the dialog (I have created a picture control (CStatic variable)). But I am facing following problem: When I press button for display result, it shows the old image instead of showing the newly calculated result image. After pressing one more time, it shows the correct result image.</p>
  
  <p>I also tried with BitBlt, CreateCompatibleDC and all. But, I am facing same problem.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>SaveResultImage("result.bmp");  // This funtion saves the result image
  
  hBitmap = (HBITMAP)LoadImage(NULL, L"result.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);  // It should read currently saved result image
  
  if(hBitmap)
  {
      SendMessage(GetDlgItem(hwndDlg, IDC_PICTURE), STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBitmap);  
  }
  </code></pre>