none
关于在编译VC++ 6.0过程中产生的 error C2039 RRS feed

  • 问题

  • 编译错误
    --------------------Configuration: test7 - Win32 Debug--------------------
    Compiling resources...
    Compiling...
    test7Dlg.cpp
    d:\program files\microsoft visual studio\myprojects\test7\test7dlg.cpp(101) : error C2039: 'SetExtendedStyle' : is not a member of 'CListBox'
            d:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(2741) : see declaration of 'CListBox'
    d:\program files\microsoft visual studio\myprojects\test7\test7dlg.cpp(101) : error C2039: 'GetExtendedStyle' : is not a member of 'CListBox'
            d:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(2741) : see declaration of 'CListBox'
    d:\program files\microsoft visual studio\myprojects\test7\test7dlg.cpp(102) : error C2039: 'InsertColumn' : is not a member of 'CListBox'
            d:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(2741) : see declaration of 'CListBox'
    d:\program files\microsoft visual studio\myprojects\test7\test7dlg.cpp(103) : error C2039: 'InsertColumn' : is not a member of 'CListBox'
            d:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(2741) : see declaration of 'CListBox'
    d:\program files\microsoft visual studio\myprojects\test7\test7dlg.cpp(104) : error C2039: 'InsertColumn' : is not a member of 'CListBox'
            d:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(2741) : see declaration of 'CListBox'
    d:\program files\microsoft visual studio\myprojects\test7\test7dlg.cpp(193) : error C2039: 'GetItemCount' : is not a member of 'CListBox'
            d:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(2741) : see declaration of 'CListBox'
    d:\program files\microsoft visual studio\myprojects\test7\test7dlg.cpp(194) : error C2039: 'InsertItem' : is not a member of 'CListBox'
            d:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(2741) : see declaration of 'CListBox'
    d:\program files\microsoft visual studio\myprojects\test7\test7dlg.cpp(195) : error C2039: 'SetItemText' : is not a member of 'CListBox'
            d:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(2741) : see declaration of 'CListBox'
    d:\program files\microsoft visual studio\myprojects\test7\test7dlg.cpp(196) : error C2039: 'SetItemText' : is not a member of 'CListBox'
            d:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(2741) : see declaration of 'CListBox'
    d:\program files\microsoft visual studio\myprojects\test7\test7dlg.cpp(203) : error C2601: 'OnBtnDelete' : local function definitions are illegal
    d:\program files\microsoft visual studio\myprojects\test7\test7dlg.cpp(208) : fatal error C1004: unexpected end of file found
    执行 cl.exe 时出错.
    test7.exe - 1 error(s), 0 warning(s)

    2015年11月20日 14:52

全部回复

  • 错误指向的核心代码分别如下:

    CDialog::OnInitDialog();
    m_listCtrl.SetExtendedStyle(m_listCtrl.GetExtendedStyle()|LVS_EX_GRIDLINES);
    m_listCtrl.InsertColumn(0,"编号",LVCFMT_LEFT,70);
    m_listCtrl.InsertColumn(1,"姓名",LVCFMT_LEFT,80);
    m_listCtrl.InsertColumn(2,"职位",LVCFMT_LEFT,100);
    return TRUE;

    ///////

    class CListBox : public CWnd
    {
    DECLARE_DYNAMIC(CListBox)

    // Constructors
    public:
    CListBox();
    BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);

    // Attributes

    // for entire listbox
    int GetCount() const;
    int GetHorizontalExtent() const;
    void SetHorizontalExtent(int cxExtent);
    int GetTopIndex() const;
    int SetTopIndex(int nIndex);
    LCID GetLocale() const;
    LCID SetLocale(LCID nNewLocale);
    #if (WINVER >= 0x400)
    int InitStorage(int nItems, UINT nBytes);
    UINT ItemFromPoint(CPoint pt, BOOL& bOutside) const;
    #endif
    // for single-selection listboxes
    int GetCurSel() const;
    int SetCurSel(int nSelect);

    // for multiple-selection listboxes
    int GetSel(int nIndex) const;           // also works for single-selection
    int SetSel(int nIndex, BOOL bSelect = TRUE);
    int GetSelCount() const;
    int GetSelItems(int nMaxItems, LPINT rgIndex) const;
    void SetAnchorIndex(int nIndex);
    int GetAnchorIndex() const;

    // for listbox items
    DWORD GetItemData(int nIndex) const;
    int SetItemData(int nIndex, DWORD dwItemData);
    void* GetItemDataPtr(int nIndex) const;
    int SetItemDataPtr(int nIndex, void* pData);
    int GetItemRect(int nIndex, LPRECT lpRect) const;
    int GetText(int nIndex, LPTSTR lpszBuffer) const;
    void GetText(int nIndex, CString& rString) const;
    int GetTextLen(int nIndex) const;

    // Settable only attributes
    void SetColumnWidth(int cxWidth);
    BOOL SetTabStops(int nTabStops, LPINT rgTabStops);
    void SetTabStops();
    BOOL SetTabStops(const int& cxEachStop);    // takes an 'int'

    int SetItemHeight(int nIndex, UINT cyItemHeight);
    int GetItemHeight(int nIndex) const;
    int FindStringExact(int nIndexStart, LPCTSTR lpszFind) const;
    int GetCaretIndex() const;
    int SetCaretIndex(int nIndex, BOOL bScroll = TRUE);

    // Operations
    // manipulating listbox items
    int AddString(LPCTSTR lpszItem);
    int DeleteString(UINT nIndex);
    int InsertString(int nIndex, LPCTSTR lpszItem);
    void ResetContent();
    int Dir(UINT attr, LPCTSTR lpszWildCard);

    // selection helpers
    int FindString(int nStartAfter, LPCTSTR lpszItem) const;
    int SelectString(int nStartAfter, LPCTSTR lpszItem);
    int SelItemRange(BOOL bSelect, int nFirstItem, int nLastItem);

    // Overridables (must override draw, measure and compare for owner draw)
    virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
    virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
    virtual int CompareItem(LPCOMPAREITEMSTRUCT lpCompareItemStruct);
    virtual void DeleteItem(LPDELETEITEMSTRUCT lpDeleteItemStruct);
    virtual int VKeyToItem(UINT nKey, UINT nIndex);
    virtual int CharToItem(UINT nKey, UINT nIndex);

    // Implementation
    public:
    virtual ~CListBox();
    protected:
    virtual BOOL OnChildNotify(UINT, WPARAM, LPARAM, LRESULT*);
    };

    ///////

    CDialog::OnInitDialog();
    m_listCtrl.SetExtendedStyle(m_listCtrl.GetExtendedStyle()|LVS_EX_GRIDLINES);
    m_listCtrl.InsertColumn(0,"编号",LVCFMT_LEFT,70);
    m_listCtrl.InsertColumn(1,"姓名",LVCFMT_LEFT,80);
    m_listCtrl.InsertColumn(2,"职位",LVCFMT_LEFT,100);
    return TRUE;

    ////////

    class CListBox : public CWnd
    {
    DECLARE_DYNAMIC(CListBox)

    ////////

    CDialog::OnInitDialog();
    m_listCtrl.SetExtendedStyle(m_listCtrl.GetExtendedStyle()|LVS_EX_GRIDLINES);
    m_listCtrl.InsertColumn(0,"编号",LVCFMT_LEFT,70);
    m_listCtrl.InsertColumn(1,"姓名",LVCFMT_LEFT,80);
    m_listCtrl.InsertColumn(2,"职位",LVCFMT_LEFT,100);
    return TRUE;

    ///////

    2015年11月20日 14:55
  • 有人知道是什么原因吗???
    2015年11月22日 15:18