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

如何解决fatal error C1083

2012-09-24 
怎么解决fatal error C1083:#include stdafx.h#include resource.h#include time.h#includetime.h

怎么解决fatal error C1083:
#include "stdafx.h"
#include "resource.h"
#include "time.h"
#include<time.h>
#define MAX_LOADSTRING 100
#define WM_TIMET_CLOCK WM_USER+20
#define WM_CLOCK_INTERVAL 1000
HINSTANCE hInst;
TCHAR szTitle[MAX_LOADSTRING];
TCHAR szWindowClass[MAX_LOADSTRING];
struct tm *newdate;
time_t long_date;
TCHAR szTimerTitle[MAX_LOADSTRING];
ATOM MyregisterClass(HINSTANCE hInstance);

BOOL InitInstance(HINSTANCE,int);
LRESULT CALLBACK WinProc(HWND , UINT ,WPARAM , LPARAM);
LRESULT CALLBACK About(HWND , UINT ,WPARAM , LPARAM);

//主函数
Int APIENTRY WinMain(HINSTANCE hInstance, 
HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
{
MSG msg;
HACCEL hAccelTable;
LoadString (hInstance,IDS_APP_TITLE,szTitle,MAX_LOADSTRING);
LodString(hInstance,IDC_WINAPPSAMPLE,szWindowClass,MAX_LOADSTRING);
MyRigisterClass(hInstance);
if (!InitInstance(hInstance,nCmdShow)) return FALSE;
hAccelTable=LoadAccelerator(hInsstance,(LPCTSTR)IDC_WINAPPSAMPLE);
while((GetMessage(&msg,NULL,0,0))
{
  If(!TranslateAccelerator(msg.hwnd,hAccelTable,&msg))
  { 
  TranslateMessage(&msg);
  DispatchMessage(&msg)
}
  }
return msg.wParam;
}
ATOM MyRegisterClass(HINSTANCE hInstance)
{
  WNDCLASSEX wcex;
  wcex.cbSize=sizeof(WNDCLASSEX);
  wcex.style=CS_HREDRAW | CS_BREDRAW;
  wcex.lpfnWndPric=(WNDPROC)WndProc;
wcex.cbClsExtra=0;
  wcex.cbWndExtra=0;
  wcex.hIstance=hInstance;
  wcex.hIcon=LoadIcon(hInstance,(LPCTSTR) IDI_WINAPPSAMPLE);
  wcex.hCursor=LoadCusor(NULL,IDC_ARROW);
  wcex.hbrBackground=(HBRUSH)(COLOR_WINDOW+1);
  wcex.lpszMenuName=(LPCSTR) IDC_WINAPPSAMPLE;
  wcex.lpszClassName=szWindowClass;
  wcex.hIconSm=LoadIcon(wcex.hInstance,(LPCTSTR) IDI_SMALL);
  return RegisterClassEx(&wcex);
}
BOOL InitInstance (HINSTANCE hInstance,int nCmdShow)
{
  HMND hWnd;
  hInst =hInstance;
  hWnd=CreateWindow(szWindowClass,szTitle ,WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,0,CW_USEDEFAULT,0,NULL,NULL,hInstance,NULL);
If(!hwnd) return FALSE;
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
SetTimer(hWnd,WM_TIMER_CLOCK,WM_CLOCK_INTERVAL,NULL);
return TRUE;
}
LRESULT CALLBACK WinProc
(HWND hWnd, UINT message,
 WPARAM wParam, LPARAM lParam
)
{
switch(message)
{
  case WM_TIMER:
  if (wParam==WM_TIMER_Clock)
{
time(&long_date);
newdate=localtime(&long_date);
memset(szTimerTitle,0,sizeof(szTimerTitle));
strcpy(szTimerTitle,asctime(newdate));
UpdateWindow(hWnd);
}
  break;
}
  return 0;
}
LRESULT CALLBACK About (HWND hDlg,UINT message,WPRAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_INITDIALOG:return TRUE;
case WM_CONMAND;
if (LOWORD(wParam)==IDOK || LOWORD(wParam)==IDCANCEL)
{
EndDialog(hDlg,LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}
Configuration: FHHH - Win32 Debug--------------------
Compiling...
FHHH.CPP
e:\microsoft visual studio英文版\myprojects\hfgfx\fhhh.cpp(1) : fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
执行 cl.exe 时出错.

FHHH.OBJ - 1 error(s), 0 warning(s)


[解决办法]
是找不到:'stdafx.h'这个头文件


你可以再其他成功编译的MFC程序下,拷贝一个'stdafx.h'到你当前的工程目录下

热点排行