首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

打不开头文件的有关问题

2012-06-11 
打不开头文件的问题我按着书上步骤弄了对话框,但是编译的时候出现:D:\WINDOWS\vc++学习\实验0\EX_Ctrls\EX

打不开头文件的问题
我按着书上步骤弄了对话框,但是编译的时候出现:D:\WINDOWS\vc++学习\实验0\EX_Ctrls\EX_CtrlsDlg.cpp(8) : fatal error C1083: Cannot open include file: 'StuInfoDlg.h': No such file or directory



// EX_CtrlsDlg.cpp : implementation file
//

#include "stdafx.h"
#include "EX_Ctrls.h"
#include "EX_CtrlsDlg.h"
#include "CourseDlg.h"
#include "StuInfoDlg.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()

/////////////////////////////////////////////////////////////////////////////
// CEX_CtrlsDlg dialog

CEX_CtrlsDlg::CEX_CtrlsDlg(CWnd* pParent /*=NULL*/)
: CDialog(CEX_CtrlsDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CEX_CtrlsDlg)
// 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 CEX_CtrlsDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEX_CtrlsDlg)
DDX_Control(pDX, IDC_LIST1, m_List);
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CEX_CtrlsDlg, CDialog)
//{{AFX_MSG_MAP(CEX_CtrlsDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON_COURSE, OnButtonCourse)
ON_BN_CLICKED(IDC_BUTTON_STUINFO, OnButtonStuinfo)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEX_CtrlsDlg message handlers

BOOL CEX_CtrlsDlg::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 CEX_CtrlsDlg::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 CEX_CtrlsDlg::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 CEX_CtrlsDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}

void CEX_CtrlsDlg::OnButtonCourse() //从这里开始是自己按着书上的添加的程序{
  CCourseDlg dlg;
if(IDOK!=dlg.DoModal()) return;
while(m_List.GetCount()!=0) m_List.DeleteString(0);
m_List.AddString("课程号:"+dlg.m_strNO);
  m_List.AddString("课程名称:"+dlg.m_strName);
  m_List.AddString("所属专业:"+dlg.m_strSpecial);
  m_List.AddString("课程类型:"+dlg.m_strType);
  CString str;
str.Format("开课学期:%d",dlg.m_nOpen);
m_List.AddString(str);
str.Format("课时数:%d",dlg.m_nHours);
m_List.AddString(str);
str.Format("学分:%4.1f",dlg.m_fCredit);
  m_List.AddString(str);
}

void CEX_CtrlsDlg::OnButtonStuinfo() 
{
CStuInfoDlg dlg;
if(IDOK!=dlg.DoModal()) return;
while(m_List.GetCount()!=0) m_List.DeleteString(0);
  CString strSex("女");
if(dlg.bMale) strSex="男";
  m_List.AddString("姓名:"+dlg.m_strName);
  m_List.AddString("学号:"+dlg.m_strNO);
  m_List.AddString("性别:"+dlg.m_strSex);
  m_List.AddString("出生年月:"+dlg.m_tBirth.Format("%Y-%m-%d"));
  m_List.AddString("所学专业:"+dlg.m_strSpecial);
}



请高手们帮忙看看,忙了一上午,最后不能编译郁闷死了


[解决办法]
程序中有没有这个'StuInfoDlg.h'头文件?
[解决办法]
你把这个'StuInfoDlg.h'加入到工程里面了没?
[解决办法]
工程里面。左面的列表里,看看有没有,没有就头文件夹那里,右键,增加,存在文件。加进去


[解决办法]
.h不一定需要加到工程里,和使用者在一个目录下也是可以找到的。
跟EX_CtrlsDlg.cpp一个目录下也行。

这是简单的做法,只是针对一个源文件,如果有多个源文件都使用,且源文件又不是处在同一个目录,
这个方法就不行了。
[解决办法]
主要是头文件路径问题:

1.与CPP在同一路径可以
2.增加头文件INCLUDE路径,对于VC6,在TOOLS->OPTIONS->DIRECTORIES,添加include路径即可,将你的头文件放在该路径下

热点排行