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


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.


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AndyAinscowFreelance programmer / ConsultantCommented:
Assuming you have an OnPaint routine that takes an ID/path to the bitmap.

DrawBMP(m_szPATH);  //draw bitmap from path - a function you have coded

When you get the mouse event
Invalidate(); //flag dlg for redrawing
UpdateWindow(); //force a repaint
vihar123Author Commented:
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()
    dd_obj.Draw(hwnd);// This draws the backSurface to the primarySurface
void CDialogSampleDlg::OnLButtonDown(UINT nFlags, CPoint point)
   CDialog::OnLButtonDown(nFlags, point);

AndyAinscowFreelance programmer / ConsultantCommented:
This line is dangerous - give your static control a unique ID eg IDC_STATIC_DD
hwnd = ((CStatic*) this->GetDlgItem(IDC_STATIC))->m_hWnd;

and use
hwnd = ((CStatic*) this->GetDlgItem(IDC_STATIC_DD))->m_hWnd;

Does that help?
If not does your dd_obj have a function to delete the back surface?  Does the LoadBackSurface return a value, if so is it indecating success?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AndyAinscowFreelance programmer / ConsultantCommented:
Excerpt from help
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.