怎么用vc做win32 Application
2个回答
展开全部
#include <windows.h>
//声明窗口函数原型
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
//主函数
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE PreInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
HWND hwnd;
MSG msg;
TCHAR lpszClassName[4] = TEXT("窗口");
TCHAR szWindowsTitle[4] = TEXT("窗口") ;
WNDCLASS wc;
wc.style = 0 ;
wc.lpfnWndProc = WndProc ;
wc.cbClsExtra = 0 ;
wc.cbWndExtra = 0 ;
wc.hInstance = hInstance ;
wc.hIcon = LoadIcon( NULL , IDI_APPLICATION ) ;
wc.hCursor = LoadCursor( NULL , IDC_ARROW ) ;
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH) ;
wc.lpszMenuName = NULL ;
wc.lpszClassName = lpszClassName ;
RegisterClass(&wc);
hwnd = CreateWindow(lpszClassName,
szWindowsTitle,
WS_OVERLAPPEDWINDOW,
120,50,800,600,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
}
//处理消息的窗口函数
LRESULT CALLBACK WndProc(HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
switch(message)
{
case WM_LBUTTONDOWN:
{
MessageBeep(0);
}
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0;
}
//声明窗口函数原型
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
//主函数
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE PreInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
HWND hwnd;
MSG msg;
TCHAR lpszClassName[4] = TEXT("窗口");
TCHAR szWindowsTitle[4] = TEXT("窗口") ;
WNDCLASS wc;
wc.style = 0 ;
wc.lpfnWndProc = WndProc ;
wc.cbClsExtra = 0 ;
wc.cbWndExtra = 0 ;
wc.hInstance = hInstance ;
wc.hIcon = LoadIcon( NULL , IDI_APPLICATION ) ;
wc.hCursor = LoadCursor( NULL , IDC_ARROW ) ;
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH) ;
wc.lpszMenuName = NULL ;
wc.lpszClassName = lpszClassName ;
RegisterClass(&wc);
hwnd = CreateWindow(lpszClassName,
szWindowsTitle,
WS_OVERLAPPEDWINDOW,
120,50,800,600,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
}
//处理消息的窗口函数
LRESULT CALLBACK WndProc(HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
switch(message)
{
case WM_LBUTTONDOWN:
{
MessageBeep(0);
}
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询