?? openmultifiledlg.cpp
字號:
// MyFileDialog.cpp : implementation file
//
#include "stdafx.h"
#include "MyFolder.h"
#include "OpenMultiFileDlg.h"
#include <afxodlgs.h> // MFC OLE dialog classes
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define MAXMULTIPATH 260//保存文件名的緩沖區的最大長度
/////////////////////////////////////////////////////////////////////////////
// COpenMultiFileDlg
IMPLEMENT_DYNAMIC(COpenMultiFileDlg, CFileDialog)
COpenMultiFileDlg::COpenMultiFileDlg(BOOL bOpenFileDialog, LPCTSTR lpszDefExt, LPCTSTR lpszFileName,
DWORD dwFlags, LPCTSTR lpszFilter, CWnd* pParentWnd) :
CFileDialog(bOpenFileDialog, lpszDefExt, lpszFileName, dwFlags, lpszFilter, pParentWnd)//派生類構造函數必須調用基類構造函數。
{
m_pszFileName=new TCHAR[MAXMULTIPATH];
m_pszFileName[0]='\0';
}
COpenMultiFileDlg::~COpenMultiFileDlg()
{
if(m_pszFileName!=NULL)
delete []m_pszFileName;//釋放m_pszFileName
}
int COpenMultiFileDlg::DoModal()//m_ofn是win32openfiledialog的一個實例。
{
ASSERT_VALID(this);
ASSERT(m_ofn.Flags&OFN_ALLOWMULTISELECT);//支持打開多個文件
m_ofn.lpstrFile=m_pszFileName;
m_ofn.nMaxFile=MAXMULTIPATH;//路徑及文件名最大字符數,(260)
return CFileDialog::DoModal();
}
BEGIN_MESSAGE_MAP(COpenMultiFileDlg, CFileDialog)
//{{AFX_MSG_MAP(COpenMultiFileDlg)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
////////////////////////////////////////////////////////////////
// This is where the real action is going on
// Remember #include <dlgs.h>
BOOL COpenMultiFileDlg::OnInitDialog() // Override
{
const UINT iExtraSize = 150;//增加Dialog窗口長度
// Number of controls in the File Dialog
const UINT nControls = 7;
// Get a pointer to the original dialog box.
CWnd *wndDlg = GetParent();//得到CFileDialog指針
RECT Rect;
wndDlg->GetWindowRect(&Rect);
// Change the size
wndDlg->SetWindowPos(NULL, 0, 0,
Rect.right - Rect.left, //原來對話框寬度
Rect.bottom - Rect.top + iExtraSize, //原來對話框長度+iExtraSize
SWP_NOMOVE);
// Control ID's - defined in <dlgs.h>
UINT Controls[nControls] = {stc3, stc2, // The two label controls
edt1, cmb1, // The eidt control and the drop-down box
IDOK, IDCANCEL,
lst1}; // Explorer vinduet
// Go through each of the controls in the dialog box, and move them to a new position
for (int i=0 ; i<nControls ; i++)
{
CWnd *wndCtrl = wndDlg->GetDlgItem(Controls[i]);
wndCtrl->GetWindowRect(&Rect);
wndDlg->ScreenToClient(&Rect); // Remember it is child controls
// Move all the controls according to the new size of the dialog.
if (Controls[i] != lst1)
wndCtrl->SetWindowPos(NULL,
Rect.left, Rect.top + iExtraSize,
0, 0, SWP_NOSIZE);
else // This is the explorer like window. It should be sized - not moved.
wndCtrl->SetWindowPos(NULL, 0, 0,
Rect.right - Rect.left,
Rect.bottom - Rect.top + iExtraSize,
SWP_NOMOVE);
}
// Remember to call the baseclass.
return CFileDialog::OnInitDialog();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -