zoukankan      html  css  js  c++  java
  • WinCE应用程序开发打开或另存为对话框

    注:转载请注明出处http://www.cnblogs.com/zaishuiyifang006 人生如棋,我愿为卒,行动虽缓,可谁见我后退一步。

    1. 功能:打开文件选择对话框,选择某个数据文件;或者弹出文件另存为对话框,保存数据文件。

    2. 实现:

    2.1 平台: WinCE6.0 + VS2005

    2.2 实现方法:打开或者另存为对话框,要使用CFileDialog。函数解释为:The destruction of CFileDialog objects is handled automatically. It is not necessary to call CDialog::EndDialog.

        // 相关参数的设置

        CString FileFlt = _T("data file(*.");

        FileFlt += FILE_EXT_1;  // 获取数据文件的拓展名

        FileFlt += _T(")|*.");

        FileFlt += FILE_EXT_1;

        FileFlt += _T("||");

        CFileDialog FileDlg(TRUE,NULL,NULL,OFN_HIDEREADONLY,FileFlt,this,0);

        FileDlg.m_ofn.lpstrInitialDir = DataFileSaveDir;

        FileDlg.m_ofn.lpstrTitle = L"请选择数据文件...";

        INT_PTR nResponse = FileDlg.DoModal();

        if(nResponse == IDCANCEL)

            return;

     运行效果为:

    如果要显示保存数据文件提示,修改FileDlg.m_ofn.lpstrTitle = L"另存数据文件...";即可。

    还有一种方法也可实现这两个功能,即使用GetOpenFileName和GetSaveFileName。

    GetOpenFileName的函数定义为:

    BOOL GetOpenFileName( LPOPENFILENAME lpofn);

    Remarks
    Not all members of the OPENFILENAME structure are defined in Windows CE. For information about the defined members, see the reference topic for the OPENFILENAME structure.

    Windows CE modifies the meaning of the following members of the OPENFILENAME structure when it is passed into the GetOpenFileName function.

    参数lpofn是一结构体,这个结构体的参数列表如下:

    typedef struct tagOFN { /* ofn */
      DWORD lStructSize;
      HWND hwndOwner;
      HINSTANCE hInstance;
      LPCSTR lpstrFilter;
      LPSTR lpstrCustomFilter;
      DWORD nMaxCustFilter;
      DWORD nFilterIndex;
      LPSTR lpstrFile;
      DWORD nMaxFile;
      LPSTR lpstrFileTitle;
      DWORD nMaxFileTitle;
      LPSTR lpstrInitialDir;
      LPCSTR lpstrTitle;
      DWORD Flags;
      WORD nFileOffset;
      WORD nFileExtension;
      LPCSTR lpstrDefExt;
      DWORD lCustData;
      LPOFNHOOKPROC lpfnHook;
      LPCSTR lpTemplateName;
    } OPENFILENAME;

     GetSaveFileName函数的参数及使用说明与GetOpenFileName()基本一致,不再赘述了。

     

     

    注:转载请注明出处http://www.cnblogs.com/zaishuiyifang006 人生如棋,我愿为卒,行动虽缓,可谁见我后退一步。
  • 相关阅读:
    字符型数据(char)与无符号字符型数据的区别(unsigned char)
    Delphi 动态数组、静态数组、TBytes 的区别
    设置dbgrideh的footer
    Electron13之remote模块使用
    源码学习攻略
    使用git子模块实现代码复用
    关于 iframe 在隐藏后显示时,不能保持原有滚动条位置的处理
    字符串分割(String.Split)时连同分隔符一起返回
    008-Linux服务器如何查看自己的公网出口IP地址
    010-核心技术-netty-编码解码机制、protobuf、Netty入站出站机制、netty与log结合
  • 原文地址:https://www.cnblogs.com/zaishuiyifang006/p/2678361.html
Copyright © 2011-2022 走看看