WINAPI WinMain

#include <windows.h>
#include <stdio.h>

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

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPreInstance,LPSTR lpCmdLine,int nShowCmd)
{
 WNDCLASS wc;
 wc.style =  CS_VREDRAW|CS_HREDRAW ;
 wc.lpfnWndProc = WndProc;
 wc.cbClsExtra = 0;
 wc.cbWndExtra = 0;
 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW);
 wc.hIcon = LoadIcon(NULL,IDI_APPLICATION);
 wc.hCursor = LoadCursor(NULL,IDC_ARROW);
 wc.hInstance = hInstance;
 wc.lpszClassName = "mainwindow";
 wc.lpszMenuName = NULL;
 if(!RegisterClass(&wc))
 {
  MessageBeep(0);
  return FALSE;
 }

 HWND hwnd;
 hwnd = CreateWindow(
  "mainwindow",
  NULL,
  WS_OVERLAPPED /*WS_POPUP | WS_VISIBLE*/,
  0,0,500,400,
  NULL,
  NULL,
  hInstance,
  NULL
  );

 ShowWindow(hwnd,nShowCmd);
 UpdateWindow(hwnd);

 MSG uMsg;
 while(GetMessage(&uMsg,hwnd,0,0))
 {
  TranslateMessage(&uMsg);
  DispatchMessage(&uMsg);
 }

 return uMsg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
 switch(uMsg)
 {
 //case WM_PAINT:
 // break;
 //case WM_KEYDOWN:
 // break;
 case WM_DESTROY:
  DestroyWindow(hwnd);
  break;
 default:
  return DefWindowProc(hwnd,uMsg,wParam,lParam);
 }
 return 0;
}

#include<windows.h>

LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);//窗口消息处理函数

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR lpszCmdLine,int nCmdShow){
    HWND hwnd;
 MSG Msg;
 WNDCLASS wndclass;
 char lpszClassName[]="test";//窗口类名,实际没有意义
 char lpszTitle[]="我的程序";//应用程序的窗口名
 //LPCTSTR lpszClassName = TEXT("MyApp");
 //LPCTSTR lpszTitle = TEXT("My Application");
 hi=hInstance;//应用程序实例句柄可以在全局使用
 
 ///
 //窗口类型设置/
 ///
 wndclass.style=0;//窗口类型
 wndclass.lpfnWndProc=WndProc;//窗口处理函数
 wndclass.cbClsExtra=0;//窗口类扩展
 wndclass.cbWndExtra=0;//窗口实例扩展
 wndclass.hInstance=hInstance;//当前实例句柄
 wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);//最小化图标
 wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);//光标
 wndclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);//背景
 //wndclass.hbrBackground=(HBRUSH)(COLOR_WINDOW+1);
 wndclass.lpszMenuName=NULL;//菜单
 wndclass.lpszClassName=lpszClassName;//窗口类名
 ///
 ///窗口类注册//
 ///
 if(!RegisterClass(&wndclass)) {
  MessageBeep(0);
  return FALSE;
 }
 ///
 ///创建窗口返回句柄
 ///
 hwnd=CreateWindow(
  lpszClassName,//窗口类名
  lpszTitle,//标题名
  WS_OVERLAPPEDWINDOW,//窗口风格
  CW_USEDEFAULT,//左上角坐标
  CW_USEDEFAULT,
  CW_USEDEFAULT,//高和宽的大小
  CW_USEDEFAULT,
  NULL,
  NULL,
  hInstance,//创建窗口的应用程序句柄
  NULL
  );
 hw=hwnd;//可以在全局使用
 ///
 //显示窗口,进入消息循环///
 ///
 ShowWindow(hwnd,nCmdShow);
 UpdateWindow(hwnd);
 while(GetMessage(&Msg,NULL,0,0)) {
  TranslateMessage(&Msg);
  DispatchMessage(&Msg);
 }
 return Msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)//窗口消息处理函数
{ switch(message)
{
case WM_DESTROY:
PostQuitMessage(0);
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return (0);
}

 

Creating Windows CreateMDIWindow CreateWindow CreateWindowEx RegisterClass RegisterClassEx UnregisterClass Message Processing BroadcastSystemMessage CallNextHookEx CallWindowProc DefFrameProc DefMDIChildProc DefWindowProc DispatchMessage GetMessage GetMessageExtraInfo GetMessagePos GetMessageTime GetQueueStatus InSendMessage PeekMessage PostMessage PostQuitMessage PostThreadMessage RegisterWindowMessage ReplyMessage SendMessage SendMessageCallback SendMessageTimeout SendNotifyMessage SetMessageExtraInfo SetWindowsHookEx TranslateMessage UnhookWindowsHookEx WaitMessage Window Information AnyPopup ChildWindowFromPoint ChildWindowFromPointEx EnableWindow EnumChildWindows EnumPropsEx EnumThreadWindows EnumWindows FindWindow FindWindowEx GetClassInfoEx GetClassLong GetClassName GetClientRect GetDesktopWindow GetFocus GetForegroundWindow GetNextWindow GetParent GetProp GetTopWindow GetWindow GetWindowLong GetWindowRect GetWindowText GetWindowTextLength IsChild IsIconic IsWindow IsWindowEnabled IsWindowUnicode IsWindowVisible IsZoomed RemoveProp SetActiveWindow SetClassLong SetFocus SetForegroundWindow SetParent SetProp SetWindowLong SetWindowText WindowFromPoint Processes and Threads CreateEvent CreateMutex CreateProcess CreateSemaphore CreateThread DeleteCriticalSection DuplicateHandle EnterCriticalSection ExitProcess ExitThread GetCurrentProcess GetCurrentProcessId GetCurrentThread GetCurrentThreadId GetExitCodeProcess GetExitCodeThread GetPriorityClass GetThreadPriority GetWindowThreadProcessId InitializeCriticalSection InterlockedDecrement InterlockedExchange InterlockedIncrement LeaveCriticalSection OpenEvent OpenMutex OpenProcess OpenSemaphore PulseEvent ReleaseMutex ReleaseSemaphore ResetEvent ResumeThread SetEvent SetPr
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值