(CPP)MFC应用程序里不能添加自己的类
phpskycn2009/08/08软件综合 IP:浙江
随便添加个类
class a{
public:
void a;}
编译就会报出几十个错误(全部都出在是VS自动生成的代码)
去掉自己添加的类就一切正常。
。。。。。。。。。。
难道要我去装个2008?
来自:计算机科学 / 软件综合
4
已屏蔽 原因:{{ notice.reason }}已屏蔽
{{notice.noticeContent}}
~~空空如也
phpskycn 作者
14年11个月前 IP:未同步
138113
// CFGSDlg.cpp : 实现文件
//

#include "stdafx.h"
#include "CFGS.h"
#include "CFGSDlg.h"

//=======================================================================================

#ifdef _DEBUG
#define new DEBUG_NEW
#endif
class palatte
{
public:
         double x ;
         double y ;
         double x1 ;
         double x2 ;
         COLORREF color ;
         COLORREF colorX ;
         int clr ;
         palatte(void){
             x = 400;
             y = 300;
             x1 = 400;
             x2 = 400;
             hDC = ::GetDC(null);
             color = null;
             colorX = null;
             clr = null;
         }

int GetAColor(double x,double y,int a){
     color = ::GetPixel(hDC, x, y);
    switch(a){
        case 1:
            clr =  GetBValue(color);
        case 2:
            clr =  GetGValue(color);
        case 3:
            clr =  GetRValue(color);
    }
    return clr;
}
void cf(){
    color = ::GetPixel(hDC, 400, 300);
    if((GetBValue(color))<100){
        while( GetAColor(x1,300,1)<100){
            x1++;
        }
        while( GetAColor(x1,300,1)<100){
            x2--;
        }
             x=(x1)/2+(x2)/2;
    while(GetAColor(x,y,1)<100){
        y++;
    }}
     mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, (x-1), (y-1), 0, 0);
    return;

    ~palatte(void);
}

// 用于应用程序“关于”菜单项的 CAboutDlg 对话框

class CAboutDlg : public CDialog
{
public:
    CAboutDlg();

// 对话框数据
    enum { IDD = IDD_ABOUTBOX };

    protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持

// 实现
protected:
    DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}

void CAboutDlg:[s:3]oDataExchange(CDataExchange* pDX)
{
    CDialog:[s:3]oDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()


// CCFGSDlg 对话框




CCFGSDlg::CCFGSDlg(CWnd* pParent /*=NULL*/)
    : CDialog(CCFGSDlg::IDD, pParent)
{
    m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CCFGSDlg:[s:3]oDataExchange(CDataExchange* pDX)
{
    CDialog:[s:3]oDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CCFGSDlg, CDialog)
    ON_WM_SYSCOMMAND()
    ON_WM_PAINT()
    ON_WM_QUERYDRAGICON()

    //}}AFX_MSG_MAP
    ON_BN_CLICKED(IDOK, &CCFGSDlg::OnBnClickedOk)
    ON_WM_TIMER()
    ON_BN_CLICKED(IDOK2, &CCFGSDlg::OnBnClickedOk2)
END_MESSAGE_MAP()


// CCFGSDlg 消息处理程序

BOOL CCFGSDlg::OnInitDialog()
{
    CDialog::OnInitDialog();

    // 将“关于...”菜单项添加到系统菜单中。

    // IDM_ABOUTBOX 必须在系统命令范围内。
    ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
    ASSERT(IDM_ABOUTBOX < 0xF000);

    CMenu* pSysMenu = GetSystemMenu(FALSE);
    if (pSysMenu != NULL)
    {
        CString strAboutMenu;
        strAboutMenu.LoadString(IDS_ABOUTBOX);
        if (!XXXXXXXXXXXXXXXEmpty())
        {
            pSysMenu->AppendMenu(MF_SEPARATOR);
            pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
        }
    }

    // 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
    //  执行此操作
    SetIcon(m_hIcon, TRUE);            // 设置大图标
    SetIcon(m_hIcon, FALSE);        // 设置小图标

    // TODO: 在此添加额外的初始化代码

    return TRUE;  // 除非将焦点设置到控件,否则返回 TRUE
}

void CCFGSDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
    if ((nID & 0xFFF0) == IDM_ABOUTBOX)
    {
        CAboutDlg dlgAbout;
        XXXXXXXXXXXModal();
    }
    else
    {
        CDialog::OnSysCommand(nID, lParam);
    }
}

// 如果向对话框添加最小化按钮,则需要下面的代码
//  来绘制该图标。对于使用文档/视图模型的 MFC 应用程序,
//  这将由框架自动完成。

void CCFGSDlg::OnPaint()
{
    if (IsIconic())
    {
        CPaintDC dc(this); // 用于绘制的设备上下文

        SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(XXXXXtSafeHdc()), 0);

        // 使图标在工作矩形中居中
        int cxIcon = GetSystemMetrics(SM_CXICON);
        int cyIcon = GetSystemMetrics(SM_CYICON);
        CRect rect;
        GetClientRect(&rect);
        int x = (rect.Width() - cxIcon + 1) / 2;
        int y = (rect.Height() - cyIcon + 1) / 2;

        // 绘制图标
        dc.DrawIcon(x, y, m_hIcon);
    }
    else
    {
        CDialog::OnPaint();
    }
}

