概述
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include
#include LRESULT CALLBACK Winsgjt(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
); int WINAPI Winmain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd)
{
WNDCLASS sgjt;
sgjt.cbClsExtra=0; //??
sgjt.cbWndExtra=0; //??
sgjt.hbrBackground=(HBRUSH)GetStockObject(ANSI_FIXED_FONT);;
sgjt.hCursor=LoadCursor(NULL,IDC_CROSS);
sgjt.hIcon=LoadIcon(NULL,IDI_ASTERISK);
sgjt.hInstance=hInstance;
sgjt.lpfnWndProc=Winsgjt; //??
sgjt.lpszClassName="sgjt";
sgjt.lpszMenuName=NULL;
sgjt.style=CS_HREDRAW|CS_VREDRAW;
RegisterClass(&sgjt);
HWND hwnd;
hwnd=CreateWindow("sgjt","我的第一次尝试",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,WS_VISIBLE,400,400,NULL,NULL,hInstance,NULL); //最后一个NULL什么意思
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd); //??
MSG msg;
while(GetMessage(&msg,NULL,0,0)) //得到WM_QUIT时返回0值,我要得到所有窗口的信息时设为NULL
{
TranslateMessage(&msg);
DispatchMessage(&msg);
} //GetMessage的运行原理
return 0;
}
LRESULT CALLBACK Winsgjt(
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 cha[20];
sprintf(cha,"char is %d",wParam);
MessageBox(hwnd,cha,"sgjt",MB_YESNO);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"sgjt","sgjt",MB_OK);
HDC hdc; //不能在WM_PAINT用
hdc=GetDC(hwnd);
TextOut(hdc,0,50,"sgjt",strlen("sgjt"));
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,"是否真的结束","sgjt",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0; }
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/First.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/First.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
最后
以上就是如意乐曲为你收集整理的c语言在cmd中运行不了,为什么我在windows和Console下都不能运行的全部内容,希望文章能够帮你解决c语言在cmd中运行不了,为什么我在windows和Console下都不能运行所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复