本文整理汇总了C#中System.Windows.Forms.MSG类的典型用法代码示例。如果您正苦于以下问题:C# MSG类的具体用法?C# MSG怎么用?C# MSG使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MSG类属于System.Windows.Forms命名空间,在下文中一共展示了MSG类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: RemovePendingMessages
private static void RemovePendingMessages(int msgMin, int msgMax)
{
if (!control.IsDisposed)
{
MSG msg = new MSG();
IntPtr handle = control.Handle;
while (PeekMessage(ref msg, new HandleRef(control, handle), msgMin, msgMax, 1))
{
}
}
}
开发者ID:MikhailoMMX,项目名称:AspectMarkup,代码行数:12,代码来源:KeyboardShortcutHelper.cs
示例2: StartDrag
public DragDropEffects StartDrag (IntPtr handle, object data,
DragDropEffects allowed_effects)
{
drag_data = new DragData ();
drag_data.Window = handle;
drag_data.State = DragState.Beginning;
drag_data.MouseState = XplatUIX11.MouseState;
drag_data.Data = data;
drag_data.SupportedTypes = DetermineSupportedTypes (data);
drag_data.AllowedEffects = allowed_effects;
drag_data.Action = ActionFromEffect (allowed_effects);
if (CursorNo == null) {
// Make sure the cursors are created
CursorNo = new Cursor (typeof (X11Dnd), "DnDNo.cur");
CursorCopy = new Cursor (typeof (X11Dnd), "DnDCopy.cur");
CursorMove = new Cursor (typeof (X11Dnd), "DnDMove.cur");
CursorLink = new Cursor (typeof (X11Dnd), "DnDLink.cur");
}
drag_data.LastTopLevel = IntPtr.Zero;
control = null;
System.Windows.Forms.MSG msg = new MSG();
object queue_id = XplatUI.StartLoop (Thread.CurrentThread);
Timer timer = new Timer ();
timer.Tick += new EventHandler (DndTickHandler);
timer.Interval = 100;
int suc;
drag_data.State = DragState.Dragging;
suc = XplatUIX11.XSetSelectionOwner (display, XdndSelection,
drag_data.Window, IntPtr.Zero);
if (suc == 0) {
Console.Error.WriteLine ("Could not take ownership of XdndSelection aborting drag.");
drag_data.Reset ();
return DragDropEffects.None;
}
drag_data.State = DragState.Dragging;
drag_data.CurMousePos = new Point ();
source = toplevel = target = IntPtr.Zero;
dropped = false;
tracking = true;
motion_poll = -1;
timer.Start ();
// Send Enter to the window initializing the dnd operation - which initializes the data
SendEnter (drag_data.Window, drag_data.Window, drag_data.SupportedTypes);
drag_data.LastTopLevel = toplevel;
while (tracking && XplatUI.GetMessage (queue_id, ref msg, IntPtr.Zero, 0, 0)) {
if (msg.message >= Msg.WM_KEYFIRST && msg.message <= Msg.WM_KEYLAST) {
HandleKeyMessage (msg);
} else {
switch (msg.message) {
case Msg.WM_LBUTTONUP:
case Msg.WM_RBUTTONUP:
case Msg.WM_MBUTTONUP:
if (msg.message == Msg.WM_LBUTTONDOWN && drag_data.MouseState != MouseButtons.Left)
break;;
if (msg.message == Msg.WM_RBUTTONDOWN && drag_data.MouseState != MouseButtons.Right)
break;
if (msg.message == Msg.WM_MBUTTONDOWN && drag_data.MouseState != MouseButtons.Middle)
break;
HandleButtonUpMsg ();
// We don't want to dispatch button up neither (Match .Net)
// Thus we have to remove capture by ourselves
RemoveCapture (msg.hwnd);
continue;
case Msg.WM_MOUSEMOVE:
motion_poll = 0;
drag_data.CurMousePos.X = Control.LowOrder ((int) msg.lParam.ToInt32 ());
drag_data.CurMousePos.Y = Control.HighOrder ((int) msg.lParam.ToInt32 ());
HandleMouseOver ();
// We don't want to dispatch mouse move
continue;
}
XplatUI.DispatchMessage (ref msg);
}
}
timer.Stop ();
// If the target is a mwf control, return until DragEnter/DragLeave has been fired,
// which means the respective -already sent- dnd ClientMessages have been received and handled.
if (control != null)
Application.DoEvents ();
if (!dropped)
return DragDropEffects.None;
//.........这里部分代码省略.........
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:101,代码来源:X11Dnd.cs
示例3: TranslateAccelerator
/// <summary>
/// Send key commands to text view if it has focus
/// </summary>
/// <param name="msg"></param>
/// <returns></returns>
public int TranslateAccelerator(MSG[] messagesToTranslate)
{
int hr = VSConstants.S_FALSE;
if (messagesToTranslate == null)
{
return hr;
}
// defer to active code window
if (activeTextView != null)
{
IVsWindowPane vsWindowPane = (IVsWindowPane) activeTextView;
hr = vsWindowPane.TranslateAccelerator(messagesToTranslate);
}
else
{
switch (messagesToTranslate[0].message)
{
case NativeMethods.WM_KEYDOWN:
case NativeMethods.WM_SYSKEYDOWN:
case NativeMethods.WM_CHAR:
case NativeMethods.WM_SYSCHAR:
{
Message msg = new Message();
msg.HWnd = messagesToTranslate[0].hwnd;
msg.Msg = (int) messagesToTranslate[0].message;
msg.LParam = messagesToTranslate[0].lParam;
msg.WParam = messagesToTranslate[0].wParam;
Control ctrl = FromChildHandle(msg.HWnd);
if (ctrl != null && ctrl.PreProcessMessage(ref msg))
hr = VSConstants.S_OK;
}
break;
default:
break;
}
}
return hr;
}
开发者ID:GeertVL,项目名称:SnippetDesigner,代码行数:48,代码来源:SnippetEditor.cs
示例4: FPreTranslateMessage
/// <summary>
/// Gives the component a chance to process the message before it is translated and dispatched.
/// </summary>
/// <param name="pMsg">The message to process.</param>
/// <returns>TRUE (not zero) if the message is consumed, otherwise FALSE (zero).</returns>
/// <remarks>
/// The component can do TranslateAccelerator, do IsDialogMessage, modify pMsg, or take some other action.
/// </remarks>
public int FPreTranslateMessage(MSG[] pMsg)
{
return 0;
}
开发者ID:yellowbigbird,项目名称:bird-self-lib,代码行数:12,代码来源:SourceOutlinerToolWindow.cs
示例5: PeekMessage
static extern bool PeekMessage(ref MSG msg, IntPtr hWnd, int messageFilterMin, int messageFilterMax, int flags);
开发者ID:gamemaster101gr,项目名称:open3deditor,代码行数:1,代码来源:WinGLControl.cs
示例6: Win32DispatchMessage
internal extern static IntPtr Win32DispatchMessage(ref MSG msg);
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:1,代码来源:XplatUIWin32.cs
示例7: StoreMessage
private static bool StoreMessage(ref MSG msg) {
MSG message = new MSG();
message = msg;
message_queue.Enqueue(message);
return true;
}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:8,代码来源:XplatUIWin32.cs
示例8: PeekMessage
internal override bool PeekMessage(Object queue_id, ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags)
{
XEventQueue queue = (XEventQueue) queue_id;
bool pending;
if ((flags & (uint)PeekMessageFlags.PM_REMOVE) == 0) {
throw new NotImplementedException("PeekMessage PM_NOREMOVE is not implemented yet"); // FIXME - Implement PM_NOREMOVE flag
}
pending = false;
if (queue.Count > 0) {
pending = true;
} else {
// Only call UpdateMessageQueue if real events are pending
// otherwise we go to sleep on the socket
if (XPending(DisplayHandle) != 0) {
UpdateMessageQueue((XEventQueue)queue_id);
pending = true;
} else if (((XEventQueue)queue_id).Paint.Count > 0) {
pending = true;
}
}
CheckTimers(queue.timer_list, DateTime.UtcNow);
if (!pending) {
return false;
}
return GetMessage(queue_id, ref msg, hWnd, wFilterMin, wFilterMax);
}
开发者ID:nlhepler,项目名称:mono,代码行数:30,代码来源:XplatUIX11.cs
示例9: TranslateMessage
internal override bool TranslateMessage(ref MSG msg)
{
return Keyboard.TranslateMessage (ref msg);
}
开发者ID:nlhepler,项目名称:mono,代码行数:4,代码来源:XplatUIX11.cs
示例10: DoEvents
internal override void DoEvents()
{
DebugHelper.Enter ();
MSG msg = new MSG ();
XEventQueue queue;
if (OverrideCursorHandle != IntPtr.Zero) {
OverrideCursorHandle = IntPtr.Zero;
}
queue = ThreadQueue(Thread.CurrentThread);
queue.DispatchIdle = false;
in_doevents = true;
while (PeekMessage(queue, ref msg, IntPtr.Zero, 0, 0, (uint)PeekMessageFlags.PM_REMOVE)) {
Message m = Message.Create (msg.hwnd, (int)msg.message, msg.wParam, msg.lParam);
if (Application.FilterMessage (ref m))
continue;
TranslateMessage (ref msg);
DispatchMessage (ref msg);
string key = msg.hwnd + ":" + msg.message;
if (messageHold[key] != null) {
messageHold[key] = ((int)messageHold[key]) - 1;
DebugHelper.WriteLine ("Got " + msg + " for " + key);
}
}
in_doevents = false;
queue.DispatchIdle = true;
DebugHelper.Leave ();
}
开发者ID:nlhepler,项目名称:mono,代码行数:37,代码来源:XplatUIX11.cs
示例11: GetMessage
internal override bool GetMessage(Object queue_id, ref MSG msg, IntPtr handle, int wFilterMin, int wFilterMax)
{
XEvent xevent;
bool client;
Hwnd hwnd;
ProcessNextMessage:
if (((XEventQueue)queue_id).Count > 0) {
xevent = (XEvent) ((XEventQueue)queue_id).Dequeue ();
} else {
UpdateMessageQueue ((XEventQueue)queue_id);
if (((XEventQueue)queue_id).Count > 0) {
xevent = (XEvent) ((XEventQueue)queue_id).Dequeue ();
} else if (((XEventQueue)queue_id).Paint.Count > 0) {
xevent = ((XEventQueue)queue_id).Paint.Dequeue();
} else {
msg.hwnd= IntPtr.Zero;
msg.message = Msg.WM_ENTERIDLE;
return true;
}
}
hwnd = Hwnd.GetObjectFromWindow(xevent.AnyEvent.window);
#if DriverDebugDestroy
if (hwnd != null)
if (hwnd.zombie)
Console.WriteLine ( "GetMessage zombie, got Event: " + xevent.ToString () + " for 0x{0:x}", hwnd.Handle.ToInt32());
else
Console.WriteLine ( "GetMessage, got Event: " + xevent.ToString () + " for 0x{0:x}", hwnd.Handle.ToInt32());
#endif
// Handle messages for windows that are already or are about to be destroyed.
// we need a special block for this because unless we remove the hwnd from the paint
// queue it will always stay there (since we don't handle the expose), and we'll
// effectively loop infinitely trying to repaint a non-existant window.
if (hwnd != null && hwnd.zombie && xevent.type == XEventName.Expose) {
hwnd.expose_pending = hwnd.nc_expose_pending = false;
hwnd.Queue.Paint.Remove (hwnd);
goto ProcessNextMessage;
}
// We need to make sure we only allow DestroyNotify events through for zombie
// hwnds, since much of the event handling code makes requests using the hwnd's
// client_window, and that'll result in BadWindow errors if there's some lag
// between the XDestroyWindow call and the DestroyNotify event.
if (hwnd == null || hwnd.zombie && xevent.AnyEvent.type != XEventName.ClientMessage) {
DriverDebug("GetMessage(): Got message {0} for non-existent or already destroyed window {1:X}", xevent.type, xevent.AnyEvent.window.ToInt32());
goto ProcessNextMessage;
}
// If we get here, that means the window is no more but there are Client Messages
// to be processed, probably a Posted message (for instance, an WM_ACTIVATE message)
// We don't want anything else to run but the ClientMessage block, so reset all hwnd
// properties that might cause other processing to occur.
if (hwnd.zombie) {
hwnd.resizing_or_moving = false;
}
if (hwnd.client_window == xevent.AnyEvent.window) {
client = true;
//Console.WriteLine("Client message {1}, sending to window {0:X}", msg.hwnd.ToInt32(), xevent.type);
} else {
client = false;
//Console.WriteLine("Non-Client message, sending to window {0:X}", msg.hwnd.ToInt32());
}
msg.hwnd = hwnd.Handle;
// Windows sends WM_ENTERSIZEMOVE when a form resize/move operation starts and WM_EXITSIZEMOVE
// when it is done. The problem in X11 is that there is no concept of start-end of a moving/sizing.
// Configure events ("this window has resized/moved") are sent for each step of the resize. We send a
// WM_ENTERSIZEMOVE when we get the first Configure event. The problem is the WM_EXITSIZEMOVE.
//
// - There is no way for us to know which is the last Configure event. We can't traverse the events
// queue, because the next configure event might not be pending yet.
// - We can't get ButtonPress/Release events for the window decorations, because they are not part
// of the window(s) we manage.
// - We can't rely on the mouse state to change to "up" before the last Configure event. It doesn't.
//
// We are almost 100% guaranteed to get another event (e.g Expose or other), but we can't know for sure
// which, so we have here to check if the mouse buttons state is "up" and send the WM_EXITSIZEMOVE
//
if (hwnd.resizing_or_moving) {
int root_x, root_y, win_x, win_y, keys_buttons;
IntPtr root, child;
XQueryPointer (DisplayHandle, hwnd.Handle, out root, out child, out root_x, out root_y,
out win_x, out win_y, out keys_buttons);
if ((keys_buttons & (int)MouseKeyMasks.Button1Mask) == 0 &&
(keys_buttons & (int)MouseKeyMasks.Button2Mask) == 0 &&
(keys_buttons & (int)MouseKeyMasks.Button3Mask) == 0) {
hwnd.resizing_or_moving = false;
SendMessage (hwnd.Handle, Msg.WM_EXITSIZEMOVE, IntPtr.Zero, IntPtr.Zero);
}
}
//
//.........这里部分代码省略.........
开发者ID:nlhepler,项目名称:mono,代码行数:101,代码来源:XplatUIX11.cs
示例12: DispatchMessage
internal override IntPtr DispatchMessage(ref MSG msg)
{
return NativeWindow.WndProc(msg.hwnd, msg.message, msg.wParam, msg.lParam);
}
开发者ID:nlhepler,项目名称:mono,代码行数:4,代码来源:XplatUIX11.cs
示例13: WaitForHwndMessage
void WaitForHwndMessage (Hwnd hwnd, Msg message, bool process) {
MSG msg = new MSG ();
XEventQueue queue;
queue = ThreadQueue(Thread.CurrentThread);
queue.DispatchIdle = false;
bool done = false;
string key = hwnd.Handle + ":" + message;
if (!messageHold.ContainsKey (key))
messageHold.Add (key, 1);
else
messageHold[key] = ((int)messageHold[key]) + 1;
do {
DebugHelper.WriteLine ("Waiting for message " + message + " on hwnd " + String.Format("0x{0:x}", hwnd.Handle.ToInt32 ()));
DebugHelper.Indent ();
if (PeekMessage(queue, ref msg, IntPtr.Zero, 0, 0, (uint)PeekMessageFlags.PM_REMOVE)) {
if ((Msg)msg.message == Msg.WM_QUIT) {
PostQuitMessage (0);
done = true;
}
else {
DebugHelper.WriteLine ("PeekMessage got " + msg);
if (msg.hwnd == hwnd.Handle) {
if ((Msg)msg.message == message) {
if (process) {
TranslateMessage (ref msg);
DispatchMessage (ref msg);
}
break;
}
else if ((Msg)msg.message == Msg.WM_DESTROY)
done = true;
}
TranslateMessage (ref msg);
DispatchMessage (ref msg);
}
}
done = !messageHold.ContainsKey (key) || ((int)messageHold[key] < 1) || done;
} while (!done);
messageHold.Remove (key);
DebugHelper.Unindent ();
DebugHelper.WriteLine ("Finished waiting for " + key);
queue.DispatchIdle = true;
}
开发者ID:nlhepler,项目名称:mono,代码行数:58,代码来源:XplatUIX11.cs
示例14: HandleKeyMessage
public void HandleKeyMessage (MSG msg)
{
if (VirtualKeys.VK_ESCAPE == (VirtualKeys) msg.wParam.ToInt32()) {
QueryContinue (true, DragAction.Cancel);
}
}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:6,代码来源:X11Dnd.cs
示例15: Win32GetMessage
internal extern static bool Win32GetMessage(ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax);
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:1,代码来源:XplatUIWin32.cs
示例16: DoEvents
internal override void DoEvents() {
MSG msg = new MSG();
while (GetMessage(ref msg, IntPtr.Zero, 0, 0, false)) {
Message m = Message.Create (msg.hwnd, (int)msg.message, msg.wParam, msg.lParam);
if (Application.FilterMessage (ref m))
continue;
XplatUI.TranslateMessage(ref msg);
XplatUI.DispatchMessage(ref msg);
}
}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:13,代码来源:XplatUIWin32.cs
示例17: Win32TranslateMessage
internal extern static bool Win32TranslateMessage(ref MSG msg);
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:1,代码来源:XplatUIWin32.cs
示例18: PeekMessage
internal override bool PeekMessage(Object queue_id, ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags) {
return Win32PeekMessage(ref msg, hWnd, wFilterMin, wFilterMax, flags);
}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:3,代码来源:XplatUIWin32.cs
示例19: RetrieveMessage
private static bool RetrieveMessage(ref MSG msg) {
MSG message;
if (message_queue.Count == 0) {
return false;
}
message = (MSG)message_queue.Dequeue();
msg = message;
return true;
}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:12,代码来源:XplatUIWin32.cs
示例20: GetMessage
internal override bool GetMessage(Object queue_id, ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax) {
return GetMessage(ref msg, hWnd, wFilterMin, wFilterMax, true);
}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:3,代码来源:XplatUIWin32.cs
注:本文中的System.Windows.Forms.MSG类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论