分类: C/C++
2008-05-31 10:06:20
“打开”按钮代码:
char szFilters[]="MyType Files (*.swf)|*.swf||";
CFileDialog fileDlg (TRUE, "swf", "*.swf",OFN_FILEMUSTEXIST| OFN_HIDEREADONLY,szFilters, this);
if( fileDlg.DoModal ()==IDOK )
{
CString pathName = fileDlg.GetPathName();
flash.put_Movie(pathName);
playflag=TRUE;
if(!timerflag)
{
m_nTimer=SetTimer(1,100,0); //开启计时器
timerflag=!timerflag;
}
}
“播放”按钮代码:
flash.Play();
“暂停”按钮代码:
flash.Stop();
“停止”按钮代码:
flash.Rewind();
flash.Stop();
“重播”按钮代码:
flash.Rewind();
flash.Play();
“后退”按钮代码:
flash.Back();
“前进”按钮代码:
flash.Forward();
“末帧”按钮代码:
flash.GotoFrame(flash.get_TotalFrames()-1);
“快退”按钮代码:
int current=flash.CurrentFrame();
if(current>4)
{
current-=5;
flash.GotoFrame(current);
}
else
{
flash.put_FrameNum(0);
}
“快进”按钮代码:
int current=flash.CurrentFrame();
int i=flash.get_FrameNum();
if(current
current+=5;
flash.GotoFrame(current);
}
else
{
flash.put_FrameNum(flash.get_TotalFrames()-1);
}
“放大”按钮代码:
flash.Zoom(50);
“缩小”按钮代码:
flash.Zoom(200);
“还原”按钮代码:
flash.Zoom(0);
5。添加Slider 控件的消息处理函数PreTranslateMessage()响应的消息NM_RELEASEDCAPTURE
CSliderCtrl *m_pSlider=(CSliderCtrl*)GetDlgItem(IDC_SLIDER1);
int num=m_pSlider->GetPos();
num=num*flash.get_TotalFrames()/100;
flash.GotoFrame(num);
////////////////////////////////////////////////////////////////////////////////////
将下面代码添加到,Dialog类的OnInitDialog()函数中
CSliderCtrl *m_pSlider=(CSliderCtrl*)GetDlgItem(IDC_SLIDER1);
m_pSlider->SetRange(0,100); //设定Slider的活动范围是0~100
6。添加Dialog类的OnTimer()函数响应消息WM_TIMER
在OnTimer()函数中添加代码:
CSliderCtrl *m_pSlider=(CSliderCtrl*)GetDlgItem(IDC_SLIDER1);
m_pSlider->SetPos(flash.CurrentFrame()*100/flash.get_TotalFrames());
7。在Dialog类的DestroyWindow()函数中添加代码:
if(timerflag)
KillTimer(m_nTimer);
8。“全屏”按钮代码:
if(!screenflag && playflag)
{
GetWindowPlacement(&m_WndPos);
flash.GetWindowPlacement(&m_Pos);
flash.GetWindowRect(flashrect);
CSliderCtrl *m_pSlider=(CSliderCtrl*)GetDlgItem(IDC_SLIDER1);
m_pSlider->ShowWindow(SW_HIDE );
HWND hwnd=this->GetSafeHwnd();
LONG style=GetWindowLongPtr(hwnd,GWL_STYLE);
SetWindowLongPtr(hwnd,GWL_STYLE,style-WS_CAPTION );
CClientDC dc(this);
this->MoveWindow(0,0,dc.GetDeviceCaps(HORZRES),dc.GetDeviceCaps(VERTRES));
flash.SetWindowPos(&CWnd::wndTop ,0,0,dc.GetDeviceCaps(HORZRES),dc.GetDeviceCaps(VERTRES),SWP_SHOWWINDOW);
screenflag=TRUE;////////////////////
}
9。响应按键ESC消息,取消全屏。
重载对话框的PreTranslateMessage()函数,在函数中添加如下代码:
if(pMsg->message == WM_KEYDOWN)
{
if(pMsg->wParam==VK_ESCAPE)
{
if(screenflag)
{
HWND hwnd=this->GetSafeHwnd();
LONG style=GetWindowLongPtr(hwnd,GWL_STYLE);
SetWindowLongPtr(hwnd,GWL_STYLE,style+WS_CAPTION );
ShowWindow(SW_HIDE);
SetWindowPlacement(&m_WndPos);
flash.MoveWindow(flashrect.left,flashrect.top,flashrect.Width(),flashrect.Height(),1);
flash.SetWindowPlacement(&m_Pos);
screenflag=FALSE;
CSliderCtrl *m_pSlider=(CSliderCtrl*)GetDlgItem(IDC_SLIDER1);
m_pSlider->ShowWindow(SW_SHOW );
}
}
}
全屏和取消全屏的代码,是俺自己拼凑所得,充其量只是个模拟效果,而且还是个模拟的不好的效果,如果有高手见到,希望能够博您一笑。另外,在笑过之后还请您不吝赐教。俺一定以十二亿万分的热情接受
-