#include <windows.h>
#include <stdlib.h>
#include <string.h>
long WINAPI WndProc
 (
    HWND hWnd,
UINT iMessage,
UINT wParam,
LONG lParam
);BOOL InitWindowsClass(HINSTANCE hInstance);
BOOL InitWindows(HINSTANCE hInstance,int nCmdShow);
HWND hWndMain;int WINAPI WinMain//主函数
   (
      HINSTANCE hInstance,
  HINSTANCE hPrevInstance,
  LPSTR lpCmdLine,
  int nCmdShow
  )
{
MSG Message;
if (! InitWindowsClass(hInstance))
return FALSE;
if (! InitWindows(hInstance,nCmdShow))
return FALSE;
while (GetMessage(&Message,0,0,0))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return Message.wParam;
}long WINAPI WndProc
     (
   HWND hWnd,
   UINT iMessage,
   UINT wParam,
   LONG lParam
   )

HDC hDC;
HBRUSH hBrush;
HPEN hPen;
PAINTSTRUCT PtStr;
switch (iMessage)

case WM_PAINT:
hDC=BeginPaint(hWnd, &PtStr);
SetMapMode(hDC,MM_ANISOTROPIC);
hPen=(HPEN)GetStockObject(BLACK_PEN);
      hBrush=(HBRUSH)GetStockObject(DKGRAY_BRUSH);
     SelectObject(hDC,hBrush);
SelectObject(hDC,hPen);
RoundRect(hDC,50,120,100,200,15,15);
hBrush=(HBRUSH)GetStockObject(LTGRAY_BRUSH);
SelectObject(hDC,hBrush);
Ellipse(hDC,150,50,200,150);
hBrush=(HBRUSH)GetStockObject(HOLLOW_BRUSH);
SelectObject(hDC,hBrush);
Pie(hDC,250,50,300,100,250,50,300,50);
EndPaint(hWnd,&PtStr);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return (DefWindowProc(hWnd,iMessage,wParam,lParam));
}
}BOOL InitWindows(HINSTANCE hInstance,int nCmdShow)     //初始化窗口
{
HWND hWnd;
hWnd=CreateWindow(" WinFill",                          //生成窗口
               "填充示例程序",
   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;
}
BOOL InitWindowsClass(HINSTANCE hInstance)//定义窗口
{
WNDCLASS WndClass;
WndClass.cbClsExtra=0;
WndClass.cbWndExtra=0;
WndClass.hbrBackground=(HBRUSH)(GetStockObject(WHITE_BRUSH));
WndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
WndClass.hIcon=LoadIcon(NULL,"END");
WndClass.hInstance=hInstance;
WndClass.lpfnWndProc=WndProc;
WndClass.lpszClassName="WinFill";
WndClass.lpszMenuName=NULL;
WndClass.style=CS_HREDRAW|CS_VREDRAW;
return RegisterClass(&WndClass);
}运行不能生成EXE文件

解决方案 »

  1.   

    不太可能吧,是不是LINK参数不太对啊
      

  2.   

    --------------------Configuration: bug - Win32 Debug--------------------
    Linking...
    LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
    Debug/bug.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.bug.exe - 2 error(s), 0 warning(s)
    是不是这些?
      

  3.   

    你是不是还需要连接一些静态库,而这些库你既没有添加入项目,也没有在LINK参数中进行设置?
      

  4.   

    我是加在项目里面但是还是不能生成EXE文件啊
    各位帮忙啊
      

  5.   

    就是没有错误信息啊
    就是不能生成EXE啊
      

  6.   

    感觉这句有问题
    return Message.wParam;
    改为 return true;
    试试