zoukankan      html  css  js  c++  java
  • Windows系统自带选择文件的对话重写和居中处理

    class CMyFileDialog: public CFileDialogImpl<CMyFileDialog>
    {
    public:
        CMyFileDialog(BOOL bOpenFileDialog, // TRUE for FileOpen, FALSE for FileSaveAs
            LPCTSTR lpszDefExt = NULL,
            LPCTSTR lpszFileName = NULL,
            DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
            LPCTSTR lpszFilter = NULL,
            HWND hWndParent = NULL)
            : CFileDialogImpl<CMyFileDialog>(bOpenFileDialog, lpszDefExt, lpszFileName, dwFlags, lpszFilter, hWndParent){ }
    
        // Maps
        BEGIN_MSG_MAP(CMyFileDialog)
            CHAIN_MSG_MAP(CFileDialogImpl<CMyFileDialog>)
        END_MSG_MAP()
    
    
    
        //重载此函数;实现居中
        void OnInitDone ( LPOFNOTIFY lpon )
        {
            GetFileDialogWindow().CenterWindow(lpon->lpOFN->hwndOwner);
        }
    
    };        

    重写FileDialog,重载OnInitDone,实现居中,引用代码如下:

    void xxx::SelectUpgradeFile()
    {
        char szFilters[] =  _T("升级文件 (*.ram)\0*.ram\0全部文件(*.*)\0*.*\0\0");
        CMyFileDialog fileDlg(TRUE,NULL, NULL,OFN_FILEMUSTEXIST|OFN_HIDEREADONLY,szFilters );//szFilters
    
        char strBuffer[MAX_PATH] = {0};
        fileDlg.m_ofn.lpstrFile = strBuffer;
        fileDlg.m_ofn.nMaxFile = MAX_PATH;
        if (fileDlg.DoModal() != IDOK)
        {
            ImmsMessageBox(m_PaintManager.GetPaintWindow(),_T("升级设备失败!"),_T("提示"),MB_OK);        
            return ;
        }
        m_strEquipmentUpgradeFileName = fileDlg.m_ofn.lpstrFile;
        if (m_strEquipmentUpgradeFileName.Right(4).CompareNoCase(".ram")!=0)
        {
            ImmsMessageBox(m_PaintManager.GetPaintWindow(),_T("选择的文件不是编解码器升级文件!"),_T("提示"),MB_OK|MB_ICONERROR);
            return ;
        }
    
        CEditUI *pFileName = static_cast<CEditUI *>(m_PaintManager.FindControl(ctrl_device_data_manager_decoder_equi_upgrade_select_file));
        if(!pFileName)
            return;
        pFileName->SetText(m_strEquipmentUpgradeFileName);
    
    }
  • 相关阅读:
    git 分支报错: error: The following untracked working tree files would be overwritten by merge
    JSAPI唤起微信支付
    解决html body 元素在底部设置padding-bottom 或者margin-bottom失效的问题
    Java中的接口
    Java中的抽象类
    IDEA快捷键
    Java的访问控制权限修饰符
    Java中的包机制和import机制
    Java中的final关键字
    Java面向对象三大特征
  • 原文地址:https://www.cnblogs.com/happinessday/p/6292147.html
Copyright © 2011-2022 走看看