设为首页 加入收藏

TOP

CFileDialog的各种风格的目录/文件夹选择对话框---(CFolderDialog)(二)
2014-11-23 20:17:46 】 浏览:837
Tags:CFileDialog 各种 风格 目录 文件夹 选择 对话 --- CFolderDialog
, NULL, pParentWnd)
{
m_pPath = pPath;
}

BEGIN_MESSAGE_MAP(CFolderDialog, CFileDialog)
END_MESSAGE_MAP()

// Function name : WindowProcNew
// Description : Call this function when user navigate into CFileDialog.
// Return type : LRESULT
// Argument : HWND hwnd
// Argument : UINT message
// Argument : WPARAM wParam
// Argument : LPARAM lParam
LRESULT CALLBACK WindowProcNew(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if(message == WM_COMMAND)
{
if(HIWORD(wParam) == BN_CLICKED)
{
if(LOWORD(wParam) == IDOK)
{
if(CFileDialog* pDlg = (CFileDialog*)CWnd::FromHandle(hwnd))
{
TCHAR path[MAX_PATH];
GetCurrentDirectory(MAX_PATH, path);
*((CFolderDialog*)pDlg->GetDlgItem(0))->m_pPath = CString(path);
pDlg->EndDialog(IDOK);
return NULL;
}
}
}
}
return CallWindowProc(CFolderDialog::m_wndProc, hwnd, message, wParam, lParam);
}

// Function name : CFolderDialog::OnInitDone
// Description : For update the wiew of CFileDialog
// Return type : void
void CFolderDialog::OnInitDone()
{
HideControl(edt1);
//HideControl(stc3); //Select file static text
//HideControl(cmb13); //Current file combobox
HideControl(cmb1); //File filter combobox
HideControl(stc2); //Filter static text

//Rearrange the controls in the bottom.
CWnd* pFD = GetParent();
//Get Cancel Button Position
CRect rectCancel;
pFD->GetDlgItem(IDCANCEL)->GetWindowRect(rectCancel);
pFD->ScreenToClient(rectCancel);

//Enlarge Listview control
CRect rectList2;
pFD->GetDlgItem(lst1)->GetWindowRect(rectList2);
pFD->ScreenToClient(rectList2);
pFD->GetDlgItem(lst1)->SetWindowPos(0, 0, 0, rectList2.Width(), abs(rectList2.top - (rectCancel.top - 4)), SWP_NOMOVE | SWP_NOZORDER);

//Set Static text and position
CRect rectText;
pFD->GetDlgItem(stc3)->GetWindowRect(rectText);
pFD->ScreenToClient(rectText);
pFD->GetDlgItem(stc3)->SetWindowPos(0, rectList2.left, rectCancel.top + 6, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
SetControlText(stc3, _T("Selected:"));

//ComboBox of current file
CRect rectComBo;
pFD->GetDlgItem(cmb13)->GetWindowRect(rectComBo);
pFD->ScreenToClient(rectComBo);
pFD->GetDlgItem(cmb13)->SetWindowPos(0, rectText.left + rectText.Width() - 40, rectCancel.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE);

//Set OK Button Position
CRect rectOK;
pFD->GetDlgItem(IDOK)->GetWindowRect(rectOK);
pFD->ScreenToClient(rectOK);
pFD->GetDlgItem(IDOK)->SetWindowPos(0, rectCancel.left - rectOK.Width() - 2, rectCancel.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
SetControlText(IDOK, _T("Select"));

pFD->SetWindowText(_T("Choose folder"));
pFD->CenterWindow();
m_wndProc = (WNDPROC)SetWindowLong(pFD->m_hWnd, GWL_WNDPROC, (long)WindowProc
首页 上一页 1 2 3 4 下一页 尾页 2/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇实战VC时间控制函数 下一篇vector彻彻底底干干净净清理内存..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目