| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 545 人关注过本帖
标题:C++MFC问题
只看楼主 加入收藏
张丹
Rank: 2
等 级:论坛游民
帖 子:94
专家分:66
注 册:2010-6-7
结帖率:42.86%
收藏
已结贴  问题点数:15 回复次数:2 
C++MFC问题
我在MFC中定义了string    m_strText;但是报错了
d:\example\titlebutton\ncbutton.h(39) : error C2146: syntax error : missing ';' before identifier 'm_strText'
d:\example\titlebutton\ncbutton.h(39) : error C2501: 'string' : missing storage-class or type specifiers
各位帮帮忙看看是怎么回事?
搜索更多相关主题的帖子: MFC 
2010-09-13 09:08
红色警戒
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:19
帖 子:444
专家分:2967
注 册:2005-11-20
收藏
得分:15 
看看这行的前后行是否漏掉了';'

2010-09-13 09:56
张丹
Rank: 2
等 级:论坛游民
帖 子:94
专家分:66
注 册:2010-6-7
收藏
得分:0 
// NCButton.h: interface for the CNCButton class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_NCBUTTON_H__F74B28E4_0F45_4E80_B6C4_59FD5968D2AA__INCLUDED_)
#define AFX_NCBUTTON_H__F74B28E4_0F45_4E80_B6C4_59FD5968D2AA__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


// #include <iostream.h>
// #include <string>
// #include <stdio.h>
// using namespace std;


// 对齐方式
#define ALIGN_LEFT                0x0001
#define ALIGN_TOP                0x0002
#define ALIGN_RIGHT                0x0004
#define ALIGN_BOTTOM            0x0008

// 按钮状态
#define BTNSTATE_NORMAL            0x0000        // 正常
#define BTNSTATE_MOUSEOVER        0x0001        // 鼠标在上面
#define BTNSTATE_LBUTTONDOWN    0x0002        // 鼠标左键按下

// 按钮位图
#define BTNBMP_NORMAL            0x0000
#define BTNBMP_MOUSEOVER        0x0001
#define BTNBMP_LBUTTONDOWN        0x0002

class CNCButton
{
private:
    HWND    m_hParentWnd;            // 父窗口句柄
    UINT    m_nID;                    // 按钮ID
    RECT    m_Rect;                    // 按钮具体位置
    SIZE    m_sizeBtn;                // 尺寸
    POINT    m_ptOffset;                // 位置
    BOOL    m_bCreated;                // 创建成功的标志
    string    m_strText;                // 按钮文字
    string  m_strTooltip;            // 工具提示
    UINT    m_nAlign;                // 对齐方式
    UINT    m_nState;                // 状态
    UINT    m_nBmpNormal;            // 正常时候的位图ID
    UINT    m_nBmpHover;            // 热点位图ID
    UINT    m_nBmpDown;                // 按下时的位图ID
    HFONT    m_hFont;                // 字体
    HWND    m_hTooltip;                // 工具提示

public:
    void    SetTooltip(LPCTSTR lpszText);
    void    ShowTooltip(BOOL bShow);
    void    SetText(LPCTSTR lpszText, LPCTSTR lpszFont, int nSize, BYTE lfCharSet = GB2312_CHARSET);
    void    SetButtonBitmap(UINT nBmpID, UINT nCase);
    void    DrawTransparentBmp(HDC hdc, int nXOriginDest, int nYOriginDest, int nWidth, int nHeight, WORD wBmpID, COLORREF crTransparent);
    void    FillSolidRect(HDC hdc, int x, int y, int cx, int cy, COLORREF clr);
    void    Draw3dRect(HDC hdc, LPRECT lpRect, COLORREF clrTopLeft, COLORREF clrBottomRight );
    UINT    GetButtonID() { return m_nID; }
    UINT    GetState() { return m_nState; }
    void    SetState(UINT nState) { m_nState = nState;    }
    HWND    GetParentWnd() { return m_hParentWnd; }
    BOOL    OnHitTest(POINT point);
    void    SetAlign(UINT nAlign);
    BOOL    Create(LPCTSTR lpszText, HWND hParentWnd, POINT& ptOffset, SIZE& sizeBtn, UINT nID);
    BOOL    IsCreated() { return m_bCreated; }
    void    OnPaint();

    CNCButton();

    virtual void OnSetCursor();
    virtual void OnParentSize(UINT nSide, LPRECT lpRect );
    virtual void OnPaintDown(HDC hdc);
    virtual void OnPaintHover(HDC hdc);
    virtual void OnPaintNormal(HDC hdc);
    virtual void OnMouseMove(POINT point);
    virtual void OnMouseLButtonDown();
    virtual void OnMouseLButtonUp();
    virtual void OnMouseClick();
    virtual void OnMouseLeave();
    virtual ~CNCButton();

};

#endif // !defined(AFX_NCBUTTON_H__F74B28E4_0F45_4E80_B6C4_59FD5968D2AA__INCLUDED_)


这是.h文件。
在网上查了说是没有引用
// #include <iostream.h>
// #include <string>
// #include <stdio.h>
// using namespace std;
这些头文件,我添上了,但是还报错
2010-09-13 12:53
快速回复:C++MFC问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013936 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved