#include <windows.h>
#include <stdio.h>
LRESULT CALLBACK WinsunProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
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
)
{
WNDCLASS wndcls;
wndcls.cbClsExtra=0;
wndcls.cbWndExtra=0;
wndcls.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wndcls.hIcon=LoadIcon(NULL,IDI_ERROR);
wndcls.hInstance=hInstance;
wndcls.lpfnWndProc=WinsunProc;
wndcls.lpszClassName="www.zzu.edu.cn";
wndcls.lpszMenuName=NULL;
wndcls.style=CS_HREDRAW | CS_VREDRAW;
wndcls.hCursor=LoadCursor(NULL,IDC_ARROW);
RegisterClass(&wndcls); HWND hwnd;
hwnd=CreateWindow("www.zzu.edu.cn","信息工程学院2010级研究生",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, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
switch (uMsg)
{
case WM_CHAR:
{
char szChar[20];
sprintf(szChar,"char is %d",wParam);
MessageBox(hwnd,szChar,"iezzu.com",0);
}
break;
case WM_LBUTTONDOWN:
{
MessageBox(hwnd,"mouse clicked","iezzu.com",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,"信息工程学院2010级研究生",strlen("信息工程学院2010级研究生"));
EndPaint(hwnd,&ps);
}
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"是否真的关闭窗口?","iezzu.com",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
{
PostQuitMessage(0);
}
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}链接出错提示,如下:
-------------------Configuration: WinMain - Win32 Debug--------------------
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/WinMain.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.WinMain.exe - 2 error(s), 0 warning(s)
#include <stdio.h>
LRESULT CALLBACK WinsunProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
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
)
{
WNDCLASS wndcls;
wndcls.cbClsExtra=0;
wndcls.cbWndExtra=0;
wndcls.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wndcls.hIcon=LoadIcon(NULL,IDI_ERROR);
wndcls.hInstance=hInstance;
wndcls.lpfnWndProc=WinsunProc;
wndcls.lpszClassName="www.zzu.edu.cn";
wndcls.lpszMenuName=NULL;
wndcls.style=CS_HREDRAW | CS_VREDRAW;
wndcls.hCursor=LoadCursor(NULL,IDC_ARROW);
RegisterClass(&wndcls); HWND hwnd;
hwnd=CreateWindow("www.zzu.edu.cn","信息工程学院2010级研究生",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, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
switch (uMsg)
{
case WM_CHAR:
{
char szChar[20];
sprintf(szChar,"char is %d",wParam);
MessageBox(hwnd,szChar,"iezzu.com",0);
}
break;
case WM_LBUTTONDOWN:
{
MessageBox(hwnd,"mouse clicked","iezzu.com",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,"信息工程学院2010级研究生",strlen("信息工程学院2010级研究生"));
EndPaint(hwnd,&ps);
}
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"是否真的关闭窗口?","iezzu.com",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
{
PostQuitMessage(0);
}
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}链接出错提示,如下:
-------------------Configuration: WinMain - Win32 Debug--------------------
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/WinMain.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.WinMain.exe - 2 error(s), 0 warning(s)
解决方案 »
- MFC 让Static控件上的图形运动
- 消息传递一定要经过主框架吗?
- CCheckListBox是怎么加到对话框的?
- ******跪求大虾,一个对我来说很难的问题,如何在对话框的基础上添加分割条?******
- 关于安全模式下,程序的自启动.
- 关于CComboBox类的使用
- ★★★相互学习列出自己的QQ,成立VC菜鸟联盟!!!!★★★
- OnMouseMove
- CSplashWnd* CSplashWnd::c_pSplashWnd;小弟不什分明白
- 为什么我的电脑安装不上vs2010专业版,我的电脑室win8的,跪求各位大神啊,
- 在TEXTVIEW的CEDIT控件下打印字符
- 请教字符串,字符集问题
这样改:
[Project] --> [Settings] --> 选择"Link"属性页,在Project Options中将/subsystem:console改成/subsystem:windows
在Project Options中将/subsystem: 是不是Console?如果是,把Console改成windows
提示无法找到main函数,即你程序当前入口点为main函数,此为命令行程序。
改为Windows程序后,即可把入口点换为WinMain函数,就不会出错了。
解决办法:
[Project] --> [Settings] --> 选择"Link"属性页,
在Project Options中将/subsystem:console改成/subsystem:windows