| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2521 人关注过本帖
标题:求救:error C2731: 'WinMain' : function cannot be overloaded:急
只看楼主 加入收藏
xgoshawk
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-3-4
收藏
 问题点数:0 回复次数:1 
求救:error C2731: 'WinMain' : function cannot be overloaded:急
#include<windows.h>
#include<stdio.h>
//#include<stdafx.h>

LRESULT CALLBACK WinSunProc(
  HWND hwnd,
  UINT uMsg,
  WPARAM wParam,
  LPARAM lParam
);

int WINAPI WinMain(
  HINSTANCE hInstance,
  HINSTANCE hPrevInstance,
  LPWSTR lpCmdLine,
  int nShowCmd
)
{
    WNDCLASS wndcls;
    wndcls.cbClsExtra=0;
    wndcls.cbWndExtra=0;
    wndcls.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
    wndcls.hCursor=LoadCursor(NULL,IDC_CROSS);
    wndcls.hIcon=LoadIcon(NULL,IDI_ERROR);
    wndcls.hInstance=hInstance;
    wndcls.lpfnWndProc=WinSunProc;
    wndcls.lpszClassName="weixin2003";
    wndcls.lpszMenuName=NULL;
    wndcls.style=CS_HREDRAW|CS_VREDRAW;
    RegisterClass(&wndcls);

    HWND hwnd;
    hwnd=CreateWindow("weixin2003","北京维新",WS_OVERLAPPEDWINDOW,0,0,600,400,NULL,NULL,hInstance,NULL);
    ShowWindow(hwnd,SW_SHOWNORMAL);
    UpdateWindow(hwnd);


    MSG msg;
    while(GetMessage(&msg,NULL,0,0))
    {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
    }
    return 0;
}

LRESULT CALLBACK WinSunProc(
  HWND hwnd,
  UINT uMsg,
  WPARAM wParam,
  LPARAM lParam
)
{
    switch(uMsg)
    {
          case WM_CHAR:
              char szchar[20];
              sprintf(szchar,"char is %d",wParam);
              MessageBox(hwnd,szchar,"weixin",0);
          break;
          case WM_LBUTTONDOWN:
              MessageBox(hwnd,"mouse clicked","weixin",0);
              HDC hdc;
              hdc=GetDC(hwnd);
              TextOut(hdc,0,50,"边城",strlen("边城"));
              ReleaseDC(hwnd,hdc);
          break;
          case WM_PAINT:
              HDC hDC;
              PAINTSTRUCT ps;
              hDC=BeginPaint(hwnd,&ps);
              TextOut(hDC,0,0,"维新培训",strlen("维新培训"));
              EndPaint(hwnd,&ps);
          break;
          case WM_CLOSE:
              if(IDYES==MessageBox(hwnd,"关闭?","weixin",MB_YESNO))
              {
                 DestroyWindow(hwnd);
              }
          break;
          case WM_DESTROY:
                PostQuitMessage(0);
          break;
          default:
              return DefWindowProc(hwnd,uMsg,wParam,lParam);
    }
    return 0;
}

编译时:
c:\c_practice\winmain\winmain.cpp(18) : error C2731: 'WinMain' : function cannot be overloaded
        c:\c_practice\winmain\winmain.cpp(12) : see declaration of 'WinMain'
执行 cl.exe 时出错.
Creating browse info file...

winmain.exe - 1 error(s), 0 warning(s)

不知道为什么,我也是抄教科书上的。谢了
搜索更多相关主题的帖子: cannot function error WinMain overloaded 
2008-03-04 20:08
sunkaidong
Rank: 4
来 自:南京师范大学
等 级:贵宾
威 望:12
帖 子:4496
专家分:141
注 册:2006-12-28
收藏
得分:0 
int WINAPI WinMain(
  HINSTANCE hInstance,  // handle to current instance
  HINSTANCE hPrevInstance,  // handle to previous instance
  LPSTR lpCmdLine,      // pointer to command line
  int nCmdShow          // show state of window
)

学习需要安静。。海盗要重新来过。。
2008-03-04 20:32
快速回复:求救:error C2731: 'WinMain' : function cannot be overloaded:急
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.039921 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved