private static unsafe void Main() { MainWindow mainWindow = new MainWindow(); MSG message = new MSG(); while (message.message != NativeConstants.WM_QUIT) { if (NativeMethods.PeekMessage(&message, IntPtr.Zero, 0, 0, NativeConstants.PM_REMOVE)) { NativeMethods.TranslateMessage(&message); NativeMethods.DispatchMessage(&message); } } }
public static extern int TranslateAccelerator(HWND hwnd, HANDLE hAccTable, ref MSG lpMsg);
public static extern int PeekMessage(ref MSG lpMsg, HWND hwnd, int wMsgFilterMin, int wMsgFilterMax, int wRemoveMsg);
public static extern int IsDialogMessage(HANDLE hDlg, ref MSG lpMsg);
public static extern int GetMessage(ref MSG lpMsg, HWND hwnd, int wMsgFilterMin, int wMsgFilterMax);
public static extern int DispatchMessage(ref MSG lpMsg);
public static extern int CallMsgFilter(ref MSG lpMsg, int ncode);
public static unsafe extern BOOL PeekMessage(MSG* lpMsg, IntPtr hWnd, uint wMsgFilterMin, uint wMsgFilterMax, uint wRemoveMsg);
public static extern bool GetMessage(out MSG lpMsg, IntPtr hWnd, uint wMsgFilterMin, uint wMsgFilterMax);
public int Run() { Functions.ShowWindow(gameWindow.Handle, SW.SHOW); Functions.UpdateWindow(gameWindow.Handle); timer.Start(); MSG msg = new MSG(); while (msg.Message != WM.QUIT) { if (Functions.PeekMessage(out msg, IntPtr.Zero, 0, 0, PM.REMOVE)) { //messages++; //Functions.SetWindowText(gameWindow.Handle, string.Format("Message #{0}: {1}", messages.ToString(), msg.Message.ToString())); Functions.TranslateMessage(ref msg); Functions.DispatchMessage(ref msg); } else { gameWindow.OnNewFrame(); timer.UpdateTime(); if (NewFrame != null) { NewFrame(timer.RealTime); } } } return msg.WParam.ToInt32(); }
public static extern bool PeekMessage( out MSG lpMsg, IntPtr hWnd, int wMsgFilterMin, int wMsgFilterMax, PM wRemoveMsg );
public static extern bool PeekMessage(out MSG message, IntPtr hwnd, uint messageFilterMin, uint messageFilterMax, uint flags);
public static extern bool PeekMessage(out MSG message, IntPtr handle, uint filterMin, uint filterMax, PM flags);
public static unsafe extern BOOL TranslateMessage(MSG* lpMsg);
public static extern int TranslateMDISysAccel(HWND hwndClient, ref MSG lpMsg);
public static extern int TranslateMessage(ref MSG lpMsg);
public static unsafe extern IntPtr DispatchMessage(MSG* lpMsg);