//当用户拖动最小化窗口时系统调用此函数取得光标显示。
//
HCURSOR CCFGSDlg::OnQueryDragIcon()
{
    return static_cast<HCURSOR>(m_hIcon);
}




void CCFGSDlg::OnBnClickedOk()
{
    CWnd::SetTimer(731,20,NULL);
        AfxMessageBox(L"程序已经启动!");
    // OnOK();
}

void CCFGSDlg::OnTimer(UINT_PTR nIDEvent)
{
    cf();
    CDialog::OnTimer(nIDEvent);

}

void CCFGSDlg::OnBnClickedOk2()
{
    CWnd::KillTimer(731);
    AfxMessageBox(L"程序已经停止运行!");
}
引用
评论
加载评论中,请稍候...
200字以内,仅用于支线交流,主线讨论请采用回复功能。
折叠评论
phpskycn作者
14年11个月前 IP:未同步
138114
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(67) : error C2236: unexpected 'class' 'CAboutDlg'. Did you forget a ';'?
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(67) : error C2143: syntax error : missing ';' before ':'
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(23) : error C2059: syntax error : ':'
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(28) : error C2065: 'hDC' : undeclared identifier
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(28) : error C2065: 'null' : undeclared identifier
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(59) : warning C4244: 'argument' : conversion from 'double' to 'DWORD', possible loss of data
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(59) : warning C4244: 'argument' : conversion from 'double' to 'DWORD', possible loss of data
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(62) : error C2144: syntax error : 'void' should be preceded by ')'
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(62) : error C2675: unary '~' : 'palatte' does not define this operator or a conversion to a type acceptable to the predefined operator
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(62) : error C2059: syntax error : ')'
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(67) : error C2059: syntax error : 'public'
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(68) : error C2143: syntax error : missing ';' before '{'
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(68) : error C2447: '{' : missing function header (old-style formal list?)
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(83) : error C2653: 'CAboutDlg' : is not a class or namespace name
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(83) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(83) : error C2653: 'CAboutDlg' : is not a class or namespace name
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(83) : error C2065: 'IDD' : undeclared identifier
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(84) : error C2550: 'CAboutDlg' : constructor initializer lists are only allowed on constructor definitions
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(85) : warning C4508: 'CAboutDlg' : function should return a value; 'void' return type assumed
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(87) : error C2653: 'CAboutDlg' : is not a class or namespace name
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(89) : error C2248: 'CWnd:[s:3]oDataExchange' : cannot access protected member declared in class 'CWnd'
        c:\\program files\\microsoft visual studio 8\\vc\\atlmfc\\include\\afxwin.h(2700) : see declaration of 'CWnd:[s:3]oDataExchange'
        c:\\program files\\microsoft visual studio 8\\vc\\atlmfc\\include\\afxwin.h(1967) : see declaration of 'CWnd'
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(89) : error C2352: 'CWnd:[s:3]oDataExchange' : illegal call of non-static member function
        c:\\program files\\microsoft visual studio 8\\vc\\atlmfc\\include\\afxwin.h(2700) : see declaration of 'CWnd:[s:3]oDataExchange'
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(92) : error C2653: 'CAboutDlg' : is not a class or namespace name
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(92) : error C2270: 'GetMessageMap' : modifiers not allowed on nonmember functions
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(92) : error C3861: 'GetThisMessageMap': identifier not found
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(92) : error C2653: 'CAboutDlg' : is not a class or namespace name
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(92) : error C2365: 'GetThisMessageMap' : redefinition; previous definition was 'formerly unknown identifier'
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(92) : error C2146: syntax error : missing ';' before identifier 'ThisClass'
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(92) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(92) : error C2065: 'ThisClass' : undeclared identifier
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(93) : error C2248: 'CDialog::GetThisMessageMap' : cannot access protected member declared in class 'CDialog'
        c:\\program files\\microsoft visual studio 8\\vc\\atlmfc\\include\\afxwin.h(2950) : see declaration of 'CDialog::GetThisMessageMap'
        c:\\program files\\microsoft visual studio 8\\vc\\atlmfc\\include\\afxwin.h(2852) : see declaration of 'CDialog'
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(162) : error C2146: syntax error : missing ';' before identifier 'dlgAbout'
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(162) : warning C4551: function call missing argument list
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(162) : error C2065: 'dlgAbout' : undeclared identifier
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(163) : error C2228: left of '.DoModal' must have class/struct/union
        type is ''unknown-type''
