FileDialog 注意事项

  1. OPENFILENAMEW   ofn;
  2.     ::memset( &ofn,0,sizeof(ofn));
  3.     ofn.lStructSize   =   sizeof   (OPENFILENAME)   ;   
  4.     ofn.hwndOwner     =   GetHWND();                         
  5.     ofn.lpstrFilter   =   L"Gif Files/0*.gif/0/0";//L"Gif Files/0*.gif/0All Files/0*.*/0/0"
  6.     ofn.lpstrFile =  _wcsCurGifPath;   
  7.     ofn.nMaxFile  =  sizeof(_wcsCurGifPath)/sizeof(WCHAR);//字符个数 
  8.     ofn.lpstrFileTitle  = NULL;   
  9.     ofn.nMaxFileTitle  =  MAX_PATH;   
  10.     ofn.lpstrDefExt = NULL;
  11.     ofn.Flags = OFN_EXPLORER;
  12.     if( ::GetOpenFileNameW(&ofn) != 0 )
  13.         FALSETEST_SE(_clsShowGif.ProcessGif( _wcsCurGifPath),L"处理Gif文件错误");//Mrs Secretary, We want to open a GIF file, pleae help me.
  14.     else
  15.         ::wmemset( _wcsCurGifPath,0,sizeof(_wcsCurGifPath)/sizeof(WCHAR));

注意 ofn.lpstrFile, 在这个域中,是保存最后的文件路径的,

这个值要求在某些情况下, 内容初始化为NULL.

MSDN:

lpstrFile
Pointer to a buffer that contains a file name used to initialize the File Name edit control. The first character of this buffer must be NULL if initialization is not necessary. When the GetOpenFileName or GetSaveFileName function returns successfully, this buffer contains the drive designator, path, file name, and extension of the selected file.

If the OFN_ALLOWMULTISELECT flag is set and the user selects multiple files, the buffer contains the current directory followed by the file names of the selected files. For Explorer-style dialog boxes, the directory and file name strings are NULL separated, with an extra NULL character after the last file name. For old-style dialog boxes, the strings are space separated and the function uses short file names for file names with spaces. You can use the FindFirstFile function to convert between long and short file names. If the user selects only one file, the lpstrFile string does not have a separator between the path and file name.

If the buffer is too small, the function returns FALSE and the CommDlgExtendedError function returns FNERR_BUFFERTOOSMALL. In this case, the first two bytes of the lpstrFile buffer contain the required size, in bytes or characters.

posted on   norsd  阅读(238)  评论(0编辑  收藏  举报

编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 葡萄城 AI 搜索升级:DeepSeek 加持,客户体验更智能
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏

导航

< 2008年8月 >
27 28 29 30 31 1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31 1 2 3 4 5 6
点击右上角即可分享
微信分享提示