我重载了文件保存时的命令,更改了文件过滤器。现在发现在保存的时候如果在保存文件名里面写“out”,再在扩展名下拉列表里面选“.txt” 保存出来的是“out” 而不是“out.txt” 囧,怎么获得这个下拉列表里面的值呢@@
bow~~

解决方案 »

  1.   

    GetFileExt( ) 能够获得文件的扩展名,但前提是我要在文件名框里面写入“out.txt”,这样它能得到“.txt”。可是我想在文件名框里面只写“out”,然后在扩展名框里面选择“.txt”这一项,点确定,最后得到完整的文件名“out.txt”  :)
      

  2.   

    那你重载CFileDialog::OnFileNameOK 这个函数咯,在点击OK的时候处理一下就应该可以了
    [Quote]
    Override this function only if you want to provide custom validation of filenames that are entered into a common file dialog box. 
    virtual BOOL OnFileNameOK( );
     Return Value
    1 if the filename is not a valid filename; otherwise 0.Res
    This function allows you to reject a filename for any application-specific reason. Normally, you do not need to use this function because the framework provides default validation of filenames and displays a message box if an invalid filename is entered. If 1 is returned, the dialog box will remain displayed for the user to enter another filename. The dialog procedure dismisses the dialog if the return is 0. Other nonzero return values are currently reserved and should not be used.[Quote]
      

  3.   

    我想让用户随便输入一个 FileTitle 然后通过选择列表来自动加上 后缀名。现在觉得是不是应该用:CFileDialog::OnLBSelChangedNotify
    virtual void OnLBSelChangedNotify( UINT nIDBox, UINT iCurSel, UINT nCode);可是这个函数要UINT nIDBox 即 后缀名列表的ID,这个ID该怎么才能获得呢@@
      

  4.   

    子类化CFileDialog时可能用到的控件对应的值。用PrevDlgCtrl和NextDlgCtrl遍历
    得到。
    Open Button
    1
    Cancel Button
    2
    file name(Edit Combo)
    1152
    folder(Combo)
    1137
    read only(Label)
    1040
    file extension(Combo)
    1136
    FolderView(ListView)
    1
    ToolBar
    1088
    未经证实!
      

  5.   

    cannot access protected member declared in class 'CFileDialog'囧rz我找到解决方法鸟:
    CFileDialog oFileDlg(FALSE, .... );
    然后判断这个变量就可以了:
    sel = oFileDlg.m_ofn.nFilterIndex;O(∩_∩)O