error C2512: 'CFileDialog' : no appropriate default constructor available

解决方案 »

  1.   

    这样不对吗?
    class CGfxInComboDlg : public CFileDialog
    {
    public:
    CGfxInComboDlg(BOOL bOpenFileDialog, 
    LPCTSTR lpszDefExt,
    LPCTSTR lpszFileName ,
    DWORD dwFlags ,
    LPCTSTR lpszFilter,
    CWnd* pParentWnd );
      

  2.   

    CFileDialog的構造函數是這樣的:
    CFileDialog( BOOL bOpenFileDialog, LPCTSTR lpszDefExt = NULL, LPCTSTR lpszFileName = NULL, DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, LPCTSTR lpszFilter = NULL, CWnd* pParentWnd = NULL );也就是說他需要至少一個參數。
    把你的構造函數改為:
    CGfxInComboDlg(BOOL bOpenFileDialog, 
    LPCTSTR lpszDefExt,
    LPCTSTR lpszFileName ,
    DWORD dwFlags ,
    LPCTSTR lpszFilter,
    CWnd* pParentWnd ):CFileDialog(bool bOpenFileDialog); (在CPP 裡)
    就對了。
      

  3.   

    老大我试过了,但却得到下列错误:
    GfxincomboDlg.cpp(25) : error C2144: syntax error : missing ')' before type 'bool'
    GfxincomboDlg.cpp(25) : error C2612: trailing 'auto' illegal in base/member initializer list
    GfxincomboDlg.cpp(25) : error C2512: 'CFileDialog' : no appropriate default constructor available
    GfxincomboDlg.cpp(25) : error C2059: syntax error : ')'
    GfxincomboDlg.cpp(26) : error C2082: redefinition of formal parameter 'bOpenFileDialog'
    GfxincomboDlg.cpp(26) : error C2601: 'bOpenFileDialog' : local function definitions are illegal
    GfxincomboDlg.cpp(26) : error C2063: 'bOpenFileDialog' : not a function
    GfxincomboDlg.cpp(42) : error C2143: syntax error : missing ';' before '{'
    GfxincomboDlg.cpp(46) : error C2601: '_GetBaseMessageMap' : local function definitions are illegal
    GfxincomboDlg.cpp(46) : error C2601: 'GetMessageMap' : local function definitions are illegal
    GfxincomboDlg.cpp(46) : error C2655: 'messageMap' : definition or redeclaration illegal in current scope
            gfxincombodlg.h(55) : see declaration of 'messageMap'
    GfxincomboDlg.cpp(46) : error C2655: '_messageEntries' : definition or redeclaration illegal in current scope
            gfxincombodlg.h(55) : see declaration of '_messageEntries'
    GfxincomboDlg.cpp(57) : error C2601: 'OnKillFocus' : local function definitions are illegal
    GfxincomboDlg.cpp(73) : error C2601: 'OnLButtonUp' : local function definitions are illegal
    GfxincomboDlg.cpp(110) : error C2601: 'PreTranslateMessage' : local function definitions are illegal
    GfxincomboDlg.cpp(155) : fatal error C1004: unexpected end of file found
    Generating Code...
    Error executing cl.exe.- 16 error(s), 0 warning(s)这是我的源码
    GfxincomDlg.h:
    class CGfxInComboDlg : public CFileDialog
    {
    // Construction
    public:
    CGfxInComboDlg(BOOL bOpenFileDialog, 
    LPCTSTR lpszDefExt,
    LPCTSTR lpszFileName ,
    DWORD dwFlags ,
    LPCTSTR lpszFilter,
    CWnd* pParentWnd );// Attributes
    public:
    CGfxInCombo * pCombo;
    int   iLastSel;
    CString   csLastItem;// Operations
    public:// Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CGfxInComboList)
    public:
    virtual BOOL PreTranslateMessage(MSG* pMsg);
    //}}AFX_VIRTUAL// Implementation
    public:
    virtual ~CGfxInComboDlg(); // Generated message map functions
    protected:
    //{{AFX_MSG(CGfxInComboList)
    afx_msg void OnKillFocus(CWnd* pNewWnd);
    afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
    //}}AFX_MSG DECLARE_MESSAGE_MAP()
    };
    GfxincomDlg.CPP:
    CGfxInComboDlg::CGfxInComboDlg(BOOL bOpenFileDialog, 
    LPCTSTR lpszDefExt,
    LPCTSTR lpszFileName ,
    DWORD dwFlags ,
    LPCTSTR lpszFilter,
    CWnd* pParentWnd ) :CFileDialog(bool bOpenFileDialog)
    {
    pCombo = NULL;
    iLastSel = -1;
    bOpenFileDialog = TRUE, 
    lpszDefExt = "mp3",
    lpszFileName = "",
    dwFlags = OFN_ALLOWMULTISELECT |
    OFN_FILEMUSTEXIST    | 
    OFN_HIDEREADONLY     |
    OFN_EXPLORER,
    lpszFilter = "MPEG Audio Files {*.mp3}|*.mp3|All Files {*.*}|*.*||",
    pParentWnd = GetParent();}CGfxInComboDlg::~CGfxInComboDlg()
    {
    }
    ...
    ...
      

  4.   

    我试过你的代码,在我机器上没有问题...当然我没有加入
    afx_msg void .....和pretranslatemessage等代码....
    我估计可能是你键入的字符有问题....
    你是用中文输入法还是拷贝的字符????
    你用windows英文输入法再重新输一遍代码试试.....
      

  5.   

    错误在实现文件里:CGfxInComboDlg::CGfxInComboDlg(BOOL bOpenFileDialog, 
    LPCTSTR lpszDefExt,
    LPCTSTR lpszFileName ,
    DWORD dwFlags ,
    LPCTSTR lpszFilter,
    CWnd* pParentWnd ) :CFileDialog(bool bOpenFileDialog)
    //应该是CFileDialog(bOpenFileDialog)
    你多加了一个bool 
      

  6.   

    樓上說的對,我多加了一個bool ,sorry.
      

  7.   

    樓上說的對,我多加了一個bool ,sorry.