[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2004-11-08
4
Medium Priority
?
327 Views
Last Modified: 2013-11-20
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
0
Comment
Question by:vihar123
  • 3
4 Comments
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 12522956
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
}
0
 

Author Comment

by:vihar123
ID: 12523086
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
0
 
LVL 45

Accepted Solution

by:
AndyAinscow earned 1500 total points
ID: 12523884
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?
0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 12530604
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.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month18 days, 14 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question