连接错误,帮我改正一下
代码:#include"windows.h"#include"string.h"#include"stdlib.h"#include"stdio.h"HDChDC;HFO...
代码:
#include"windows.h"
#include"string.h"
#include"stdlib.h"
#include"stdio.h"
HDC hDC;
HFONT CreateFont(HDC hDC,int nCharHeight,BOOL bItalic);
int i=0;
int x[11],y[11];
int color[11];
POINT pt;
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
HDC hdc;
HDC hdcmem;
HBITMAP hBm;
BITMAP bm;
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR lpszCmdLine,int nCmdShow)
{
HWND hwnd;
MSG Msg;
WNDCLASS wndclass;
char lpszClassName[]="图位";
char lpszTitle[]="pi";
wndclass.style=0;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=lpszClassName;
if(!RegisterClass(&wndclass))
{
MessageBeep(0);
return FALSE;
}
hwnd=CreateWindow(lpszClassName,
lpszTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
hBm=LoadBitmap(hInstance,"tiger");
GetObject(hBm,sizeof(BITMAP),(LPVOID)&bm);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&Msg,NULL,0,0))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
PAINTSTRUCT ps;
HFONT hF;
TEXTMETRIC tm;
char str[]="Hellos VC ";
switch(message)
{
case WM_CREATE:
SetTimer(hwnd,1,40,NULL);
GetCursorPos(&pt);
for(i=0;i<11;i++)
{
x[i]=pt.x;
y[i]=pt.y;
color[i]=25*(i-1);
}
hdc=GetDC(hwnd);
hdcmem=CreateCompatibleDC(hdc);
ReleaseDC(hwnd,hdc);
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
SelectObject(hdcmem,hBm);
BitBlt(hdc,180,80,bm.bmWidth,bm.bmHeight,hdcmem,0,0,SRCCOPY);
hF=CreateFont(hDC,40,0);
SelectObject(hDC,hF);
GetTextMetrics(hDC,&tm);
for(i=10;i>1;i--)
{
x[i]=x[i-1]+50;
y[i]=y[i-1];
}
GetCursorPos(&pt);
x[1]=pt.x;
y[1]=pt.y;
for(i=1;i<11;i++)
{
SetTextColor(hDC,RGB(255-color[i],color[i],255));
TextOut(hDC,x[i],y[i],&str[i],1);
}
color[1]=color[10];
for(i=10;i>1;i--)
color[i]=color[i-1];
DeleteObject(hF);
EndPaint(hwnd,&ps);
break;
case WM_DESTROY:
DeleteObject(hBm);
PostQuitMessage(0);
KillTimer(hwnd,1);
break;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0;
}
错误提示:
Compiling...
hao1.cpp
Linking...
hao1.obj : error LNK2001: unresolved external symbol "struct HFONT__ * __cdecl CreateFontA(struct HDC__ *,int,int)" (?CreateFontA@@YAPAUHFONT__@@PAUHDC__@@HH@Z)
Debug/hao1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
hao1.exe - 2 error(s), 0 warning(s) 展开
#include"windows.h"
#include"string.h"
#include"stdlib.h"
#include"stdio.h"
HDC hDC;
HFONT CreateFont(HDC hDC,int nCharHeight,BOOL bItalic);
int i=0;
int x[11],y[11];
int color[11];
POINT pt;
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
HDC hdc;
HDC hdcmem;
HBITMAP hBm;
BITMAP bm;
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR lpszCmdLine,int nCmdShow)
{
HWND hwnd;
MSG Msg;
WNDCLASS wndclass;
char lpszClassName[]="图位";
char lpszTitle[]="pi";
wndclass.style=0;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=lpszClassName;
if(!RegisterClass(&wndclass))
{
MessageBeep(0);
return FALSE;
}
hwnd=CreateWindow(lpszClassName,
lpszTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
hBm=LoadBitmap(hInstance,"tiger");
GetObject(hBm,sizeof(BITMAP),(LPVOID)&bm);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&Msg,NULL,0,0))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
PAINTSTRUCT ps;
HFONT hF;
TEXTMETRIC tm;
char str[]="Hellos VC ";
switch(message)
{
case WM_CREATE:
SetTimer(hwnd,1,40,NULL);
GetCursorPos(&pt);
for(i=0;i<11;i++)
{
x[i]=pt.x;
y[i]=pt.y;
color[i]=25*(i-1);
}
hdc=GetDC(hwnd);
hdcmem=CreateCompatibleDC(hdc);
ReleaseDC(hwnd,hdc);
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
SelectObject(hdcmem,hBm);
BitBlt(hdc,180,80,bm.bmWidth,bm.bmHeight,hdcmem,0,0,SRCCOPY);
hF=CreateFont(hDC,40,0);
SelectObject(hDC,hF);
GetTextMetrics(hDC,&tm);
for(i=10;i>1;i--)
{
x[i]=x[i-1]+50;
y[i]=y[i-1];
}
GetCursorPos(&pt);
x[1]=pt.x;
y[1]=pt.y;
for(i=1;i<11;i++)
{
SetTextColor(hDC,RGB(255-color[i],color[i],255));
TextOut(hDC,x[i],y[i],&str[i],1);
}
color[1]=color[10];
for(i=10;i>1;i--)
color[i]=color[i-1];
DeleteObject(hF);
EndPaint(hwnd,&ps);
break;
case WM_DESTROY:
DeleteObject(hBm);
PostQuitMessage(0);
KillTimer(hwnd,1);
break;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0;
}
错误提示:
Compiling...
hao1.cpp
Linking...
hao1.obj : error LNK2001: unresolved external symbol "struct HFONT__ * __cdecl CreateFontA(struct HDC__ *,int,int)" (?CreateFontA@@YAPAUHFONT__@@PAUHDC__@@HH@Z)
Debug/hao1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
hao1.exe - 2 error(s), 0 warning(s) 展开
1个回答
展开全部
CreateFont(
12, // nHeight
12, // nWidth
0, // nEscapement
0, // nOrientation
FW_NORMAL, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
"Arial");
这是CreateFont的用法
12, // nHeight
12, // nWidth
0, // nEscapement
0, // nOrientation
FW_NORMAL, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
"Arial");
这是CreateFont的用法
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询