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
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
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::OnInitDi alog()
{
-----------
hwnd = ((CStatic*) this->GetDlgItem(IDC_STATI C))->m_hWn d;
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(Afx GetInstanc eHandle(), "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::OnLButto nDown(UINT nFlags, CPoint point)
{
dd_obj.LoadBackSurface(Afx GetInstanc eHandle(), "dog.bmp", hwnd);
dd_obj.Draw(hwnd);
CDialog::OnLButtonDown(nFl ags, point);
}
regards
Vihar
BOOL CDialogSampleDlg::OnInitDi
{
-----------
hwnd = ((CStatic*) this->GetDlgItem(IDC_STATI
dd_obj.Init(hwnd); // Set up our DirectDraw interface AND save off a compatible HDC AND load our clipper
dd_obj.InitSurfaces(hwnd);
dd_obj.LoadBackSurface(Afx
return TRUE;
}
void CDialogSampleDlg::OnPaint(
{
if()
--
else
{
dd_obj.Draw(hwnd);// This draws the backSurface to the primarySurface
CDialog::OnPaint();
}
}
void CDialogSampleDlg::OnLButto
{
dd_obj.LoadBackSurface(Afx
dd_obj.Draw(hwnd);
CDialog::OnLButtonDown(nFl
}
regards
Vihar
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
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
}