home *** CD-ROM | disk | FTP | other *** search
- // MMDlg.cpp : implementation file
- //
-
- #include "stdafx.h"
- #include "MMApp.h"
- #include "MMDlg.h"
- #include "MMSave.h"
-
- #define TIMER_ID 1
-
- #define BALANCE_MIN -100
- #define BALANCE_MED 0
- #define BALANCE_MAX 100
- #define BALANCE_POS 0
-
- #define VOLUME_MIN 0
- #define VOLUME_MED 50
- #define VOLUME_MAX 100
- #define VOLUME_POS 50
-
- #define SPEED_MIN 0
- #define SPEED_MED 100
- #define SPEED_MAX 200
- #define SPEED_POS 100
-
- char szGraphOpenFilter[] =
- {
- "All Files (*.*)|" "*.*|"
- "LEAD (*.cmp)|" "*.cmp|"
- "CALS (*.cal)|" "*.cal|"
- "GEM Image (*.img)|" "*.img|"
- "CServe PNG (*.png)|" "*.png|"
- "DICOM DIC (*.dic)|" "*.dic|"
- "Exif (*.jpj)|" "*.tif;*.jpg|"
- #ifdef WIN32
- "FlashPix (*.fpx)|" "*.fpx|"
- #endif
- "GIF (*.gif)|" "*.gif|"
- "IOCA (*.ica)|" "*.ica|"
- "JPEG (*.jpg;*.jff;*.jtf)|" "*.jpg;*.jff;*.jtf|"
- "Mac PICTURE (*.pct)|" "*.pct|"
- "MacPaint (*.mac)|" "*.mac|"
- "MS Paint (*.msp)|" "*.msp|"
- #ifdef WIN32
- "MS Fax (*.awd)|" "*.awd|"
- #endif
- "Photo CD (*.pcd)|" "*.pcd|"
- "PCX (*.pcx)|" "*.pcx|"
- "PhotoShop PSD (*.psd)|" "*.psd|"
- "PostScript Raster (*.eps)|" "*.eps|"
- "SUN Raster (*.ras)|" "*.ras|"
- "TGA (*.tga)|" "*.tga|"
- "TIF (*.tif)|" "*.tif|"
- "Win Metafile (*.wmf)|" "*.wmf|"
- "Win & OS/2 (*.bmp)|" "*.bmp|"
- "Winfax (*.fxs)|" "*.fxs|"
- "WordPerfect (*.wpg)|" "*.wpg|"
- "Win Icon (*.ico)|" "*.ico|"
- "Win Cursor (*.cur)|" "*.cur|"
- };
-
- char szVideoOpenFilter[] =
- {
- "AVI Files (*.avi)|" "*.avi|"
- "WAV Files (*.wav)|" "*.wav|"
- "All Files (*.*)|" "*.*||"
- };
-
- /////////////////////////////////////////////////////////////////////////////
- // CAboutDlg dialog used for App About
-
- class CAboutDlg : public CDialog
- {
- public:
- CAboutDlg();
-
- // Dialog Data
- //{{AFX_DATA(CAboutDlg)
- enum { IDD = IDD_ABOUTBOX };
- //}}AFX_DATA
-
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CAboutDlg)
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- //}}AFX_VIRTUAL
-
- // Implementation
- protected:
- //{{AFX_MSG(CAboutDlg)
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
-
- CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
- {
- //{{AFX_DATA_INIT(CAboutDlg)
- //}}AFX_DATA_INIT
- }
-
- void CAboutDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAboutDlg)
- //}}AFX_DATA_MAP
- }
-
- BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- //{{AFX_MSG_MAP(CAboutDlg)
- // No message handlers
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CMMDlg dialog
-
- CMMDlg::CMMDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CMMDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CMMDlg)
- m_FrameMin = _T("");
- m_FrameMax = _T("");
- m_TimeMin = _T("");
- m_TimeMax = _T("");
- //}}AFX_DATA_INIT
- // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
-
- m_szVideoCompressor[0] = 0;
- m_szAudioCompressor[0] = 0;
- m_nAudioFormat = -1;
- }
-
- void CMMDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CMMDlg)
- DDX_Control(pDX, IDC_FRAMEPOS, m_FramePos);
- DDX_Control(pDX, IDC_TIMEPOS, m_TimePos);
- DDX_Control(pDX, IDC_VIDEOFRAME, m_VideoFrame);
- DDX_Control(pDX, IDC_ONOFF, m_OnOff);
- DDX_Control(pDX, IDC_VOLUME, m_Volume);
- DDX_Control(pDX, IDC_SPEED, m_Speed);
- DDX_Control(pDX, IDC_BALANCE, m_Balance);
- DDX_Control(pDX, IDC_PROGRESS, m_Progress);
- DDX_Control(pDX, IDC_PLAY, m_Play);
- DDX_Control(pDX, IDC_STOP, m_Stop);
- DDX_Control(pDX, IDC_REWIND, m_Rewind);
- DDX_Control(pDX, IDC_FORWARD, m_Forward);
- DDX_Control(pDX, IDC_PREVMARK, m_PrevMark);
- DDX_Control(pDX, IDC_NEXTMARK, m_NextMark);
- DDX_Control(pDX, IDC_PREVFRAME, m_PrevFrame);
- DDX_Control(pDX, IDC_NEXTFRAME, m_NextFrame);
- DDX_Control(pDX, IDC_STARTSEL, m_StartSel);
- DDX_Control(pDX, IDC_ENDSEL, m_EndSel);
- DDX_Text(pDX, IDC_FRAMEMIN, m_FrameMin);
- DDX_Text(pDX, IDC_FRAMEMAX, m_FrameMax);
- DDX_Text(pDX, IDC_TIMEMIN, m_TimeMin);
- DDX_Text(pDX, IDC_TIMEMAX, m_TimeMax);
- DDX_Control(pDX, IDC_LEADDLG, m_LeadDlg);
- DDX_Control(pDX, IDC_LEAD, m_Lead);
- DDX_Control(pDX, IDC_LEADVIDEO, m_LeadVideo);
- //}}AFX_DATA_MAP
- }
-
- BEGIN_MESSAGE_MAP(CMMDlg, CDialog)
- //{{AFX_MSG_MAP(CMMDlg)
- ON_WM_SYSCOMMAND()
- ON_COMMAND(ID_FILE_OPENREAD, OnFileOpenRead)
- ON_COMMAND(ID_FILE_OPENEDIT, OnFileOpenEdit)
- ON_COMMAND(ID_FILE_CLOSE, OnFileClose)
- ON_COMMAND(ID_FILE_SAVEAS, OnFileSaveAs)
- ON_COMMAND(ID_EDIT_COPYFRAME, OnEditCopyFrame)
- ON_COMMAND(ID_EDIT_PASTEFRAME, OnEditPasteFrame)
- ON_COMMAND(ID_EDIT_INSERTFRAME, OnEditInsertFrame)
- ON_COMMAND(ID_EDIT_REPLACEFRAME, OnEditReplaceFrame)
- ON_COMMAND(ID_EDIT_DELETEFRAME, OnEditDeleteFrame)
- ON_COMMAND(ID_EDIT_SAVEFRAME, OnEditSaveFrame)
- ON_COMMAND(ID_HELP_ABOUTBOX, OnHelpAboutbox)
- ON_BN_CLICKED(IDC_PLAY, OnPlay)
- ON_BN_CLICKED(IDC_STOP, OnStop)
- ON_BN_CLICKED(IDC_REWIND, OnRewind)
- ON_BN_CLICKED(IDC_FORWARD, OnForward)
- ON_BN_CLICKED(IDC_PREVMARK, OnPrevMark)
- ON_BN_CLICKED(IDC_NEXTMARK, OnNextMark)
- ON_BN_CLICKED(IDC_PREVFRAME, OnPrevFrame)
- ON_BN_CLICKED(IDC_NEXTFRAME, OnNextFrame)
- ON_BN_CLICKED(IDC_STARTSEL, OnStartSel)
- ON_BN_CLICKED(IDC_ENDSEL, OnEndSel)
- ON_WM_HSCROLL()
- ON_WM_VSCROLL()
- ON_WM_TIMER()
- ON_WM_CLOSE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CMMDlg message handlers
-
- BOOL CMMDlg::OnInitDialog()
- {
- CRect rcVideo;
-
- CDialog::OnInitDialog();
-
- SetIcon(m_hIcon, TRUE);
- SetIcon(m_hIcon, FALSE);
-
- UNLOCKSUPPORT(m_Lead);
- UNLOCKSUPPORT(m_LeadVideo);
-
- m_Lead.SetEnableMethodErrors(FALSE);
- m_LeadVideo.SetEnableMethodErrors(FALSE);
- m_LeadVideo.SetAutoResizeControl(FALSE);
- m_LeadVideo.SetEnableProgressEvent(FALSE);
-
- m_OnOff.SetIcon(AfxGetApp()->LoadIcon(IDI_OFF));
- m_Play.SetIcon(AfxGetApp()->LoadIcon(IDI_PLAY));
- m_Stop.SetIcon(AfxGetApp()->LoadIcon(IDI_STOP));
- m_Rewind.SetIcon(AfxGetApp()->LoadIcon(IDI_REWIND));
- m_Forward.SetIcon(AfxGetApp()->LoadIcon(IDI_FORWARD));
- m_PrevFrame.SetIcon(AfxGetApp()->LoadIcon(IDI_PREVFRAME));
- m_NextFrame.SetIcon(AfxGetApp()->LoadIcon(IDI_NEXTFRAME));
- m_PrevMark.SetIcon(AfxGetApp()->LoadIcon(IDI_PREVMARK));
- m_NextMark.SetIcon(AfxGetApp()->LoadIcon(IDI_NEXTMARK));
- m_StartSel.SetIcon(AfxGetApp()->LoadIcon(IDI_STARTSEL));
- m_EndSel.SetIcon(AfxGetApp()->LoadIcon(IDI_ENDSEL));
-
- m_Balance.SetRange(BALANCE_MIN, BALANCE_MAX, TRUE);
- m_Balance.SetTic(BALANCE_MIN);
- m_Balance.SetTic(BALANCE_MED);
- m_Balance.SetTic(BALANCE_MAX);
- m_Balance.SetPos(BALANCE_POS);
-
- m_Volume.SetRange(VOLUME_MIN, VOLUME_MAX, TRUE);
- m_Volume.SetTic(VOLUME_MIN);
- m_Volume.SetTic(VOLUME_MED);
- m_Volume.SetTic(VOLUME_MAX);
- m_Volume.SetPos(VOLUME_POS);
-
- m_Speed.SetRange(SPEED_MIN, SPEED_MAX, TRUE);
- m_Speed.SetTic(SPEED_MIN);
- m_Speed.SetTic(SPEED_MED);
- m_Speed.SetTic(SPEED_MAX);
- m_Speed.SetPos(SPEED_POS);
-
- m_ToolTip.Create(this);
- m_ToolTip.Activate(TRUE);
- m_ToolTip.AddTool(GetDlgItem(IDC_PLAY), "Play");
- m_ToolTip.AddTool(GetDlgItem(IDC_STOP), "Stop");
- m_ToolTip.AddTool(GetDlgItem(IDC_PREVFRAME), "Previous Frame");
- m_ToolTip.AddTool(GetDlgItem(IDC_NEXTFRAME), "Next Frame");
- m_ToolTip.AddTool(GetDlgItem(IDC_PREVMARK), "Previous Mark");
- m_ToolTip.AddTool(GetDlgItem(IDC_NEXTMARK), "Next Mark");
- m_ToolTip.AddTool(GetDlgItem(IDC_REWIND), "Rewind");
- m_ToolTip.AddTool(GetDlgItem(IDC_FORWARD), "Forward");
- m_ToolTip.AddTool(GetDlgItem(IDC_STARTSEL), "Start Selection");
- m_ToolTip.AddTool(GetDlgItem(IDC_ENDSEL), "End Selection");
-
- m_fLeadVideo = FALSE;
-
- m_VideoFrame.GetWindowRect(m_rcVideoFrame);
- ScreenToClient(m_rcVideoFrame);
- m_VideoFrame.GetClientRect(rcVideo);
- m_LeadVideo.MoveWindow(m_rcVideoFrame.TopLeft().x + (m_rcVideoFrame.Width() - rcVideo.Width()) / 2, m_rcVideoFrame.TopLeft().y + (m_rcVideoFrame.Height() - rcVideo.Height()) / 2, rcVideo.Width(), rcVideo.Height(), TRUE);
-
- SetButtons();
- InitProgress(0, 0);
- SetProgress(0);
-
- SetTimer(TIMER_ID, 100, NULL);
-
- return TRUE; // return TRUE unless you set the focus to a control
- }
-
- void CMMDlg::OnSysCommand(UINT nID, LPARAM lParam)
- {
- SetMenu();
-
- CDialog::OnSysCommand(nID, lParam);
- }
-
- BOOL CMMDlg::PreTranslateMessage(MSG* pMsg)
- {
- m_ToolTip.RelayEvent(pMsg);
-
- return CDialog::PreTranslateMessage(pMsg);
- }
-
- BEGIN_EVENTSINK_MAP(CMMDlg, CDialog)
- //{{AFX_EVENTSINK_MAP(CMMDlg)
- ON_EVENT(CMMDlg, IDC_LEADVIDEO, 1 /* MMCompressor */, OnMMCompressor, VTS_BSTR)
- ON_EVENT(CMMDlg, IDC_LEADVIDEO, 3 /* MMModeChange */, OnMMModeChange, VTS_I2)
- //}}AFX_EVENTSINK_MAP
- END_EVENTSINK_MAP()
-
- void CMMDlg::OnClose()
- {
- KillTimer(TIMER_ID);
- OnFileClose();
-
- CDialog::OnClose();
- }
-
- void CMMDlg::OnFileOpenRead()
- {
- int nResult;
-
- OnFileClose();
-
- nResult = OpenFile(MODE_PLAYBACK);
- if (nResult != S_OK)
- {
- if (nResult != ERROR_DLG_CANCELED)
- {
- DisplayError(nResult);
- }
- return;
- }
-
- m_fLeadVideo = TRUE;
-
- SetButtons();
- InitProgress(0, m_LeadVideo.GetMMTotalFrames());
- SetProgress(0);
- }
-
- void CMMDlg::OnFileOpenEdit()
- {
- int nResult;
-
- OnFileClose();
-
- nResult = OpenFile(MODE_EDIT);
- if (nResult != S_OK)
- {
- if (nResult != ERROR_DLG_CANCELED)
- {
- DisplayError(nResult);
- }
- return;
- }
-
- m_fLeadVideo = TRUE;
-
- SetButtons();
- InitProgress(0, m_LeadVideo.GetMMTotalFrames());
- SetProgress(0);
- }
-
- void CMMDlg::OnFileClose()
- {
- if (m_fLeadVideo)
- {
- if (m_LeadVideo.GetMMIsPlaying())
- {
- m_LeadVideo.MMStop();
- }
-
- m_LeadVideo.MMClose();
- m_fLeadVideo = FALSE;
-
- SetButtons();
- InitProgress(0, 0);
- SetProgress(0);
- }
- }
-
- void CMMDlg::OnFileSaveAs()
- {
- int nResult;
-
- nResult = SaveFile(MODE_EDIT);
- if (nResult != S_OK)
- {
- if (nResult != ERROR_DLG_CANCELED)
- {
- DisplayError(nResult);
- }
- }
- }
-
- void CMMDlg::OnEditCopyFrame()
- {
- int nResult;
-
- nResult = m_LeadVideo.MMCopyFramesToClipboard(m_Progress.GetPos(), 1);
- if (nResult != S_OK)
- {
- DisplayError(nResult);
- }
- }
-
- void CMMDlg::OnEditPasteFrame()
- {
- int nResult, nMin, nMax;
-
- nResult = m_LeadVideo.MMPasteFrames(m_Progress.GetPos(), -1);
- if (nResult != S_OK)
- {
- DisplayError(nResult);
- }
-
- m_Progress.GetSelection(nMin, nMax);
- InitProgress(nMin, nMax);
- SetProgress(m_Progress.GetPos());
- }
-
- void CMMDlg::OnEditInsertFrame()
- {
- int nResult, nMin, nMax;
-
- nResult = OpenFile(-1);
- if (nResult != S_OK)
- {
- if (nResult != ERROR_DLG_CANCELED)
- {
- DisplayError(nResult);
- }
- return;
- }
-
- m_Progress.GetSelection(nMin, nMax);
- InitProgress(nMin, nMax);
- SetProgress(m_Progress.GetPos());
- }
-
- void CMMDlg::OnEditReplaceFrame()
- {
- int nResult;
-
- nResult = m_LeadVideo.MMDeleteFrames(m_Progress.GetPos(), 1);
- if (nResult != S_OK)
- {
- DisplayError(nResult);
- return;
- }
-
- nResult = OpenFile(-1);
- if (nResult != S_OK)
- {
- if (nResult != ERROR_DLG_CANCELED)
- {
- DisplayError(nResult);
- }
- return;
- }
-
- SetProgress(m_Progress.GetPos());
- }
-
- void CMMDlg::OnEditDeleteFrame()
- {
- int nPos, nResult, nMin, nMax;
-
- nPos = m_Progress.GetPos();
-
- nResult = m_LeadVideo.MMDeleteFrames(nPos, 1);
- if (nResult != S_OK)
- {
- DisplayError(nResult);
- return;
- }
-
- if (nPos >= m_LeadVideo.GetMMTotalFrames())
- {
- m_Progress.SetPos(m_LeadVideo.GetMMTotalFrames());
- }
-
- m_Progress.GetSelection(nMin, nMax);
- InitProgress(nMin, nMax);
- SetProgress(m_Progress.GetPos());
- }
-
- void CMMDlg::OnEditSaveFrame()
- {
- int nResult;
-
- nResult = SaveFile(-1);
- if (nResult != S_OK)
- {
- if (nResult != ERROR_DLG_CANCELED)
- {
- DisplayError(nResult);
- }
- }
- }
-
- void CMMDlg::OnHelpAboutbox()
- {
- CAboutDlg dlg;
- dlg.DoModal();
- }
-
- void CMMDlg::OnPlay()
- {
- int nMin, nMax, nPos;
-
- if (m_LeadVideo.GetMMIsPlaying())
- {
- m_LeadVideo.MMPause();
- }
- else
- {
- m_Progress.GetSelection(nMin, nMax);
- nPos = m_Progress.GetPos();
- if(nMin <= nPos && nPos < nMax)
- nMin = nPos;
- m_LeadVideo.SetMMClipStart(nMin);
- m_LeadVideo.SetMMClipEnd(nMax);
- m_LeadVideo.MMPlay();
- }
- }
-
- void CMMDlg::OnStop()
- {
- int nMin, nMax;
-
- m_LeadVideo.MMStop();
- m_Progress.GetSelection(nMin, nMax);
- SetProgress(nMin);
- }
-
- void CMMDlg::OnRewind()
- {
- SetProgress(0);
- }
-
- void CMMDlg::OnForward()
- {
- SetProgress(m_LeadVideo.GetMMTotalFrames());
- }
-
- void CMMDlg::OnPrevMark()
- {
- int nMin, nMax;
-
- m_Progress.GetSelection(nMin, nMax);
- SetProgress(nMin);
- }
-
- void CMMDlg::OnNextMark()
- {
- int nMin, nMax;
-
- m_Progress.GetSelection(nMin, nMax);
- SetProgress(nMax);
- }
-
- void CMMDlg::OnPrevFrame()
- {
- SetProgress(m_Progress.GetPos() - 1);
- }
-
- void CMMDlg::OnNextFrame()
- {
- SetProgress(m_Progress.GetPos() + 1);
- }
-
- void CMMDlg::OnStartSel()
- {
- int nMin, nMax;
-
- m_Progress.GetSelection(nMin, nMax);
- nMin = m_Progress.GetPos();
- InitProgress(nMin, nMax);
- }
-
- void CMMDlg::OnEndSel()
- {
- int nMin, nMax;
-
- m_Progress.GetSelection(nMin, nMax);
- nMax = m_Progress.GetPos();
- InitProgress(nMin, nMax);
- }
-
- void CMMDlg::OnTimer(UINT nIDEvent)
- {
- long nPos;
-
- if (m_fLeadVideo)
- {
- nPos = m_LeadVideo.GetMMCurrentPos();
-
- if (m_LeadVideo.GetMMIsPlaying())
- {
- nPos = m_LeadVideo.GetMMCurrentPos();
- DisplayPosition(nPos, IDC_TIMEPOS, IDC_FRAMEPOS);
- m_Progress.SetPos(nPos);
-
- if (m_nOnOff)
- {
- m_OnOff.SetIcon(AfxGetApp()->LoadIcon(IDI_ONLOW));
- m_nOnOff = 0;
- }
- else
- {
- m_OnOff.SetIcon(AfxGetApp()->LoadIcon(IDI_ONHIGH));
- m_nOnOff = 1;
- }
- }
- }
-
- CDialog::OnTimer(nIDEvent);
- }
-
- void CMMDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- if (m_fLeadVideo == FALSE)
- {
- return;
- }
-
- if ((CSliderCtrl *)pScrollBar == &m_Balance)
- {
- m_LeadVideo.SetMMBalance(-m_Balance.GetPos());
- }
- else
- if ((CSliderCtrl *)pScrollBar == &m_Progress)
- {
- int nPos;
-
- nPos = m_Progress.GetPos();
-
- if (nPos != m_LeadVideo.GetMMCurrentPos())
- {
- SetProgress(nPos);
- }
- }
-
- CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
- }
-
- void CMMDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- if (m_fLeadVideo == FALSE)
- {
- return;
- }
-
- if ((CSliderCtrl *)pScrollBar == &m_Volume)
- {
- m_LeadVideo.SetMMVolume(m_Volume.GetPos());
- }
- else
- if ((CSliderCtrl *)pScrollBar == &m_Speed)
- {
- m_LeadVideo.SetMMPlayRate((float)m_Speed.GetPos() / 100);
- }
-
- CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
- }
-
- int CMMDlg::DisplayError (int nCode)
- {
- char str[128];
-
- if (nCode != S_OK)
- {
- wsprintf(str, "A LEADTOOLS error has occured.\nCODE = %d", nCode);
- MessageBox(str, NULL, MB_ICONERROR);
- }
-
- return nCode;
- }
-
- int CMMDlg::OpenFile(int nMode)
- {
- int nResult, nZoom, nWidth, nHeight, nLeft, nTop;
- CRect rcVideo;
-
- m_LeadDlg.SetEnableMethodErrors(FALSE);
- m_LeadDlg.SetPreviewEnabled(TRUE);
- m_LeadDlg.SetFileDlgFlags(0);
- m_LeadDlg.SetUIFlags(DLG_FO_95STYLE | DLG_FO_MULTIPAGE | DLG_FO_FILEINFO | DLG_FO_SHOWPREVIEW | DLG_FO_SHOWSTAMP);
- m_LeadDlg.SetDialogTitle("Open File");
-
- if ((nMode != MODE_PLAYBACK) && (nMode != MODE_EDIT))
- {
- m_LeadDlg.SetFilter(szGraphOpenFilter);
- }
- else
- {
- m_LeadDlg.SetFilter(szVideoOpenFilter);
- }
-
- //You must move the Video Control off the screen or else it
- //traps input and never sets focus back correctly when
- //user selects a file by double clicking on the filename
- //in the FileOpen dialog. This is due to the Playback
- //window which is created by Microsoft ActiveMovie.
- CRect rcWin;
- m_LeadVideo.GetWindowRect(&rcWin);
- m_LeadVideo.SetWindowPos(NULL, -400, 0, 0, 0, SWP_NOSIZE);
- nResult = m_LeadDlg.FileOpen((long)this->m_hWnd);
- m_LeadVideo.SetWindowPos(NULL, rcWin.left, rcWin.top, 0, 0, SWP_NOSIZE);
- if (nResult != S_OK)
- {
- return nResult;
- }
-
- if ((nMode != MODE_PLAYBACK) && (nMode != MODE_EDIT))
- {
- BeginWaitCursor();
- nResult = m_LeadVideo.MMInsertFrame(m_Progress.GetPos(), (char far *)((LPCTSTR)m_LeadDlg.GetFileName()));
- EndWaitCursor();
- }
- else
- {
- BeginWaitCursor();
- m_LeadVideo.SetControlMode(nMode);
- nResult = m_LeadVideo.MMLoad((char far *)((LPCTSTR)m_LeadDlg.GetFileName()));
- if (nResult != S_OK)
- {
- EndWaitCursor();
- return nResult;
- }
- nResult = S_OK;
-
- m_LeadVideo.SetMMBalance(-m_Balance.GetPos());
- m_LeadVideo.SetMMVolume(m_Volume.GetPos());
- m_LeadVideo.SetMMPlayRate((float)m_Speed.GetPos() / 100);
-
- if ((m_LeadVideo.GetVideoWidth() <= 0) || (m_LeadVideo.GetVideoHeight() <= 0))
- {
- EndWaitCursor();
- return S_OK;
- }
-
- nZoom = max(min(((long)m_rcVideoFrame.Width() * 1000L / (long)m_LeadVideo.GetVideoWidth()), ((long)m_rcVideoFrame.Height() * 1000L / (long)m_LeadVideo.GetVideoHeight())), 1L);
- nWidth = MulDiv(m_LeadVideo.GetVideoWidth(), nZoom, 1000);
- nHeight = MulDiv(m_LeadVideo.GetVideoHeight(), nZoom, 1000);
-
- nLeft = (m_rcVideoFrame.Width() - nWidth) / 2 + m_rcVideoFrame.TopLeft().x;
- nTop = (m_rcVideoFrame.Height() - nHeight) / 2 + m_rcVideoFrame.TopLeft().y;
-
- m_VideoFrame.MoveWindow(nLeft, nTop, nWidth, nHeight, TRUE);
- m_VideoFrame.GetClientRect(rcVideo);
- m_LeadVideo.MoveWindow(nLeft + (nWidth - rcVideo.Width()) / 2, nTop + (nHeight - rcVideo.Height()) / 2, rcVideo.Width(), rcVideo.Height(), TRUE);
- EndWaitCursor();
- }
-
- return nResult;
- }
-
- void CMMDlg::OnMMCompressor(LPCTSTR szName)
- {
- if (m_nCompressor == COMPRESSOR_VIDEO)
- {
- if (m_strVideoCompressor == NULL)
- {
- m_nVideoIndex++;
- }
- else
- {
- m_strVideoCompressor[m_nVideoIndex++] = szName;
- }
- }
- else
- {
- if (m_strAudioCompressor == NULL)
- {
- m_nAudioIndex++;
- }
- else
- {
- m_strAudioCompressor[m_nAudioIndex++] = szName;
- }
- }
- }
-
- int CMMDlg::SaveFile(int nMode)
- {
- int nResult;
- CMMSave dlgSave;
-
- if ((nMode != MODE_PLAYBACK) && (nMode != MODE_EDIT))
- {
- m_LeadDlg.SetEnableMethodErrors(FALSE);
- m_LeadDlg.SetFileDlgFlags(0);
- m_LeadDlg.SetUIFlags(DLG_FS_95STYLE | DLG_FS_MULTIPAGE | DLG_FS_QFACTOR);
- m_LeadDlg.SetSaveFormatFlags(DLG_FS_ALL);
- m_LeadDlg.SetDialogTitle("Save File");
-
- nResult = m_LeadDlg.FileSave((long)(this->m_hWnd));
- if (nResult != S_OK)
- {
- return nResult;
- }
-
- BeginWaitCursor();
- nResult = m_LeadVideo.MMSaveFrame((char far *)((LPCTSTR)m_LeadDlg.GetFileName()), m_LeadDlg.GetSaveFormat(), m_LeadDlg.GetSaveBitsPerPixel(), m_LeadDlg.GetSaveQFactor(), m_LeadDlg.GetSaveMulti());
- EndWaitCursor();
- }
- else
- {
- m_nCompressor = COMPRESSOR_VIDEO;
- m_nVideoIndex = 0;
- m_strVideoCompressor = NULL;
- m_LeadVideo.MMEnumCompressors(m_nCompressor);
-
- m_strVideoCompressor = new CString[m_nVideoIndex];
- m_nVideoIndex = 0;
- m_LeadVideo.MMEnumCompressors(m_nCompressor);
-
- m_nCompressor = COMPRESSOR_AUDIO;
- m_nAudioIndex = 0;
- m_strAudioCompressor = NULL;
- m_LeadVideo.MMEnumCompressors(m_nCompressor);
-
- m_strAudioCompressor = new CString[m_nAudioIndex];
- m_nAudioIndex = 0;
- m_LeadVideo.MMEnumCompressors(m_nCompressor);
-
- strcpy(dlgSave.m_szVideoCompressor, m_szVideoCompressor);
- strcpy(dlgSave.m_szAudioCompressor, m_szAudioCompressor);
-
- dlgSave.m_strVideoCompressor = m_strVideoCompressor;
- dlgSave.m_nVideoIndex = m_nVideoIndex;
- dlgSave.m_strAudioCompressor = m_strAudioCompressor;
- dlgSave.m_nAudioIndex = m_nAudioIndex;
- dlgSave.m_nAudioFormat = m_nAudioFormat;
-
- if (dlgSave.DoModal() != IDOK)
- {
- return ERROR_DLG_CANCELED;
- }
-
- strcpy(m_szVideoCompressor, dlgSave.m_szVideoCompressor);
- strcpy(m_szAudioCompressor, dlgSave.m_szAudioCompressor);
- m_nAudioFormat = dlgSave.m_nAudioFormat;
-
-
- BeginWaitCursor();
- if (m_LeadVideo.GetControlMode() == MODE_PLAYBACK)
- {
- nResult = m_LeadVideo.MMSaveFile((char far *)((LPCTSTR)dlgSave.GetFileName()), FILE_AVI, m_szVideoCompressor, m_szAudioCompressor);
- }
- else
- {
- nResult = m_LeadVideo.MMSaveFile((char far *)((LPCTSTR)dlgSave.GetFileName()), FILE_AVI, m_szVideoCompressor, m_szAudioCompressor);
- }
- EndWaitCursor();
-
- delete []m_strVideoCompressor;
- delete []m_strAudioCompressor;
- }
-
- return nResult;
- }
-
- void CMMDlg::SetMenu()
- {
- CMenu *pMenu=GetMenu();
-
- if (pMenu == NULL)
- {
- return;
- }
-
- if (m_fLeadVideo != FALSE)
- {
- pMenu->EnableMenuItem(ID_FILE_CLOSE, MF_ENABLED);
- pMenu->EnableMenuItem(ID_FILE_SAVE, MF_ENABLED);
- pMenu->EnableMenuItem(ID_FILE_SAVEAS, MF_ENABLED);
-
- if (m_LeadVideo.GetControlMode() == MODE_PLAYBACK)
- {
- pMenu->EnableMenuItem(ID_EDIT_COPYFRAME, MF_DISABLED | MF_GRAYED);
- pMenu->EnableMenuItem(ID_EDIT_PASTEFRAME, MF_DISABLED | MF_GRAYED);
- pMenu->EnableMenuItem(ID_EDIT_INSERTFRAME, MF_DISABLED | MF_GRAYED);
- pMenu->EnableMenuItem(ID_EDIT_REPLACEFRAME, MF_DISABLED | MF_GRAYED);
- pMenu->EnableMenuItem(ID_EDIT_DELETEFRAME, MF_DISABLED | MF_GRAYED);
- pMenu->EnableMenuItem(ID_EDIT_SAVEFRAME, MF_DISABLED | MF_GRAYED);
- }
- else
- {
- pMenu->EnableMenuItem(ID_EDIT_COPYFRAME, MF_ENABLED);
-
- if (m_LeadVideo.GetMMIsClipboardReady() != 0)
- {
- pMenu->EnableMenuItem(ID_EDIT_PASTEFRAME, MF_ENABLED);
- }
- else
- {
- pMenu->EnableMenuItem(ID_EDIT_PASTEFRAME, MF_DISABLED | MF_GRAYED);
- }
-
- pMenu->EnableMenuItem(ID_EDIT_INSERTFRAME, MF_ENABLED);
- pMenu->EnableMenuItem(ID_EDIT_REPLACEFRAME, MF_ENABLED);
- pMenu->EnableMenuItem(ID_EDIT_DELETEFRAME, MF_ENABLED);
- pMenu->EnableMenuItem(ID_EDIT_SAVEFRAME, MF_ENABLED);
- }
- }
- else
- {
- pMenu->EnableMenuItem(ID_FILE_SAVE, MF_DISABLED | MF_GRAYED);
- pMenu->EnableMenuItem(ID_FILE_SAVEAS, MF_DISABLED | MF_GRAYED);
- pMenu->EnableMenuItem(ID_FILE_CLOSE, MF_DISABLED | MF_GRAYED);
- pMenu->EnableMenuItem(ID_EDIT_COPYFRAME, MF_DISABLED | MF_GRAYED);
- pMenu->EnableMenuItem(ID_EDIT_PASTEFRAME, MF_DISABLED | MF_GRAYED);
- pMenu->EnableMenuItem(ID_EDIT_INSERTFRAME, MF_DISABLED | MF_GRAYED);
- pMenu->EnableMenuItem(ID_EDIT_REPLACEFRAME, MF_DISABLED | MF_GRAYED);
- pMenu->EnableMenuItem(ID_EDIT_DELETEFRAME, MF_DISABLED | MF_GRAYED);
- pMenu->EnableMenuItem(ID_EDIT_SAVEFRAME, MF_DISABLED | MF_GRAYED);
- }
- }
-
- void CMMDlg::SetButtons()
- {
- m_OnOff.SetIcon(AfxGetApp()->LoadIcon(IDI_OFF));
-
- if (m_fLeadVideo != FALSE)
- {
- if (m_LeadVideo.GetMMIsPlaying())
- {
- m_Play.EnableWindow(TRUE);
- m_Stop.EnableWindow(TRUE);
- m_Rewind.EnableWindow(FALSE);
- m_Forward.EnableWindow(FALSE);
- m_PrevFrame.EnableWindow(FALSE);
- m_NextFrame.EnableWindow(FALSE);
- m_PrevMark.EnableWindow(FALSE);
- m_NextMark.EnableWindow(FALSE);
- m_StartSel.EnableWindow(FALSE);
- m_EndSel.EnableWindow(FALSE);
-
- m_Play.SetIcon(AfxGetApp()->LoadIcon(IDI_PAUSE));
-
- m_ToolTip.DelTool(GetDlgItem(IDC_PLAY));
- m_ToolTip.AddTool(GetDlgItem(IDC_PLAY), "Pause");
- }
- else
- {
- m_Play.EnableWindow(TRUE);
- m_Stop.EnableWindow(FALSE);
- m_Rewind.EnableWindow(TRUE);
- m_Forward.EnableWindow(TRUE);
- m_PrevFrame.EnableWindow(TRUE);
- m_NextFrame.EnableWindow(TRUE);
- m_PrevMark.EnableWindow(TRUE);
- m_NextMark.EnableWindow(TRUE);
- m_StartSel.EnableWindow(TRUE);
- m_EndSel.EnableWindow(TRUE);
-
- m_Play.SetIcon(AfxGetApp()->LoadIcon(IDI_PLAY));
-
- m_ToolTip.DelTool(GetDlgItem(IDC_PLAY));
- m_ToolTip.AddTool(GetDlgItem(IDC_PLAY), "Play");
- }
- }
- else
- {
- m_Play.EnableWindow(FALSE);
- m_Stop.EnableWindow(FALSE);
- m_Rewind.EnableWindow(FALSE);
- m_Forward.EnableWindow(FALSE);
- m_PrevFrame.EnableWindow(FALSE);
- m_NextFrame.EnableWindow(FALSE);
- m_PrevMark.EnableWindow(FALSE);
- m_NextMark.EnableWindow(FALSE);
- m_StartSel.EnableWindow(FALSE);
- m_EndSel.EnableWindow(FALSE);
-
- m_Play.SetIcon(AfxGetApp()->LoadIcon(IDI_PLAY));
-
- m_ToolTip.DelTool(GetDlgItem(IDC_PLAY));
- m_ToolTip.AddTool(GetDlgItem(IDC_PLAY), "Play");
- }
- }
-
- void CMMDlg::DisplayPosition(long nPosition, int nTimeID, int nFrameID)
- {
- int nFormat, nResult;
- long nTime=-1, nFrame=-1;
- CString strText;
-
- if (m_fLeadVideo != FALSE)
- {
- nFormat = m_LeadVideo.GetMMTimeFormat();
-
- if (nFormat == TIME_MILLISEC)
- {
- nTime = nPosition;
- nResult = m_LeadVideo.MMConvertTime(&nFrame, TIME_FRAME, nTime, TIME_MILLISEC);
- if (nResult != S_OK)
- {
- nFrame = -1;
- }
- }
- else
- {
- nFrame = nPosition;
- nResult = m_LeadVideo.MMConvertTime(&nTime, TIME_MILLISEC, nFrame, TIME_FRAME);
- if (nResult != S_OK)
- {
- nTime = -1;
- }
- }
- }
-
- if (nFrame >= 0)
- {
- strText.Format("%ld", nFrame);
- }
- else
- {
- strText = "";
- }
-
- SetDlgItemText(nFrameID, strText);
- m_FramePos.RedrawWindow();
-
- if (nTime >= 0)
- {
- strText.Format("%02ld:%02ld", (nTime / 1000) / 60, (nTime / 1000) % 60);
- }
- else
- {
- strText = "";
- }
-
- SetDlgItemText(nTimeID, strText);
- m_TimePos.RedrawWindow();
- }
-
- void CMMDlg::InitProgress(int nMin, int nMax)
- {
- m_Progress.ClearSel(TRUE);
- m_Progress.ClearTics();
-
- if ((m_fLeadVideo != FALSE) && (m_LeadVideo.GetMMTotalFrames() > 0))
- {
- nMin = max(0, nMin);
- nMax = min(m_LeadVideo.GetMMTotalFrames(), nMax);
-
- m_Progress.SetRange(0, m_LeadVideo.GetMMTotalFrames(), TRUE);
- m_Progress.SetSelection(nMin, nMax);
- m_Progress.SetTic(nMin);
- m_Progress.SetTic(nMax);
-
- if (m_Progress.GetPos() < 0)
- {
- m_Progress.SetPos(0);
- }
- else
- if (m_Progress.GetPos() > m_LeadVideo.GetMMTotalFrames())
- {
- m_Progress.SetPos(m_LeadVideo.GetMMTotalFrames());
- }
-
- DisplayPosition(0, IDC_TIMEMIN, IDC_FRAMEMIN);
- DisplayPosition(m_LeadVideo.GetMMTotalFrames(), IDC_TIMEMAX, IDC_FRAMEMAX);
- }
- else
- {
- m_Progress.SetRange(0, 0, TRUE);
- m_Progress.SetPos(0);
- DisplayPosition(0, IDC_TIMEMIN, IDC_FRAMEMIN);
- DisplayPosition(0, IDC_TIMEMAX, IDC_FRAMEMAX);
- }
- }
-
- void CMMDlg::SetProgress(int nPos)
- {
- if (m_fLeadVideo == FALSE)
- {
- nPos = 0;
- m_Progress.SetPos(nPos);
- }
- else
- {
- nPos = max(nPos, 0);
- nPos = min(nPos, m_LeadVideo.GetMMTotalFrames());
- m_Progress.SetPos(nPos);
- m_LeadVideo.SetMMCurrentPos(nPos);
- }
-
- DisplayPosition(nPos, IDC_TIMEPOS, IDC_FRAMEPOS);
- }
-
- void CMMDlg::OnMMModeChange(short iMode)
- {
- switch (iMode)
- {
- case MODE_PLAY:
- case MODE_STOP:
- case MODE_PAUSE:
- case MODE_RESUME:
- SetButtons();
- break;
- }
- }
-