WINDOWs

#include<windows.h>
#include"resource.h"

LRESULT __stdcall wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM  lParam);
int WINAPI WinMain( HINSTANCE hInstance,  HINSTANCE hPrevInstance,  LPSTR lpCmdLine,  int nCmdShow )
{

 WNDCLASSEX wc;
 HWND hWnd;
 MSG msg;
 wc.cbClsExtra=0;
 wc.cbSize=sizeof(WNDCLASSEX);
 wc.cbWndExtra=0;                                                                                                                                                                                                                                                         
 wc.hbrBackground=(HBRUSH)COLOR_WINDOW;
 wc.hCursor=NULL;
 wc.hIcon=LoadIcon(hInstance,MAKEINTRESOURCE(IDI_ICON1));
 wc.hIconSm=LoadIcon(hInstance,MAKEINTRESOURCE(IDI_ICON2 ));
 wc.hInstance=hInstance;
 wc.lpfnWndProc=wndProc;//转定义
 wc.lpszClassName="helloworld";
 wc.lpszMenuName=NULL;
 wc.style=CS_HREDRAW|CS_VREDRAW;
 RegisterClassEx(&wc);
 hWnd=CreateWindow("helloworld","你好世界",WS_OVERLAPPEDWINDOW,300,50,500,5000,NULL,NULL,hInstance,NULL);
 ShowWindow(hWnd,nCmdShow);
 while(GetMessage(&msg,NULL,0,0))
 {
  TranslateMessage(&msg);
  DispatchMessage(&msg);
 }
 return 0;
}
LRESULT __stdcall wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM  lParam)
{
 switch(msg)
 {
 case WM_CLOSE:
         PostQuitMessage(0);
  break;
 }
 return DefWindowProc(hWnd,msg,wParam,lParam);
}

你可能感兴趣的:(WINDOWs)