主题:why............???????????????????????????
程序要求:在窗口中显示"VC中显示字体与背景"字体为红色,背景为黄色
请帮忙分析:
这是什么错误????????????
Linking...
LINK : fatal error LNK1168: cannot open Debug/VC_FONT.exe for writing
Error executing link.exe.
VC_FONT.exe - 1 error(s), 0 warning(s)
#include<windows.h>
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszCmdParam,int nCmdShow)
{
static char szAppName[]="VC_FONT";
HWND hWnd;
MSG msg;
WNDCLASS WndClass;
if(!hPrevInstance)
{
WndClass.cbClsExtra =0;
WndClass.cbWndExtra =0;
WndClass.hbrBackground =(HBRUSH)(GetStockObject(LTGRAY_BRUSH));
WndClass.hCursor =LoadCursor(NULL,IDC_ARROW);
WndClass.hIcon =LoadIcon(NULL,IDI_APPLICATION);
WndClass.hInstance =hInstance;
WndClass.lpfnWndProc =WndProc;
WndClass.lpszClassName =szAppName;
WndClass.lpszMenuName =0;
WndClass.style =CS_HREDRAW|CS_VREDRAW;
}
hWnd=CreateWindow(szAppName,
"THe Hello Program!",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT,
CW_USEDEFAULT,CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
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)
{
HDC hDC;
PAINTSTRUCT ps;
RECT rect;
static LOGFONT lf;
HFONT holdFont,hnewFont;
switch(Message)
{
case WM_CREATE:
return 0;
case WM_PAINT:
lf.lfHeight =-64;
lf.lfWeight =500;
lf.lfPitchAndFamily =DEFAULT_PITCH&FF_DONTCARE;
lf.lfCharSet =GB2312_CHARSET;
strcpy(lf.lfFaceName ,"黑体");
hnewFont=CreateFontIndirect(&lf);
hDC=BeginPaint(hWnd,&ps);
GetClientRect(hWnd,&rect);
GetClientRect(hWnd,&rect);
holdFont=(HFONT)SelectObject(hDC,hnewFont);
SetTextColor(hDC,RGB(255,0,0));
SetBkColor(hDC,RGB(255,255,0));
DrawText(hDC,
"VC 中显示的字体与背景",
-1,
&rect,
DT_SINGLELINE|DT_CENTER|DT_VCENTER);
SelectObject(hDC,holdFont);
DeleteObject(hnewFont);
EndPaint(hWnd,&ps);
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd,Message,wParam,lParam);
}
请帮忙分析:
这是什么错误????????????
Linking...
LINK : fatal error LNK1168: cannot open Debug/VC_FONT.exe for writing
Error executing link.exe.
VC_FONT.exe - 1 error(s), 0 warning(s)
#include<windows.h>
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszCmdParam,int nCmdShow)
{
static char szAppName[]="VC_FONT";
HWND hWnd;
MSG msg;
WNDCLASS WndClass;
if(!hPrevInstance)
{
WndClass.cbClsExtra =0;
WndClass.cbWndExtra =0;
WndClass.hbrBackground =(HBRUSH)(GetStockObject(LTGRAY_BRUSH));
WndClass.hCursor =LoadCursor(NULL,IDC_ARROW);
WndClass.hIcon =LoadIcon(NULL,IDI_APPLICATION);
WndClass.hInstance =hInstance;
WndClass.lpfnWndProc =WndProc;
WndClass.lpszClassName =szAppName;
WndClass.lpszMenuName =0;
WndClass.style =CS_HREDRAW|CS_VREDRAW;
}
hWnd=CreateWindow(szAppName,
"THe Hello Program!",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT,
CW_USEDEFAULT,CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
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)
{
HDC hDC;
PAINTSTRUCT ps;
RECT rect;
static LOGFONT lf;
HFONT holdFont,hnewFont;
switch(Message)
{
case WM_CREATE:
return 0;
case WM_PAINT:
lf.lfHeight =-64;
lf.lfWeight =500;
lf.lfPitchAndFamily =DEFAULT_PITCH&FF_DONTCARE;
lf.lfCharSet =GB2312_CHARSET;
strcpy(lf.lfFaceName ,"黑体");
hnewFont=CreateFontIndirect(&lf);
hDC=BeginPaint(hWnd,&ps);
GetClientRect(hWnd,&rect);
GetClientRect(hWnd,&rect);
holdFont=(HFONT)SelectObject(hDC,hnewFont);
SetTextColor(hDC,RGB(255,0,0));
SetBkColor(hDC,RGB(255,255,0));
DrawText(hDC,
"VC 中显示的字体与背景",
-1,
&rect,
DT_SINGLELINE|DT_CENTER|DT_VCENTER);
SelectObject(hDC,holdFont);
DeleteObject(hnewFont);
EndPaint(hWnd,&ps);
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd,Message,wParam,lParam);
}