📄 pathdlg.cpp
字号:
// PathDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Ext32.h"
#include "PathDlg.h"
#include <shlobj.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern char gsExtPath[];
BOOL gbSubDir=TRUE;
/////////////////////////////////////////////////////////////////////////////
// PathDlg dialog
PathDlg::PathDlg(CWnd* pParent /*=NULL*/)
: CDialog(PathDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(PathDlg)
// NOTE: the ClassWizard will add member initialization here
// hParent = pParent->m_hWnd;
szTemp[0] = 0;
//}}AFX_DATA_INIT
}
void PathDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(PathDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
DDX_Control(pDX, IDC_PATHBOX, m_PathEdit);
DDX_Check(pDX, IDC_SUBDIR, m_bSubDir);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(PathDlg, CDialog)
//{{AFX_MSG_MAP(PathDlg)
ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// PathDlg message handlers
void PathDlg::OnBrowse()
{
// TODO: Add your control notification handler code here
if(ShellGetPathName(szTemp)){
m_PathEdit.SetWindowText(szTemp);
}
}
void PathDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
gbSubDir = m_bSubDir;
m_PathEdit.GetWindowText(szTemp, sizeof(szTemp));
strcpy(gsExtPath, szTemp);
CDialog::OnOK();
}
void PathDlg::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
BOOL PathDlg::ShellGetPathName(char EditPath[])
{
BOOL bRet;
char szPath[MAX_PATH];
LPITEMIDLIST lpil;
HGLOBAL hgMem;
BROWSEINFO bi;
bi.hwndOwner=(HWND) this->m_hWnd;
bi.pidlRoot = NULL;
bi.pszDisplayName = szPath;
bi.lpszTitle = "Select Folder";
bi.ulFlags = BIF_RETURNONLYFSDIRS;
bi.lpfn = NULL;
bi.lParam = 0L;
bi.iImage = 0;
lpil = SHBrowseForFolder(&bi);
if(lpil == NULL)
return FALSE;
bRet = SHGetPathFromIDList(lpil, EditPath);
hgMem = GlobalHandle(lpil);
GlobalFree(hgMem);
return bRet;
}
BOOL PathDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
char ComboText[] = "A:\\";
// hWndCombo = ::GetDlgItem(this->m_hWnd, IDC_PATHBOX);
m_PathEdit.AddString("All");
for(int i=0;i<26;i++){
ComboText[0] = 'A'+i;
int TmpVal = GetDriveType(ComboText);
if((TmpVal != DRIVE_UNKNOWN) && (TmpVal != DRIVE_NO_ROOT_DIR))
m_PathEdit.AddString(ComboText);
}
m_PathEdit.SetWindowText(gsExtPath);
m_bSubDir = gbSubDir;
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -