主题:一个很简单的窗口程序,编译没错,可运行结果不对,请各位大侠帮帮我这个小菜鸟.
#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
)
{
// 1.设计窗口( 1个类, 4个函数 )
WNDCLASS wndclass ; //窗口类
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH ) ; //背景函数
wndclass.hCursor = LoadCursor( NULL , IDC_ARROW ) ; //光标函数
wndclass.hIcon = LoadIcon( NULL , IDI_ERROR ) ; //图标函数
wndclass.hInstance = hInstance ;
wndclass.lpfnWndProc = WinsunProc ; //窗口过程函数
wndclass.lpszClassName = "WeiXin2003" ;
wndclass.lpszMenuName = NULL ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
// 2.注册窗口(1个函数)
RegisterClass(&wndclass) ; //类注册函数
// 3.创建窗口(1个类, 1个函数) //窗口句柄
HWND hwnd ;
hwnd = CreateWindow ( "WeiXin2003" , "计算机编程" , //窗口创建函数
WS_OVERLAPPEDWINDOW , 0 , 0 , 600 , 400 ,
NULL , NULL , hInstance , NULL ) ;
// 4.显示窗口(2个函数)
ShowWindow( hwnd , SW_SHOWNORMAL ) ; //窗口显示函数
UpdateWindow( hwnd ) ; //窗口更新函数
// 5.消息循环(1个类, 3个函数)
MSG msg ; //消息类
while ( GetMessage( &msg , NULL , 0 , 0 ) ); //消息说明函数
{
TranslateMessage( &msg ) ; //消息转换函数
DispatchMessage( &msg ) ; //消息发送函数
}
return 0 ;
}
#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
)
{
// 1.设计窗口( 1个类, 4个函数 )
WNDCLASS wndclass ; //窗口类
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH ) ; //背景函数
wndclass.hCursor = LoadCursor( NULL , IDC_ARROW ) ; //光标函数
wndclass.hIcon = LoadIcon( NULL , IDI_ERROR ) ; //图标函数
wndclass.hInstance = hInstance ;
wndclass.lpfnWndProc = WinsunProc ; //窗口过程函数
wndclass.lpszClassName = "WeiXin2003" ;
wndclass.lpszMenuName = NULL ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
// 2.注册窗口(1个函数)
RegisterClass(&wndclass) ; //类注册函数
// 3.创建窗口(1个类, 1个函数) //窗口句柄
HWND hwnd ;
hwnd = CreateWindow ( "WeiXin2003" , "计算机编程" , //窗口创建函数
WS_OVERLAPPEDWINDOW , 0 , 0 , 600 , 400 ,
NULL , NULL , hInstance , NULL ) ;
// 4.显示窗口(2个函数)
ShowWindow( hwnd , SW_SHOWNORMAL ) ; //窗口显示函数
UpdateWindow( hwnd ) ; //窗口更新函数
// 5.消息循环(1个类, 3个函数)
MSG msg ; //消息类
while ( GetMessage( &msg , NULL , 0 , 0 ) ); //消息说明函数
{
TranslateMessage( &msg ) ; //消息转换函数
DispatchMessage( &msg ) ; //消息发送函数
}
return 0 ;
}