Link to home
Start Free TrialLog in
Avatar of sunshine737
sunshine737

asked on

How can i display multiple bitmaps one after the other on Modal dialog.

Hi,

I asked this question before only. I think that was not clear.
I am displaying BMP image on Modal dialog box by using Dierct Draw. I would like to show multiple BMP images on the same area, when mouse events occures(Ex. in OnLButtonDown()). Now i am able to display another BMP image when mouse event fired. But the problem is , Next BMP image is diaplying on before one. I think it is not repianting the window, when event occures. Please help me to solve this problem.

Thanks

Vihar
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Assuming you have an OnPaint routine that takes an ID/path to the bitmap.
eg.

CMyDlg::OnPaint
{
DrawBMP(m_szPATH);  //draw bitmap from path - a function you have coded
}

When you get the mouse event
eg.
CMyDlg::OnMouseEvent
{
m_szPATH = "INSERT PATH TO NEXT BMP";
Invalidate(); //flag dlg for redrawing
UpdateWindow(); //force a repaint
}
Avatar of sunshine737
sunshine737

ASKER

Thank you for your reply. I tried with above functions. But still that problem is not solved. Please see my code once.
BOOL CDialogSampleDlg::OnInitDialog()
{
 -----------
 hwnd = ((CStatic*) this->GetDlgItem(IDC_STATIC))->m_hWnd;
 dd_obj.Init(hwnd); // Set up our DirectDraw interface AND save off a compatible HDC AND load our clipper
 dd_obj.InitSurfaces(hwnd); // This will init our primary and back surfaces
 dd_obj.LoadBackSurface(AfxGetInstanceHandle(),"ball.bmp",hwnd); // This will load the backSurface with our bitmap
 return TRUE;  
}

void CDialogSampleDlg::OnPaint()
{
 if()
  --
 else
  {
    dd_obj.Draw(hwnd);// This draws the backSurface to the primarySurface
    CDialog::OnPaint();
  }
}
void CDialogSampleDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
   dd_obj.LoadBackSurface(AfxGetInstanceHandle(),"dog.bmp",hwnd);
   dd_obj.Draw(hwnd);
   CDialog::OnLButtonDown(nFlags, point);
}


regards
Vihar
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Excerpt from help
CWnd::GetDlgItem  
CWnd* GetDlgItem( int nID ) const;

void CWnd::GetDlgItem( int nID, HWND* phWnd ) const;

Return Value

A pointer to the given control or child window. If no control with the integer ID given by the nID parameter exists, the value is NULL.

The returned pointer may be temporary and should not be stored for later use.     ***************************


You MUST NOT store the returned hwnd in the OnInitDialog.  You need to use that code to get it each time you intend to use it.