当前位置: 首页>>代码示例>>C++>>正文


C++ CFileDialog::GetDlgItem方法代码示例

本文整理汇总了C++中CFileDialog::GetDlgItem方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileDialog::GetDlgItem方法的具体用法?C++ CFileDialog::GetDlgItem怎么用?C++ CFileDialog::GetDlgItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CFileDialog的用法示例。


在下文中一共展示了CFileDialog::GetDlgItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetBCGFileDlg

//***************************************************************************************
static CBCGPFileDialog* GetBCGFileDlg (HWND hwdParent)
{
	CFileDialog* pDlg = (CFileDialog*)CWnd::FromHandle (hwdParent);
	ASSERT (pDlg != NULL);

	CBCGPFileDialog* pFD = (CBCGPFileDialog*) pDlg->GetDlgItem(0);
	ASSERT (pFD != NULL);

	return pFD;
}
开发者ID:iclosure,项目名称:jframework,代码行数:11,代码来源:BCGPFileDialog.cpp

示例2: WindowProcDiag

/* WindowProcDiag
 * ----------------------------------------------------------------------------
 */
LRESULT CALLBACK WindowProcDiag(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    if (message == WM_COMMAND)
    {
        if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDOK)
        {
            CFileDialog *pDlg = (CFileDialog *)CWnd::FromHandle(hwnd);
            if (pDlg == NULL)
            {
                return CallWindowProc(CFolderDialog::m_fpWndProcDiag, hwnd, message, wParam, lParam);
            }

            CString sPath;
            pDlg->GetDlgItem(edt1)->GetWindowText(sPath);

            // If the user has entered something like "c:\\windows\\\\system"
            // this is invalid but _access returns valid if this string is passed to
            // it. So before giving it to _access validate it.
            for (int i = 1; i < sPath.GetLength() - 1; i++)
            {
                if (sPath[i] == '\\' && sPath[i+1] == '\\')
                {
                    CString sMsg;
                    sMsg.Format(_T("The selected folder '%s' is invalid. Please select another one"), sPath);

                    MessageBox(hwnd, sMsg, ((CFolderDialog*)pDlg->GetDlgItem(0))->m_sMsgTitle, MB_OK | MB_ICONHAND);
                    return NULL;
                }
            }

            // If user has entered a trailing backslash remove it
            // e.g. "c:\\windows\\system\\" --> "c:\\windows\\system"
            if (sPath[sPath.GetLength() - 1] == '\\')
                sPath = sPath.Left (sPath.GetLength() - 1);

            //If path does not exist
            if(_access(sPath, 00) != 0)
            {
                CString sTempPath(sPath);
                sTempPath += _T('\\');

                CString sMsg;
                sMsg.Format(_T("The selected path '%s' does not exist.\nDo you want to create it?"), sTempPath);

                if(MessageBox(hwnd, sMsg, ((CFolderDialog*)pDlg->GetDlgItem(0))->m_sMsgTitle, MB_YESNO | MB_ICONQUESTION) == IDYES)
                {
                    UINT uPos = 0;

                    if (! ((CFolderDialog*)pDlg->GetDlgItem(0))->CreateDirTree(sTempPath, uPos, TRUE))
                    {
                        sMsg.Format(_T("Could not create folder: %s"), sTempPath);

                        MessageBox(hwnd, sMsg, ((CFolderDialog*)pDlg->GetDlgItem(0))->m_sMsgTitle, MB_OK | MB_ICONHAND);
                        return NULL;
                    }
                }
                else
                {
                    return NULL;
                }
            }
            else
            {
                TCHAR szCurrent[MAX_PATH];
                GetCurrentDirectory (MAX_PATH, szCurrent);

                HWND hwndTest = GetFocus() ;
                if (hwndTest == pDlg->GetDlgItem(edt1)->m_hWnd && stricmp(sPath, szCurrent) != 0)
                {
                    // OK was caused by edit control, don't close the dialog.
                    return CallWindowProc(CFolderDialog::m_fpWndProcDiag, hwnd, message, wParam, lParam);
                }
            }

            ((CFolderDialog*)pDlg->GetDlgItem(0))->m_sSelPath =  sPath;
            ((CFolderDialog*)pDlg->GetDlgItem(0))->m_sSelPath += _T('\\');

            pDlg->EndDialog(IDOK);
            return NULL;
        }
    }

    return CallWindowProc(CFolderDialog::m_fpWndProcDiag, hwnd, message, wParam, lParam);
}
开发者ID:LM25TTD,项目名称:ATCMcontrol_Engineering,代码行数:87,代码来源:FolderDialog.cpp


注:本文中的CFileDialog::GetDlgItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。