C语言 用VC建立一个窗口

来源:百度知道 编辑:UC知道 时间:2024/05/21 22:24:11
#include <windows.h>
#include <stdio.h>

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

int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hprevInstance,
LPSTR lpCmdline,
int nCmdshow
)
{
WNDCLASS wndcls;
wndcls.cbClsExtra=0;
wndcls.cbWndExtra=0;
wndcls.hbrBackground=(HBRUSH)GetStockObject(DKGRAY_BRUSH);
wndcls.hCursor=LoadCursor(hInstance,IDC_CROSS);
wndcls.hIcon=LoadIcon(hInstance,IDI_APPLICATION);
wndcls.hInstance=hInstance;
wndcls.lpfnWndProc=WinSunProc;
wndcls.lpszClassName="小明是傻";
wndcls.lpszMenuName=NULL;
wndcls.style=CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wndcls);

HWND hwnd;
hwnd=CreateWindow("小明是傻","小明狂傻无比",WS_OVERLAPPEDWINDOW,
0,0,800,600,NULL,NULL,hInstance,NULL);

ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);

确定你建立的是win32 appliaction??
那就奇怪了 怎么会提示找不到main函数呢?

只有在Console工程中系统才会去找main啊
在win32 application中系统也会去找winmain啊

你重新建立工程试试

不知道你的什么情况,我全部复制一点没变,运行正常

不知道你建立工程的时间是怎么选择的,我选的的是Win32,然后空的工程