c:\\william\\visual studio\\cfgs\\cfgs\\cfgsdlg.cpp(219) : error C3861: 'cf': identifier not found
palatte.cpp
c:\\william\\visual studio\\cfgs\\cfgs\\palatte.h(12) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\\william\\visual studio\\cfgs\\cfgs\\palatte.h(21) : warning C4183: 'palette': missing return type; assumed to be a member function returning 'int'
c:\\william\\visual studio\\cfgs\\cfgs\\palatte.cpp(11) : fatal error C1075: end of file found before the left brace '{' at 'c:\\william\\visual studio\\cfgs\\cfgs\\palatte.h(4)' was matched
Generating Code...
生成日志保存在“file://c:\\William\\Visual studio\\CFGS\\CFGS\\Debug\\XXXXXXXXXXXm”
CFGS - 34 个错误,5 个警告
========== 生成: 0 已成功, 1 已失败, 0 最新, 0 已跳过 ==========
引用
评论
加载评论中,请稍候...
200字以内,仅用于支线交流,主线讨论请采用回复功能。
折叠评论
93°
14年11个月前 IP:未同步
138117
接分升星
引用
评论
加载评论中,请稍候...
200字以内,仅用于支线交流,主线讨论请采用回复功能。
折叠评论
phpskycn作者
14年11个月前 IP:未同步
138120
算了换个地方问
这里除了大叔外,会CPP的太少了
引用
评论
加载评论中,请稍候...
200字以内,仅用于支线交流,主线讨论请采用回复功能。
折叠评论

想参与大家的讨论?现在就 登录 或者 注册

所属专业
上级专业
同级专业
phpskycn
专家 老干部 学者 机友 笔友
文章
402
回复
4591
学术分
8
2009/03/15注册,4天9时前活动

CV

主体类型:个人
所属领域:无
认证方式:手机号
IP归属地:未同步
文件下载
加载中...
{{errorInfo}}
{{downloadWarning}}
你在 {{downloadTime}} 下载过当前文件。
文件名称:{{resource.defaultFile.name}}
下载次数:{{resource.hits}}
上传用户:{{uploader.username}}
所需积分:{{costScores}},{{holdScores}}下载当前附件免费{{description}}
积分不足,去充值
文件已丢失

当前账号的附件下载数量限制如下:
时段 个数
{{f.startingTime}}点 - {{f.endTime}}点 {{f.fileCount}}
视频暂不能访问,请登录试试
仅供内部学术交流或培训使用,请先保存到本地。本内容不代表科创观点,未经原作者同意,请勿转载。
音频暂不能访问,请登录试试
支持的图片格式:jpg, jpeg, png
插入公式
评论控制
加载中...
文号:{{pid}}
投诉或举报
加载中...
{{tip}}
请选择违规类型:
{{reason.type}}

空空如也

加载中...
详情
详情
推送到专栏从专栏移除
设为匿名取消匿名
查看作者
回复
只看作者
加入收藏取消收藏
收藏
取消收藏
折叠回复
置顶取消置顶
评学术分
鼓励
设为精选取消精选
管理提醒
编辑
通过审核
评论控制
退修或删除
历史版本
违规记录
投诉或举报
加入黑名单移除黑名单
查看IP
{{format('YYYY/MM/DD HH:mm:ss', toc)}}