⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tfilelistdlg.cpp

📁 mpq文件的格式就是一种压缩格式
💻 CPP
字号:
/*****************************************************************************/
/* TFileListDlg.cpp                       Copyright (c) Ladislav Zezula 2003 */
/*---------------------------------------------------------------------------*/
/* Dialog for the file list                                                  */
/*---------------------------------------------------------------------------*/
/*   Date    Ver   Who  Comment                                              */
/* --------  ----  ---  -------                                              */
/* 03.04.03  1.00  Lad  The first version of TFileListDlg.cpp                */
/*****************************************************************************/

#include "stdafx.h"
#include "TFileListDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

//-----------------------------------------------------------------------------
// TFileListDlg

BEGIN_MESSAGE_MAP(TFileListDlg, CDialog)
	//{{AFX_MSG_MAP(TFileListDlg)
	ON_BN_CLICKED(IDC_AUTODETECT, OnAutodetectClick)
	ON_COMMAND(ID_INTERNAL_LISTFILE, OnInternalListfile)
	ON_LBN_DBLCLK(IDC_FILELIST, OnOK)
	ON_COMMAND(ID_AUTODETECT_FILES, OnAutodetectFiles)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

//-----------------------------------------------------------------------------
// Constructor and destructor

TFileListDlg::TFileListDlg(CWnd* pParent /*=NULL*/) : CDialog(TFileListDlg::IDD, pParent)
{
    m_bNoAutoDetect = FALSE;

    //{{AFX_DATA_INIT(TFileListDlg)
	//}}AFX_DATA_INIT
}


void TFileListDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(TFileListDlg)
	DDX_Control(pDX, IDC_FILELIST, m_FileList);
	//}}AFX_DATA_MAP
}

//-----------------------------------------------------------------------------
// TFileListDlg message handlers

BOOL TFileListDlg::OnInitDialog() 
{
    WIN32_FIND_DATA wf;
    CString strNewTitle;
    CString strTitle;
    HANDLE hFind = INVALID_HANDLE_VALUE;
    TCHAR szMask[MAX_PATH];
    BOOL bResult = TRUE;

	CDialog::OnInitDialog();

    // Set file title
    GetWindowText(strTitle);
    strNewTitle.Format(strTitle, (const char *)GetPlainName(m_strMpqName));
    SetWindowText(strNewTitle);

	// Try to find the filelists in the directory of the application
    sprintf(szMask, "%s\\*.txt", cfg.szFileListsPath);
    hFind = FindFirstFile(szMask, &wf);

    while(hFind != INVALID_HANDLE_VALUE && bResult == TRUE)
    {
        if((wf.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
            m_FileList.InsertString(-1, wf.cFileName);

        bResult = FindNextFile(hFind, &wf);
    }

    if(hFind != INVALID_HANDLE_VALUE)
        FindClose(hFind);

    // If autodetect has to be disabled, do it now
    if(m_bNoAutoDetect)
        GetDlgItem(IDC_AUTODETECT)->EnableWindow(FALSE);

    return TRUE;
}

void TFileListDlg::OnAutodetectClick() 
{
    HMENU hMenu = LoadMenu(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_CTXAUTODETECT));
    HMENU hSubMenu = GetSubMenu(hMenu, 0);
    RECT  rect;

    if(hSubMenu != NULL)
    {
        // Calculate the position where the context menu appears
        GetDlgItem(IDC_AUTODETECT)->GetWindowRect(&rect);
        TrackPopupMenu(hSubMenu, TPM_LEFTALIGN | TPM_TOPALIGN, rect.left, rect.bottom, 0, m_hWnd, NULL);
    }
}


void TFileListDlg::OnInternalListfile() 
{
    m_strFileList = _T("");
    EndDialog(ID_INTERNAL_LISTFILE);
}

void TFileListDlg::OnAutodetectFiles() 
{
    m_strFileList = _T("");
    EndDialog(ID_AUTODETECT_FILES);
}

void TFileListDlg::OnOK() 
{
    CString strText;
    int nCurSel = m_FileList.GetCurSel();
    
    m_FileList.GetText(nCurSel, strText);
    m_strFileList.Format("%s\\%s", cfg.szFileListsPath, (const char *)strText);
	CDialog::OnOK();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -