PFM.cpp
资源名称:DXGuide.zip [点击查看]
上传用户:wymy58
上传日期:2007-01-07
资源大小:2086k
文件大小:8k
源码类别:
DirextX编程
开发平台:
Visual C++
- // PFM.cpp : Defines the class behaviors for the application.
- //
- #include "stdafx.h"
- #include "PFM.h"
- #include "MainFrm.h"
- #include "PackFilesDlg.h"
- #include "CopyFilesDlg.h"
- #include "SelDrvDlg.h"
- #include "DelFileDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- int Compare(const void* p1, const void* p2)
- {
- return (_stricmp(((FILE_ENTRY*)(p1))->szFileName, ((FILE_ENTRY*)(p2))->szFileName));
- }
- /////////////////////////////////////////////////////////////////////////////
- // CPFMApp
- BEGIN_MESSAGE_MAP(CPFMApp, CWinApp)
- //{{AFX_MSG_MAP(CPFMApp)
- ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
- ON_COMMAND(ID_TAB, OnTab)
- ON_COMMAND(ID_RETURN, OnReturn)
- ON_COMMAND(ID_CHGDRVLEFT, OnChgdrvleft)
- ON_COMMAND(ID_CHGDRVRIGHT, OnChgdrvright)
- ON_COMMAND(ID_COPYFILES, OnCopyfiles)
- ON_COMMAND(ID_DELFILES, OnDelfiles)
- ON_COMMAND(ID_MOVEFILES, OnMovefiles)
- ON_COMMAND(ID_MKDIR, OnMkdir)
- ON_COMMAND(ID_PACKFILES, OnPackfiles)
- ON_COMMAND(ID_SELFILES, OnSelfiles)
- ON_COMMAND(ID_SELREVERSE, OnSelreverse)
- ON_COMMAND(ID_DESELFILES, OnDeselfiles)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CPFMApp construction
- CPFMApp::CPFMApp()
- {
- // TODO: add construction code here,
- // Place all significant initialization in InitInstance
- }
- /////////////////////////////////////////////////////////////////////////////
- // The one and only CPFMApp object
- CPFMApp theApp;
- /////////////////////////////////////////////////////////////////////////////
- // CPFMApp initialization
- BOOL CPFMApp::InitInstance()
- {
- // Standard initialization
- // If you are not using these features and wish to reduce the size
- // of your final executable, you should remove from the following
- // the specific initialization routines you do not need.
- #ifdef _AFXDLL
- Enable3dControls(); // Call this when using MFC in a shared DLL
- #else
- Enable3dControlsStatic(); // Call this when linking to MFC statically
- #endif
- // Change the registry key under which our settings are stored.
- // TODO: You should modify this string to be something appropriate
- // such as the name of your company or organization.
- SetRegistryKey(_T("Local AppWizard-Generated Applications"));
- // To create the main window, this code creates a new frame window
- // object and then sets it as the application's main window object.
- CMainFrame* pFrame = new CMainFrame;
- m_pMainWnd = pFrame;
- // create and load the frame with its resources
- pFrame->LoadFrame(IDR_MAINFRAME,
- WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL,
- NULL);
- // The one and only window has been initialized, so show and update it.
- // pFrame->GetMenu()->RemoveMenu(2,MF_BYPOSITION);
- pFrame->ShowWindow(SW_SHOW);
- pFrame->UpdateWindow();
- // Restore previous state
- gLeftPan->LoadDirectory(gOptions.m_strStartPathLeft);
- gRightPan->LoadDirectory(gOptions.m_strStartPathRight);
- if (gCurPan)
- gRightPan->SetFocus();
- else
- gLeftPan->SetFocus();
- //pFrame->GetMenu()->GetSubMenu(2)->EnableMenuItem(ID_VIEW_TOOLBAR, FALSE);
- //pFrame->GetMenu()->GetSubMenu(2)->EnableMenuItem(ID_VIEW_STATUS_BAR, FALSE);
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CPFMApp message handlers
- /////////////////////////////////////////////////////////////////////////////
- // 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)
- // No message handlers
- //}}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()
- // App command to run the dialog
- void CPFMApp::OnAppAbout()
- {
- CAboutDlg aboutDlg;
- aboutDlg.DoModal();
- }
- /////////////////////////////////////////////////////////////////////////////
- // CPFMApp message handlers
- void CPFMApp::OnTab()
- {
- // TODO: Add your command handler code here
- if (gCurPan)
- {
- gCurPan = 0;
- gLeftPan->SetFocus();
- }
- else
- {
- gCurPan = 1;
- gRightPan->SetFocus();
- }
- }
- void CPFMApp::OnReturn()
- {
- // TODO: Add your command handler code here
- CFileList *pList = gCurPan?gRightPan:gLeftPan;
- int nItem = pList->GetNextItem(-1, LVNI_ALL|LVNI_FOCUSED);
- if (nItem!=-1)
- pList->LoadItem(nItem);
- }
- void CPFMApp::OnChgdrvleft()
- {
- // TODO: Add your command handler code here
- CSelDrvDlg dlgCd(gMainWnd);
- dlgCd.m_strPath = gLeftPath;
- if (dlgCd.DoModal()==IDOK)
- {
- gLeftPan->LoadDirectory(dlgCd.m_strPath);
- gLeftPan->SetFocus();
- }
- }
- void CPFMApp::OnChgdrvright()
- {
- // TODO: Add your command handler code here
- CSelDrvDlg dlgCd(gMainWnd);
- dlgCd.m_strPath = gRightPath;
- if (dlgCd.DoModal()==IDOK)
- {
- gRightPan->LoadDirectory(dlgCd.m_strPath);
- gRightPan->SetFocus();
- }
- }
- void CPFMApp::OnCopyfiles()
- {
- // TODO: Add your command handler code here
- CFileList *pfl = gCurPan?gRightPan:gLeftPan;
- if (pfl->GetSelectedCount()==1)
- {
- LPWIN32_FIND_DATA pFd;
- int nItem = pfl->GetNextItem(-1, LVNI_ALL|LVNI_SELECTED);
- pFd = (LPWIN32_FIND_DATA)pfl->GetItemData(nItem);
- if (strcmp(pFd->cFileName, "..")==0)
- {
- MessageBox(gMainWnd->m_hWnd, "未选取文件", "PackFile Maker", MB_OK|MB_ICONSTOP);
- return;
- }
- }
- CCopyFilesDlg cfd(gMainWnd);
- cfd.DoModal();
- }
- void CPFMApp::OnDelfiles()
- {
- // TODO: Add your command handler code here
- CFileList *pfl = gCurPan?gRightPan:gLeftPan;
- if (pfl->GetSelectedCount()==1)
- {
- LPWIN32_FIND_DATA pFd;
- int nItem = pfl->GetNextItem(-1, LVNI_ALL|LVNI_SELECTED);
- pFd = (LPWIN32_FIND_DATA)pfl->GetItemData(nItem);
- if (strcmp(pFd->cFileName, "..")==0)
- {
- MessageBox(gMainWnd->m_hWnd, "未选取文件", "PackFile Maker", MB_OK|MB_ICONSTOP);
- return;
- }
- }
- CDelFileDlg dfd(gMainWnd);
- dfd.DoModal();
- }
- void CPFMApp::OnMovefiles()
- {
- // TODO: Add your command handler code here
- }
- void CPFMApp::OnMkdir()
- {
- // TODO: Add your command handler code here
- }
- void CPFMApp::OnPackfiles()
- {
- if ((gLeftPath.Right(1)!="\") || (gRightPath.Right(1)!="\"))
- return;
- CFileList *pfl = gCurPan?gRightPan:gLeftPan;
- if (pfl->GetSelectedCount()==1)
- {
- LPWIN32_FIND_DATA pFd;
- int nItem = pfl->GetNextItem(-1, LVNI_ALL|LVNI_SELECTED);
- pFd = (LPWIN32_FIND_DATA)pfl->GetItemData(nItem);
- if (strcmp(pFd->cFileName, "..")==0)
- {
- MessageBox(gMainWnd->m_hWnd, "未选取文件", "PackFile Maker", MB_OK|MB_ICONSTOP);
- return;
- }
- }
- CPackFilesDlg pfd(gMainWnd);
- pfd.m_strPackFileName = (gCurPan?gLeftPath:gRightPath)+"package.ff";
- pfd.DoModal();
- // TODO: Add your command handler code here
- }
- void CPFMApp::OnSelfiles()
- {
- // TODO: Add your command handler code here
- }
- void CPFMApp::OnSelreverse()
- {
- // TODO: Add your command handler code here
- LVITEM lvi;
- CFileList *pFl = gCurPan?gRightPan:gLeftPan;
- int nItem = pFl->GetNextItem(-1, LVNI_ALL);
- while(nItem!=-1)
- {
- lvi.mask = LVIF_STATE;
- lvi.iItem = nItem;
- lvi.iSubItem = 0;
- lvi.stateMask = 0xFFFF;
- // get all state flags
- pFl->GetItem(&lvi);
- lvi.state ^= LVIS_SELECTED;
- pFl->SetItem(&lvi);
- nItem = pFl->GetNextItem(nItem, LVNI_ALL);
- }
- }
- void CPFMApp::OnDeselfiles()
- {
- // TODO: Add your command handler code here
- }