小金鱼系列win32-1

来源:互联网 发布:模拟退火算法太阳影子 编辑:程序博客网 时间:2024/06/10 23:58
#include <tchar.h>
#include <Windows.h>


LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch(uMsg)
{
case WM_CLOSE:
{::DestroyWindow(hWnd);}


case WM_DESTROY:
{::PostQuitMessage(0);}



}


return ::DefWindowProc(hWnd,uMsg,wParam,lParam);


}




int WINAPI _tWinMain( __in HINSTANCE hInstance,__in_opt HINSTANCE hPreIstance,__in_opt LPTSTR  lpCmdline, __in int nShowCmd)


{








//注册窗口类,12域
const TCHAR* pszClassName=_T("ITWIN");


WNDCLASSEX wce;
wce.cbSize=sizeof(WNDCLASSEX);//窗口类大小
wce.style=CS_HREDRAW | CS_VREDRAW;//窗口类样式
wce.lpfnWndProc=WndProc;//窗口处理函数
wce.cbClsExtra=0;//窗口类额外空间
wce.cbWndExtra=0;
wce.hInstance=hInstance;
wce.hIcon=(HICON)::LoadIcon(NULL,IDI_APPLICATION);
wce.hIconSm=(HICON)::LoadIcon(NULL,IDI_APPLICATION);
wce.hbrBackground=(HBRUSH)::GetStockObject(GRAY_BRUSH);//画刷
wce.hCursor=(HCURSOR)::LoadCursor(NULL,IDC_ARROW);//使用箭头光标
wce.lpszClassName=pszClassName;//把定义的窗口类名传入到注册窗口信息中
wce.lpszMenuName=NULL;




bool bRet= ::RegisterClassEx(&wce);
if (!bRet)
{
MessageBox(NULL,_T("注册窗口类失败"),_T("注册窗口"),0);




return false;


}


HWND hwnd= CreateWindowEx(0,pszClassName,_T("IT学霸"),WS_VISIBLE | WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);






if (hwnd==NULL)
{
MessageBox(NULL,_T("创建窗口失败"),_T("创建窗口"),0);
return false;
}


::ShowWindow(hwnd,SW_SHOW);
::UpdateWindow(hwnd);




MSG msg;
while ( ::GetMessage(&msg,NULL,NULL,NULL) )
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);


}


return true;










}
1 0