代码如下:
#include"windows.h"
#include"string"
#include"tchar.h"
void WINAPI CaretPos(HWND hWnd,int nArrayPos,char *cCharBuf,int*xCaret,int*yCaret,int nCharWidth );
long WINAPI WndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam);
BOOL InitWindowsClass(HINSTANCE hInstance);
BOOL InitWindows(HINSTANCE hInstance,int nCmdShow);
HWND hWndMain;
static wchar_t lpszclassname[]=_T("shegan");
static wchar_t lpszTitle[]=_T("s");
char line1[]="这是第行";
static wchar_t line2[]=_T("这是第二行");
HDC Hdc;
TEXTMETRIC tm;
HWND hWnd;
PAINTSTRUCT pt;
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
MSG msg;
if(!InitWindowsClass(hInstance))
return FALSE;
if(!InitWindows(hInstance,nCmdShow))
return FALSE;
while(GetMessage(&msg,0,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
long WINAPI WndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
{
WORD x,y;
HCURSOR hCursor;
switch(message)
{
case WM_PAINT:
Hdc=BeginPaint(hWnd,&pt);
SetTextColor(Hdc,RGB(255,0,0));
TextOut(Hdc,60,10,(LPCWSTR)line1,strlen(line1));
//GetTextMetrics(Hdc,&tm);
//SetTextColor(Hdc,RGB(0,0,255));
case WM_MOUSEMOVE:
x=LOWORD(lParam);//取低4位
y=HIWORD(lParam);//取高4位
if(x>=50&&x<=400&&y>=50&&y<=300)
{
if(x>=50&&x<=100&&y>=50&&y<=100)
{
hCursor=LoadCursor(NULL,IDC_CROSS);
SetCursor(hCursor);
}
if(x>=100&&x<=150&&y>=50&&y<=100)
{
hCursor=LoadCursor(NULL,IDC_SIZE);
SetCursor(hCursor);
}
if(x>=150&&x<=200&&y>=50&&y<=100)
{
hCursor=LoadCursor(NULL,IDC_SIZE);
SetCursor(hCursor);
}
if(x>=50&&x<=100&&y>=100&&y<=150)
{
hCursor=LoadCursor(NULL,IDC_SIZENESW);
SetCursor(hCursor);
}
if(x>=250&&x<=400&&y>=100&&y<=150)
{
hCursor=LoadCursor(NULL,IDC_SIZENWSE);
SetCursor(hCursor);
}
if(x>=50&&x<=100&&y>=150&&y<300)
{
hCursor=LoadCursor(NULL,IDC_SIZEWE);
SetCursor(hCursor);
}
if(x>=100&&x<=250&&y>=150&&y<=300)
{
hCursor=LoadCursor(NULL,IDC_UPARROW);
SetCursor(hCursor);
}
if(x>=250&&x<=400&&y>=150&&y<=300)
{
hCursor=LoadCursor(NULL,IDC_WAIT);
SetCursor(hCursor);
}
}
else
{
hCursor=LoadCursor(NULL,IDC_ARROW);
SetCursor(hCursor);//该函数确定光标的形状
}
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return (DefWindowProc(hWnd,message,wParam,lParam));
}
}
BOOL InitWindowsClass(HINSTANCE hInstance)
{
WNDCLASS wndclass;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.hCursor=LoadCursor(NULL,IDC_UPARROW);
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);//END什么意思
wndclass.hInstance=hInstance;
wndclass.lpfnWndProc=WndProc;
wndclass.lpszClassName=lpszclassname;
wndclass.lpszMenuName=NULL;
wndclass.style=CS_HREDRAW|CS_VREDRAW;//
return RegisterClass(&wndclass);
}
BOOL InitWindows(HINSTANCE hInstance,int nCmdShow)
{
hWnd=CreateWindow(
lpszclassname,
lpszTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
0,
CW_USEDEFAULT,
0,
NULL,
NULL,
hInstance,
NULL
);
if(!hWnd)
return FALSE;
hWndMain=hWnd;
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
请问:为什么输出是的汉子不正确?