| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 810 人关注过本帖
标题:MFC连接数据库提示已存在windows.h
只看楼主 加入收藏
lorject
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2011-9-19
结帖率:0
收藏
已结贴  问题点数:20 回复次数:2 
MFC连接数据库提示已存在windows.h
  就是一个很简单的程序,通过一个对话框中的按钮调出其他对话框,功能还没实现,连接数据库的时候就出现了atal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>
这个问题,可是我头文件中并没有包含这个库啊。。
程序代码:
// car_arrangeDlg.cpp : implementation file
//

#include "stdafx.h"
#include "car_arrange.h"
#include "car_arrangeDlg.h"
#include "car_equ.h"
#include "car_ins.h"
#include "good_equ.h"
#include "good_ins.h"
#include "car_arr.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

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

// Dialog Data
    //{{AFX_DATA(CAboutDlg)
    enum { IDD = IDD_ABOUTBOX };
    //}}AFX_DATA

    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CAboutDlg)
    protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
    //}}AFX_VIRTUAL

// Implementation
protected:
    //{{AFX_MSG(CAboutDlg)
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
};

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

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(CAboutDlg)
    //}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
    //{{AFX_MSG_MAP(CAboutDlg)
        // No message handlers
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCar_arrangeDlg dialog

CCar_arrangeDlg::CCar_arrangeDlg(CWnd* pParent /*=NULL*/)
    : CDialog(CCar_arrangeDlg::IDD, pParent)
{
    //{{AFX_DATA_INIT(CCar_arrangeDlg)
        // NOTE: the ClassWizard will add member initialization here
    //}}AFX_DATA_INIT
    // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
    m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CCar_arrangeDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(CCar_arrangeDlg)
        // NOTE: the ClassWizard will add DDX and DDV calls here
    //}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CCar_arrangeDlg, CDialog)
    //{{AFX_MSG_MAP(CCar_arrangeDlg)
    ON_WM_SYSCOMMAND()
    ON_WM_PAINT()
    ON_WM_QUERYDRAGICON()
    ON_BN_CLICKED(car_equries_botton, Onequriesbotton)
    ON_BN_CLICKED(car_insert_botton, Oninsertbotton)
    ON_BN_CLICKED(car_arranged_botton, Onarrangedbotton)
    ON_BN_CLICKED(good_equries, Onequries)
    ON_BN_CLICKED(good_insert, Oninsert)
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCar_arrangeDlg message handlers

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

    // Add "About..." menu item to system menu.

    // IDM_ABOUTBOX must be in the system command range.
    ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
    ASSERT(IDM_ABOUTBOX < 0xF000);

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

    // Set the icon for this dialog.  The framework does this automatically
    //  when the application's main window is not a dialog
    SetIcon(m_hIcon, TRUE);            // Set big icon
    SetIcon(m_hIcon, FALSE);        // Set small icon
   
    // TODO: Add extra initialization here
   
    return TRUE;  // return TRUE  unless you set the focus to a control
}

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

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CCar_arrangeDlg::OnPaint()
{
    if (IsIconic())
    {
        CPaintDC dc(this); // device context for painting

        SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

        // Center icon in client rectangle
        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;

        // Draw the icon
        dc.DrawIcon(x, y, m_hIcon);
    }
    else
    {
        CDialog::OnPaint();
    }
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CCar_arrangeDlg::OnQueryDragIcon()
{
    return (HCURSOR) m_hIcon;
}

void CCar_arrangeDlg::Onequriesbotton()
{
    // TODO: Add your control notification handler code here
    car_equ car_equ_a;
car_equ_a.DoModal();
}

void CCar_arrangeDlg::Oninsertbotton()
{
    // TODO: Add your control notification handler code here
car_ins car_ins_a;
    car_ins_a.DoModal();   
}

void CCar_arrangeDlg::Onarrangedbotton()
{
    // TODO: Add your control notification handler code here
    car_arr car_arr_a;
car_arr_a.DoModal();   
}

void CCar_arrangeDlg::Onequries()
{
    // TODO: Add your control notification handler code here
        good_equ good_equ_a;
    good_equ_a.DoModal();
}

void CCar_arrangeDlg::Oninsert()
{
    // TODO: Add your control notification handler code here
good_ins good_ins_a;
        good_ins_a.DoModal();   
}




还有stdafx.h的代码



// stdafx.h : include file for standard system include files,
//  or project specific include files that are used frequently, but
//      are changed infrequently
//

#if !defined(AFX_STDAFX_H__752BE8A5_0834_4B62_9AFD_7C93EC174C75__INCLUDED_)
#define AFX_STDAFX_H__752BE8A5_0834_4B62_9AFD_7C93EC174C75__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include<winsock.h>
#include<iostream>
#include<string>
#include <mysql.h>
using namespace std;
#pragma comment(lib,"ws2_32.lib")
#pragma comment(lib,"libmysql.lib")

#define VC_EXTRALEAN        // Exclude rarely-used stuff from Windows headers
#include <afxwin.h>         // MFC core and standard components
#include <afxext.h>         // MFC extensions
#include <afxdisp.h>        // MFC Automation classes
#include <afxdtctl.h>        // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>            // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT


//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_STDAFX_H__752BE8A5_0834_4B62_9AFD_7C93EC174C75__INCLUDED_)
。。

求大神指教啊 。。。。小白一个。。求问题。。。

搜索更多相关主题的帖子: 连接数据库 included already 
2013-05-12 00:58
邓士林
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:淮河河畔
等 级:贵宾
威 望:61
帖 子:2392
专家分:13384
注 册:2013-3-3
收藏
得分:20 
MFC框架的项目中不要#include <windows.h>而要用#include <afxwin.h>,MFC中已经存在了#include <windows.h>

Maybe
2013-05-12 11:20
lorject
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2011-9-19
收藏
得分:0 
回复 2楼 邓士林
可是我没有包含windows.h啊
2013-05-12 16:44
快速回复:MFC连接数据库提示已存在windows.h
数据加载中...
 
   



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

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