春哥被击败:一个windows编程的问题....

来源:百度文库 编辑:高校问答 时间:2024/04/30 00:45:31
头文件是”simpwin.h”
LRESULT CALLBACK MainWndPro(HWND,UINT,WPARAM,LPARAM);
BOOL InitApplication(HINSTANCE);
BOOL InitInstance(HINSTANCE,int);
char *hello="窗口外的世界很精彩,窗口内的天地很奇妙";

主文件是
#include<windows.h>
#include<string.h>
#include "simpwin.h"

HINSTANCE hInst;
HWND hWndMain;

int APIENTRY WinMain(
HINSTANCE hInstance,
HINSTANCE hPreInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MSG msg;
if(!InitApplication(hInstance))
return(FALSE);
if(!InitInstance(hInstance,nCmdShow))
return(FALSE);
while(Getmessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return(msg,wParam);
}
BOOL InitApplication(HINSTANCE hInstance)
{
WNDCLASS wcSimpwin;
wcSimpwin.style=0;
wcSimpwin.lpfnWndProc=(WNDPROC)MainWndProc;
wcSimpwin.cbClsExtra=0;
wcSimpwin.cbWndExtra=0;
wcSimpwin.hInstance=hInstance;
wcSimpwin.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wcSimpwin.hCursor=LoadCursor(NULL,IDC_ARROW);
wcSimpwin.hbrBackground=GETSTOCKOBJIECT(WHITE_BRUSH);
wcSimpwin.lpszMenuName=NULL;
wcSimpwin.lpszClassName="SimpwinWClass";
return(RegisterClass)(&wcSimpwin));

}

BOOL InitInstance(HINSTANCE hInstance,int nCmdShow)
{
hInst=hInstance;
hWndMain=CreateWindow("SimpwinWClass","我的窗口",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);
if(!hWndMain)
return(FAULSE);
ShowWindow(hWndMain,nCmdShow);
UpdateWindow(hWndMain);

return(TURE);
}

LRESULT CALLBACK MainWndProc(HWND hWnd,UNIT message,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
switch(message)
{
case WM_PAINT:
hdc=BeginPaint(hWnd,&ps);
TextOut(hdc,20,10,hello,lstrlen(hello));
EndPaint(hWnd,&ps);
break;

case WM_destroy:
PostQuiteMessage(0);
break;
default:
return(DefWindowPro(hWnd,message,wParam,lParam));
}
return(0);
}

我编译后有错误:
d:\program files\microsoft visual studio\myprojects\sfg\simpwin.h(4) : error C2018: unknown character '0xa3'
d:\program files\microsoft visual studio\myprojects\sfg\simpwin.h(4) : error C2018: unknown character '0xbb'
D:\Program Files\Microsoft Visual Studio\MyProjects\sfg\asdf.cpp(5) : error C2146: syntax error : missing ';' before identifier 'HINSTANCE'
D:\Program Files\Microsoft Visual Studio\MyProjects\sfg\asdf.cpp(5) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

asdf.obj - 4 error(s), 0 warning(s)
前两个错误发生在char *hello="窗口外的世界很精彩,窗口内的天地很奇妙";这一行

后两个错误发生在 HINSTANCE hInst;这一行

请问怎么改?

根据错误信息:
simpwin.h(4)
char *hello="窗口外的世界很精彩,窗口内的天地很奇妙";
最后一个分号,应该是英文的分号 ; 而不是中文的分号 ;
错误应该全部发生在这个地方.

不错