protected override void WndProc(ref Message m)
 {
     if (m.Msg == Win32.WM_HOTKEY_MSG_ID)
     {
         Console.WriteLine(m.ToString());
     }
     var hotkeyInfo = HotkeyInfo.GetFromMessage(m);
     if (hotkeyInfo != null) HotkeyProc(hotkeyInfo);
     base.WndProc(ref m);
 }
Beispiel #2
0
			protected override void WndProc (ref Message m)
			{				
				foreach (int i in watches) {
					if ((int)m.Msg == i) {
						Console.WriteLine ((this.Name != "" && this.Name != null ? this.Name : "ControlWatcher") + " received message " + m.ToString ());
						break;
					}
				}
				base.WndProc (ref m);
			}
 protected override void WndProc(ref Message m) {
     bool consumed = false;
     if(MessageCaptured != null) {
         try {
             consumed = MessageCaptured(ref m);
         }
         catch(Exception ex) {
             QTUtility2.MakeErrorLog(ex, String.Format(m.ToString()));
         }
     }
     if(!consumed) {
         base.WndProc(ref m);
     }
 }
 /*
 private void KeybindingPrompt_KeyPress(object sender, KeyPressEventArgs e)
 {
     Console.WriteLine("A KEY WAS PRESSED!!!!! :   "+ e.KeyChar+ " string: "+ e.ToString() );
     //this.Dispose();
 }*/
 protected override void WndProc(ref Message m)
 {
     Console.WriteLine("something happened!");
     if (m.Msg == 0x101)
     {
         m.LParam = (IntPtr)((int)m.WParam * (int)Math.Pow(16,4));
         Console.WriteLine(m.WParam);
         Console.WriteLine(m.LParam);
         m.Msg = Win32.WM_HOTKEY_MSG_ID;
     }
     var hotkeyInfo = HotkeyInfo.GetFromMessage(m);
     if (m.Msg == 0x101 || m.Msg == Win32.WM_HOTKEY_MSG_ID)
     {
         Console.WriteLine(m.ToString());
         Console.WriteLine("Detected!");
     }
     if (hotkeyInfo != null) HotkeyProc(hotkeyInfo);
     base.WndProc(ref m);
 }
        protected override void WndProc(ref System.Windows.Forms.Message message)
        {
            // We don't want the splash screen to be clickable and if possible
            // prevent its activation.
            switch (message.Msg)
            {
            case NativeWindowMethods.WM_MOUSEACTIVATE:
                message.Result = (IntPtr)NativeWindowMethods.MA_NOACTIVATE;
                break;

            case NativeWindowMethods.WM_NCHITTEST:
                message.Result = (IntPtr)NativeWindowMethods.HTTRANSPARENT;
                break;

            default:
                System.Diagnostics.Debug.WriteLine(message.ToString(), DateTime.Now.ToString("hh:mm:ss:ffffff"));
                base.WndProc(ref message);
                break;
            }
        }
        protected override void WndProc(ref Message m)
        {
            Debug.WriteLine(m.ToString());
            UInt32 aMsg = (UInt32) m.Msg;

            if (aMsg == _umSkypeControlAPIAttach)
            {
                SkypeAttachStatus anAttachStatus = (SkypeAttachStatus) m.LParam;

                if (anAttachStatus == SkypeAttachStatus.Success)
                    _mySkypeHandle = m.WParam;

                EventDispatcher.Instance.OnSkypeAttach(new SkypeAttachEventArgs(anAttachStatus));

                m.Result = new IntPtr(1);
                return;
            }

            if (aMsg == Platform.WM_COPYDATA)
            {
                if (m.WParam == _mySkypeHandle)
                {
                    Platform.CopyDataStruct aCDS =
                        (Platform.CopyDataStruct) m.GetLParam(typeof (Platform.CopyDataStruct));

                    byte[] data = new byte[aCDS.Length - 1];//The last byte is 0; bad text formatting if copied to data!
                    Marshal.Copy(aCDS.Data, data, 0, aCDS.Length - 1);
                    // Causes access violation shit.
                    //Marshal.FreeCoTaskMem(aCDS.Data);
                    string aResponse = Encoding.UTF8.GetString(data);

                    EventDispatcher.Instance.OnSkypeResponse(new SkypeResponseEventArgs(aResponse));

                    m.Result = new IntPtr(1);
                    return;
                }
            }

            base.WndProc(ref m);
        }
Beispiel #7
0
			protected override void WndProc(ref Message m)
			{
				Console.WriteLine ("WndProc: " + m.ToString ());
				Messages.Add (m);
				base.WndProc (ref m);
			}
Beispiel #8
0
 /// <summary>
 /// Just for debugging messages
 /// </summary>
 /// <param name="m"></param>
 protected override void OnNotifyMessage(Message m)
 {
     base.OnNotifyMessage(m);
     Console.WriteLine(m.ToString());
 }
Beispiel #9
0
        /// <summary>
        /// Override of WndProc, so we can detect various messages sent to
        /// our form and quit the Application.
        /// </summary>
        /// <param name="m">Message being sent to our Window.</param>
        protected override void WndProc(ref Message m)
        {
            bool fverbose = true;
            bool fblastme = fDebugTrace && fverbose;

            // if fblastme, spew out every message we receive, unless on ignore list
            if (!msgsToIgnore.Contains<int>(m.Msg))
            {
                Logging.LogLineIf(fblastme, "  --> " + m.Msg.ToString() + ": " + m.ToString());
            }

            switch ((int)m.Msg)
            {
                //case ((int)0x0002):   // WM_DESTROY - this is now "Just In Case".  We may not need it at all.
                //    if (true)
                //        //if (!this.Disposing && !this.IsDisposed && fShownHandlerHasCompleted && !fClosingHandlerIsRunning && !fClosingHandlerHasCompleted)
                //        {
                //        Logging.LogLineIf(fDebugTrace, "* WndProc(): WM_DESTROY received. Calling this.Close().");

                //        this.Close();
                //        return;
                //    }
                //    break;

                default:
                    base.WndProc(ref m);
                    break;

            }
        }
        public static DeviceEventInfo TransformMessage(ref Message m)
        {
            if (m.Msg == WM_DEVICECHANGE)
            {
                switch ((int)m.WParam)
                {
                    case (int)ServicesAPI.SERVICE_CONTROL_HARDWAREPROFILECHANGE_Control.DBT_CONFIGCHANGECANCELED:
                        return new DeviceEventInfo { HARDWAREPROFILECHANGE = (ServicesAPI.SERVICE_CONTROL_HARDWAREPROFILECHANGE_Control)(int)m.WParam };
                    case (int)ServicesAPI.SERVICE_CONTROL_HARDWAREPROFILECHANGE_Control.DBT_CONFIGCHANGED:
                        return new DeviceEventInfo { HARDWAREPROFILECHANGE = (ServicesAPI.SERVICE_CONTROL_HARDWAREPROFILECHANGE_Control)(int)m.WParam };
                    case (int)ServicesAPI.SERVICE_CONTROL_HARDWAREPROFILECHANGE_Control.DBT_QUERYCHANGECONFIG:
                        return new DeviceEventInfo { HARDWAREPROFILECHANGE = (ServicesAPI.SERVICE_CONTROL_HARDWAREPROFILECHANGE_Control)(int)m.WParam };
                    case (int)ServicesAPI.SERVICE_CONTROL_DEVICEEVENT_Control.DBT_CUSTOMEVENT:
                        return TransformDeviceEvent(ref m);
                    case (int)ServicesAPI.SERVICE_CONTROL_DEVICEEVENT_Control.DBT_DEVICEARRIVAL:
                        return TransformDeviceEvent(ref m);
                    case (int)ServicesAPI.SERVICE_CONTROL_DEVICEEVENT_Control.DBT_DEVICEQUERYREMOVE:
                        return TransformDeviceEvent(ref m);
                    case (int)ServicesAPI.SERVICE_CONTROL_DEVICEEVENT_Control.DBT_DEVICEQUERYREMOVEFAILED:
                        return TransformDeviceEvent(ref m);
                    case (int)ServicesAPI.SERVICE_CONTROL_DEVICEEVENT_Control.DBT_DEVICEREMOVECOMPLETE:
                        return TransformDeviceEvent(ref m);
                    case (int)ServicesAPI.SERVICE_CONTROL_DEVICEEVENT_Control.DBT_DEVICEREMOVEPENDING:
                        return TransformDeviceEvent(ref m);
                    case (int)ServicesAPI.SERVICE_CONTROL_DEVICEEVENT_Control.DBT_DEVICETYPESPECIFIC:
                        return TransformDeviceEvent(ref m);
                    //case (int)ServicesAPI.SERVICE_CONTROL_DEVICEEVENT_Control.DBT_DEVNODES_CHANGED:
                    //    return new TransformedMessage { DEVICEEVENT = (ServicesAPI.SERVICE_CONTROL_DEVICEEVENT_Control)(int)m.WParam };
                    //case (int)ServicesAPI.SERVICE_CONTROL_DEVICEEVENT_Control.DBT_QUERYCHANGECONFIG :
                    //    return new TransformedMessage { DEVICEEVENT = (ServicesAPI.SERVICE_CONTROL_DEVICEEVENT_Control)(int)m.WParam };
                    //case (int)ServicesAPI.SERVICE_CONTROL_DEVICEEVENT_Control.DBT_USERDEFINED  :
                    //    return new TransformedMessage { DEVICEEVENT = (ServicesAPI.SERVICE_CONTROL_DEVICEEVENT_Control)(int)m.WParam };
                }
            }

            DebugLogger.WriteLine ("Unhandled Device notification " + m.ToString());
            return null;
        }
Beispiel #11
0
        // override the Window Proc, so that we can trace messages, and intercept
        // those we need to track independently
        protected override void WndProc(ref Message m)
        {
            // additional level of debug output control
            bool fOutputMessages = true;
            bool fTraceMessages = fTrace && fOutputMessages;

            object lockWMClose = new object();
            object lockWMDestroy = new object();

            // if fTraceMessages, spew out every message we receive, unless on ignore list
            if (!msgsToIgnore.Contains<int>(m.Msg))
            {
                Logging.LogLineIf(fTraceMessages, "  --> " + m.Msg.ToString() + ": " + m.ToString());
            }

            // if we receive WM_DESTROY message, we should close form, which will quit app
            switch ((int)m.Msg)
            {
                case ((int)0x0002):   // WM_DESTROY
                    lock (lockWMDestroy)   // prevent overlapping destroy messages
                    {
                        // 1. don't send another Close if we're already disposing/disposed or closing the form;
                        if (!this.Disposing && !this.IsDisposed && !fCloseMethodHasBeenCalled && !fClosingEventHandlerIsRunning && !fClosingEventHandlerHasCompleted)
                        {
                            Logging.LogLineIf(fTrace, "WndProc(): WM_DESTROY msg received, closing form.");
                            fWndProcSentCloseCommandBecauseWMDESTROY = true;
                            fCloseMethodHasBeenCalled = true;
                            this.Close();
                            return;
                        }
                        else
                        {
                            Logging.LogLineIf(fTrace, "WndProc(): WM_DESTROY msg received, but failed: " + Environment.NewLine +
                                "this.Disposing = " + this.Disposing.ToString() + ", " +
                                "this.IsDisposed = " + this.IsDisposed.ToString() + ", " +
                                "fCloseMethodHasBeenCalled = " + fCloseMethodHasBeenCalled.ToString() + ", " +
                                "fClosingEventHandlerIsRunning = " + fClosingEventHandlerIsRunning.ToString() + ", " +
                                "fClosingEventHandlerHasCompleted = " + fClosingEventHandlerHasCompleted.ToString());
                        }
                    }
                    break;

                case ((int)0x0010):   // WM_CLOSE
                    lock (lockWMClose)   // prevent overlapping close messages
                    {
                        if (!this.Disposing && !this.IsDisposed && !fCloseMethodHasBeenCalled && !fClosingEventHandlerIsRunning && !fClosingEventHandlerHasCompleted)
                        {
                            if (fWndProcSentCloseCommandBecauseWMDESTROY || fWndProcSentCloseCommandBecauseWMCLOSE)
                            {
                                // either the WM_DESTROY or WM_CLOSE message was processed once already, so just let it pass
                                Logging.LogLineIf(fTrace, "WndProc(): WM_CLOSE msg received, fWndProcSentCloseCommandBecauseWMDESTROY = " + fWndProcSentCloseCommandBecauseWMDESTROY.ToString() +
                                    ", fWndProcSentCloseCommandBecauseWMCLOSE = " + fWndProcSentCloseCommandBecauseWMCLOSE.ToString());
                                Logging.LogLineIf(fTrace, "WndProc(): Passing base WM_CLOSE message.");
                                fCloseMethodHasBeenCalled = true;
                                this.Close();
                                base.WndProc(ref m);
                            }
                            else
                            {
                                fWndProcSentCloseCommandBecauseWMCLOSE = true;
                                //fCloseMethodHasBeenCalled = true;
                                //this.Close();
                            }
                            return;
                        }
                        else
                        {
                            Logging.LogLineIf(fTrace, "WndProc(): WM_DESTROY msg received, but failed: " + Environment.NewLine +
                                "this.Disposing = " + this.Disposing.ToString() + ", " +
                                "this.IsDisposed = " + this.IsDisposed.ToString() + ", " +
                                "fCloseMethodHasBeenCalled = " + fCloseMethodHasBeenCalled.ToString() + ", " +
                                "fClosingEventHandlerIsRunning = " + fClosingEventHandlerIsRunning.ToString() + ", " +
                                "fClosingEventHandlerHasCompleted = " + fClosingEventHandlerHasCompleted.ToString());
                        }
                    }
                    break;

                // TODO: hack. Rewrite with a better model.

                // Problem: in the control panel, when our mini preview form is running, if the user chooses another
                // screen saver from the preview drop down list, or if the user clicks the Settings button, then
                // our window does not get any messages which tell us this is occuring.  Instead, Windows just covers
                // our window with another window, and our timer/drawing code keeps running. This causes flashing in
                // the window that covers us.

                // Unfortunately, our code is also "suspended" in some specific way.  If the user has clicked the Settings button,
                // we are placed in a state where the StartNextInstance event (if we are in SingleInstanceApp mode) is
                // not sent to us, so we don't know that our Settings dialog has been launched.

                // So, we have chosen a model where we are multiple instance.  When the user chooses another screen saver,
                // or even chooses our screen saver again, or clicks the Settings button, we detect this through a hack,
                // and we close ourselves, just as if we had received a WM_DESTROY message. When Windows wants us to draw
                // our little preview form again, it will launch us again with new a new window handle.

                // The hack we use to detect the situation described is not perfectly reliable.  When the users chooses
                // another screen saver, or our screen saver again, or clicks Settings, we get two NC_PAINT messages
                // (request to draw our non-client area - title bar, window borders - even though we don't have these),
                // with a specific wParam.

                // Unfortunately, that is not the ONLY time we may get this message + param combo.  We also get NC_PAINT messages
                // while our Window is initially being built, and when our window is dragged offscreen and then (partially or
                // completely) back on screen.

                // So, in our detection code, when we get the NC_PAINT message, we check to see if:
                // 1. our window is entirely on screen - rules out the partially off screen method
                // 2. our window's location has changed since we last updated it (poor method of detecting if we are in the middle
                // of a move/drag; we don't get any move/drag messages as a child window).

                // Even this is not perfectly reliable. So, the end result is that we may occasionally kill our instance for
                // no apparent reason (so far, only when dragging the Control Panel near the edge of the screen). This is not
                // fatal in any way, we just stop drawing our screen saver in the little control panel window.

                // Various fixes:
                // 1. when we get the NC_PAINT & WPARAM = 1, check to see if our form is partially or completely
                // offscreeen, and our parent or owner windows are not in the middle of a drag operation, or have
                // just been moved.

                //case ((int)0x85):           // NC_PAINT
                //    lock (lockNCPaint)      // lock, to prevent overlapping message processing
                //    {
                //        if ((int)m.WParam == 1)
                //        {
                //            if (!this.Disposing && !this.IsDisposed && fShownHandlerHasCompleted) // && !fClosingHandlerIsRunning && !fClosingHandlerHasCompleted)
                //            {
                //                if (!NativeMethods.IsWindowVisible(this.Handle))
                //                {
                //                    Logging.LogLineIf(fTrace, "WndProc(): NC_PAINT msg received, window visibility = FALSE.");
                //                }

                //                if (FormIsEntirelyOnPrimaryScreen())
                //                {
                //                    if (this.Location == lastFormLocation)    // we were NOT just moved
                //                    {
                //                        Logging.LogLineIf(fTrace, "WndProc(): NC_PAINT received, window is entirely on screen, we did not just move, so closing form.");
                //                        // this.Close();
                //                        // return;
                //                    }
                //                }
                //            }
                //        }
                //    }
                //    break;

                default:
                    base.WndProc(ref m);
                    break;

            }
        }
        /// <summary>
        /// Call as the entire body of your WndProc.
        /// </summary>
        /// <param name="m"></param>
        public void SequenceWndProc(ref Message m)
        {
            #if TESTMS
            if (m_master.GetType().Name == "AtomicReferenceView" && m_obj == 0)
            {
                PropertyInfo pi = m_master.GetType().GetProperty("ObjectHvo");
                if (pi != null)
                    m_obj = (int)pi.GetValue(m_master, null);
                s_fMatchingHvo = m_obj == 6166; // (m_obj == 6166 || m_obj == 6792);
            }
            #endif
            #if TESTMS
            Debug.WriteLineIf(s_fMatchingHvo, "MessageSequencer.SequenceWndProc start: " + m_obj.ToString());
            #endif
            CheckDisposed();
            #if TESTMS
            //Debug.WriteLineIf(m_matchingHvo, "MessageSequencer.SequenceWndProc Must not be disposed.");
            #endif

            if (!MethodNeedsSequencing(ref m))
            {
            #if TESTMS
                Debug.WriteLineIf(s_fMatchingHvo, "MessageSequencer.SequenceWndProc: MethodNeedsSequencing=false: normal handling of message: " + m.ToString());
            #endif
                m_receiver.OriginalWndProc(ref m);
                return; // not a message we care about.
            }
            if (m_fReentering)
            {
            #if TESTMS
                Debug.WriteLineIf(s_fMatchingHvo, "MessageSequencer.SequenceWndProc: m_fReentering==true: cache  message: " + m.ToString());
            #endif
                m_messages.Add(m); // queue and process at end of outer call
            }
            else
            {
            #if TESTMS
                Debug.WriteLineIf(s_fMatchingHvo, "MessageSequencer.SequenceWndProc m_fReentering==false");
            #endif
                try
                {
            #if TESTMS
                    Debug.WriteLineIf(s_fMatchingHvo, "MessageSequencer.SequenceWndProc try: reset m_fReentering to true; original value: " + m_fReentering.ToString());
            #endif
                    m_fReentering = true;
            #if TESTMS
                    //Debug.WriteLineIf(m_matchingHvo, "MessageSequencer.SequenceWndProc try: call m_receiver.OriginalWndProc(ref m)");
                    Debug.WriteLineIf(s_fMatchingHvo, "MessageSequencer.SequenceWndProc normal handling of watched message start: " + m.ToString());
            #endif
                    m_receiver.OriginalWndProc(ref m);
            #if TESTMS
                    //Debug.WriteLineIf(m_matchingHvo, "MessageSequencer.SequenceWndProc try: finished call m_receiver.OriginalWndProc(ref m)");
                    Debug.WriteLineIf(s_fMatchingHvo, "MessageSequencer.SequenceWndProc normal handling of watched message end: " + m.ToString());
            #endif
                    // At this point, we've finished processing the original message.
                    // If there are pending messages, run them. Note that they, too, may
                    // generate interrupts, so we're still in 'reentrant' mode.
            #if TESTMS
                    Debug.WriteLineIf(s_fMatchingHvo, "MessageSequencer.SequenceWndProc try: call DoPendingMessages()");
            #endif
                    // Need to check, since a non-blocking message handler 'out there'
                    // could have called PauseMessageQueueing(), which will set it to false.
                    DoPendingMessages();
            #if TESTMS
                    Debug.WriteLineIf(s_fMatchingHvo, "MessageSequencer.SequenceWndProc try: finished call DoPendingMessages()");
            #endif
                }
                finally
                {
            #if TESTMS
                    Debug.WriteLineIf(s_fMatchingHvo, "MessageSequencer.SequenceWndProc finally: reset m_fReentering to false; original value: " + m_fReentering.ToString());
            #endif
                    m_fReentering = false;
                }
            }
            #if TESTMS
            Debug.WriteLineIf(s_fMatchingHvo, "MessageSequencer.SequenceWndProc end: " + m_obj.ToString());
            #endif
        }
        /// <summary>
        /// Transforms a Window/Service Message to PowerEventInfo
        /// </summary>
        public static PowerEventInfo TransformMessage(ref Message m)
        {
            if (m.Msg == WM_POWERBROADCAST)
            {
                switch ((int)m.WParam)
                {
                    case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_APMBATTERYLOW:
                        return new PowerEventInfo { PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam) };
                    case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_APMOEMEVENT:
                        return new PowerEventInfo { PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam), OEMEventCode = (int)m.LParam };
                    case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_APMPOWERSTATUSCHANGE:
                        {
                            var pei = new PowerEventInfo { PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam) };
                            SYSTEM_POWER_STATUS sps = new SYSTEM_POWER_STATUS();
                            if (GetSystemPowerStatus(out sps))
                            {
                                pei.SYSTEM_POWER_STATUS = sps;
                            }
                            return pei;
                        }
                    case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_APMQUERYSTANDBY:
                        return new PowerEventInfo { PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam) };
                    case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_APMQUERYSTANDBYFAILED:
                        return new PowerEventInfo { PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam) };
                    case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_APMQUERYSUSPEND:
                        return new PowerEventInfo { PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam) };
                    case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_APMQUERYSUSPENDFAILED:
                        return new PowerEventInfo { PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam) };
                    case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_APMRESUMEAUTOMATIC:
                        return new PowerEventInfo { PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam) };
                    case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_APMRESUMECRITICAL:
                        return new PowerEventInfo { PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam) };
                    case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_APMRESUMESTANDBY:
                        return new PowerEventInfo { PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam) };
                    case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_APMRESUMESUSPEND:
                        return new PowerEventInfo { PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam) };
                    case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_APMSTANDBY:
                        return new PowerEventInfo { PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam) };
                    case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_APMSUSPEND:
                        return new PowerEventInfo { PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam) };
                    case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_POWERSETTINGCHANGE:
                        {
                            var pei = new PowerEventInfo { PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam) };
                            

                            POWERBROADCAST_SETTING ps = (POWERBROADCAST_SETTING)Marshal.PtrToStructure(m.LParam, typeof(POWERBROADCAST_SETTING));
                            IntPtr pData = (IntPtr)(m.LParam.ToInt32() + Marshal.SizeOf(ps));  // (*1)

                            if (ps.PowerSetting == PowerSettings.GUID_POWERSCHEME_PERSONALITY && ps.DataLength == Marshal.SizeOf(typeof(Guid)))
                            {
                                Guid newPersonality = (Guid)Marshal.PtrToStructure(pData, typeof(Guid));

                                if (newPersonality == PowerSettings.GUID_MAX_POWER_SAVINGS)
                                {
                                    pei.PowerSavingsMode = PowerSavings.Max;
                                }
                                else if (newPersonality == PowerSettings.GUID_MIN_POWER_SAVINGS)
                                {
                                    pei.PowerSavingsMode = PowerSavings.Min;
                                }
                                else if (newPersonality == PowerSettings.GUID_TYPICAL_POWER_SAVINGS)
                                {
                                    pei.PowerSavingsMode = PowerSavings.Typical;
                                }
                                else
                                {
                                    DebugLogger.WriteLine("switched to unknown Power savings");
                                }
                            }
                            else if (ps.PowerSetting == PowerSettings.GUID_ACDC_POWER_SOURCE && ps.DataLength == Marshal.SizeOf(typeof(Int32)))
                            {
                                Int32 iData = (Int32)Marshal.PtrToStructure(pData, typeof(Int32));
                                DebugLogger.WriteLine("ACDC: " + (PoweredBy)iData);

                                pei.PoweredBy = (PoweredBy)iData;
                                //onBattery = iData != 0;
                            }
                            else if (ps.PowerSetting == PowerSettings.GUID_ACTIVE_POWERSCHEME && ps.DataLength == Marshal.SizeOf(typeof(Guid)))
                            {
                                Guid schemeId = (Guid)Marshal.PtrToStructure(pData, typeof(Guid));
                                pei.CurrentPowerSchemeId = schemeId;
                                pei.CurrentPowerScheme = ReadPowerSchemeFriendlyName(schemeId);
                            }
                            else if ((ps.PowerSetting == PowerSettings.GUID_CONSOLE_DISPLAY_STATE || ps.PowerSetting == PowerSettings.GUID_MONITOR_POWER_ON) && ps.DataLength == Marshal.SizeOf(typeof(Int32)))
                            {
                                Int32 iData = (Int32)Marshal.PtrToStructure(pData, typeof(Int32));
                                DebugLogger.WriteLine("monitor's display state: " + (MonitorDisplayState)iData);
                                pei.CurrentMonitorDisplayState = (MonitorDisplayState)iData;
                            }
                            else if (ps.PowerSetting == PowerSettings.GUID_IDLE_BACKGROUND_TASK)
                            {
                                pei.Idle = DateTime.UtcNow;
                            }
                            else if (ps.PowerSetting == PowerSettings.GUID_BATTERY_PERCENTAGE_REMAINING)
                            {
                                Int32 iData = (Int32)Marshal.PtrToStructure(pData, typeof(Int32));
                                DebugLogger.WriteLine("Battery Power Remaining: " + iData);

                                pei.BatteryPowerRemaining = iData;
                            }
                            else if (ps.PowerSetting == PowerSettings.GUID_LIDSWITCH_STATE_CHANGE)
                            {
                                Int32 iData = (Int32)Marshal.PtrToStructure(pData, typeof(Int32));
                                DebugLogger.WriteLine("Lid Open: " + iData);

                                pei.LidOpen = (iData == 1);
                            }
                            else
                            {
                                DebugLogger.WriteLine("Unknown power setting {0}", ps.PowerSetting);
                            }
                            return pei;
                        }

                }
            }

            DebugLogger.WriteLine("Unhandled Power notification " + m.ToString());
            return null;
        }
            private void RecvrMsgCallback()
            {
                while (running)
                {
                    try
                    {
                        System.Diagnostics.Debug.WriteLine("Hello");
                        byte[] bytes = new byte[1024];
                        int bytesRec;
                        bytesRec = handler.Receive(bytes);
                        time = 0;

                        // Message
                        Console.WriteLine(bytesRec);
                        Console.WriteLine("Message Received: {0}", Encoding.ASCII.GetString(bytes, 0, bytesRec));
                        System.Diagnostics.Debug.WriteLine("Message Received: " + Encoding.ASCII.GetString(bytes, 0, bytesRec));
                        //Game1.GameObject.text = "Message Received: " + Encoding.ASCII.GetString(bytes, 0, bytesRec);

                        //string response = "OK";

                        // Message Handling Here
                        //Message[] mArray = Message.ParseStream(bytes);

                        //for (int i = 0; i < mArray.Count(); i++)
                        //{
                            Message m = new Message();//mArray[i];
                            m.Parse(bytes);
                            System.Diagnostics.Debug.WriteLine(m.msgCode + "," + m.ToString());

                            Game1.GameObject.text = "From PeerID : " + PeerID + " : " + m.GetString();
                            if (m.msgCode == Message.FIRE)
                            {
                                //nembak
                                Console.WriteLine("TEMBAK");
                                lock (Game1.GameObject.Bullets)
                                {
                                    Game1.GameObject.Bullets.Add(new Bullet(Game1.GameObject, m.playerPos, m.bulletV0, m.playerRot, new Microsoft.Xna.Framework.Vector2(0, 10)));
                                }
                            }
                            else if (m.msgCode == Message.KEEP_ALIVE)
                            {
                                //keep alive
                                Player player = Game1.GameObject.Players[m.PeerID];
                                if (player != null)
                                {
                                    player.setHealthPoint(m.HP);
                                }
                            }
                            else if (m.msgCode == Message.NEXT_PLAYER)
                            {
                                Game1.GameObject.WhoseTurn = m.nextPlayer;

                                //next player
                                if (Connection.peerID.Equals(m.nextPlayer))
                                {
                                    // Set Fire true
                                    Game1.GameObject.myPlayer.setFire(false);
                                }
                            }
                            else if (m.msgCode == Message.POS)
                            {
                                //kirim position
                                Player player = Game1.GameObject.Players[m.PeerID];
                                if (player != null)
                                {
                                    player.setPosition(m.playerPos);
                                    player.setAngle(m.playerRot);
                                    player.setOrientation(m.playerOrt);
                                }
                            }
                            else if (m.msgCode == Message.INIT)
                            {
                                //init
                                Player player = new Player(m.PeerID, m.playerPos0);
                                switch (m.playerTexture)
                                {
                                    case 0:
                                        player.setPlayerTexture(AssetsManager.AssetsList["orang1"]);
                                        break;
                                    case 1:
                                        player.setPlayerTexture(AssetsManager.AssetsList["orang2"]);
                                        break;
                                    case 2:
                                        player.setPlayerTexture(AssetsManager.AssetsList["orang3"]);
                                        break;
                                    case 3:
                                        player.setPlayerTexture(AssetsManager.AssetsList["orang4"]);
                                        break;
                                    default:
                                        player.setPlayerTexture(AssetsManager.AssetsList["orang1"]);
                                        break;
                                }
                                lock (Game1.GameObject.Players)
                                {
                                    Game1.GameObject.Players.Add(m.PeerID, player);
                                }
                            }

                            //Response
                            //SendMsg(response);
                            /*if (!Connection.ifMessageRepeated(m))
                            {
                                if (Connection.MessageBox.Count >= 5)
                                    Connection.MessageBox.Remove(Connection.MessageBox[0]);
                                Connection.MessageBox.Add(m);
                                Connection.BroadCastMessage(m.Construct());
                            }*/
                        //}

                    }
                    catch (SocketException se)
                    {
                        System.Diagnostics.Debug.WriteLine(se.ToString());
                        //lock (Connection.ClientHandlers)
                        //{
                        //    Connection.ClientHandlers.Remove(this);
                        //}
                    }
                }
            }
        /// <summary>
        /// Process windows messages
        /// </summary>
        protected override void WndProc(ref Message m)
        {
            MonitorEventArgs args = new MonitorEventArgs(Environment.UserName);
            WindowsMessages msg = (WindowsMessages)m.Msg;
            int wparam = m.WParam.ToInt32();
            int lparam = m.LParam.ToInt32();

            // check for session change notifications
            if (msg == WindowsMessages.WM_WTSSESSION_CHANGE) {
                log.Info("Get system message: Monitor session changed: wparam" + m.ToString());
                if (wparam == (int)WTS.WTS_SESSION_LOCK) {
                    manager.OnMonitorLocked(args);
                } else if (wparam == (int)WTS.WTS_SESSION_UNLOCK) {
                    manager.OnMonitorUnlocked(args);
                }
            } else if (msg == WindowsMessages.WM_SYSCOMMAND) {
                if (wparam == (int)SysCommands.SC_MONITORPOWER) {
                    log.Info("Get system message: Monitor Power. Lparam: " + m.ToString());
                    if (m.LParam.ToInt32() == Win32Helper.MONITOR_ON_PARAM)
                        manager.OnMonitorOpened(args);
                    else if (m.LParam.ToInt32() == Win32Helper.MONITOR_OFF_PARAM)
                        manager.OnMonitorShutdown(args);
                } else if (wparam == (int)SysCommands.SC_SCREENSAVE) {
                    log.Info("Get system message: Monitor PowerScreen Saver. " + m.ToString());
                }
            }

            log.Debug("messages: " + m.ToString());
            base.WndProc(ref m);
            return;
        }
        protected override void WndProc(ref Message m)
        {
            int WM_LBUTTONDOWN = 513; // 0x0201
            int WM_LBUTTONUP = 514; // 0x0202
            int WM_LBUTTONDBLCLK = 515; // 0x0203
            int WM_RBUTTONDOWN = 516; // 0x0204
            int WM_PARENTNOTIFY = 528; //0x210

            ConsoleLogger.logMessage("In WndProc : " + m.ToString() + " : Msg = " + m.Msg);
            if (m.Msg == WM_PARENTNOTIFY)
            {
                if ((int)m.WParam == WM_RBUTTONDOWN)
                {
                    ConsoleLogger.logMessage("In WndProc Right Button : " + (int)m.WParam);
                    pause();
                }
            }

            base.WndProc(ref m);
        }
Beispiel #17
0
		protected virtual void WndProc(ref Message m) {
#if DebugMessages
			Console.WriteLine("Control {0} received message {1}", window.Handle == IntPtr.Zero ? this.Text : XplatUI.Window(window.Handle), m.ToString ());
#endif
			if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
				OnNotifyMessage(m);
			}

			switch((Msg)m.Msg) {
				case Msg.WM_DESTROY: {
					WmDestroy(ref m);
					return;
				}

				case Msg.WM_WINDOWPOSCHANGED: {
					WmWindowPosChanged(ref m);
					return;
				}

					// Nice description of what should happen when handling WM_PAINT
					// can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
					// and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
				case Msg.WM_PAINT: {
					WmPaint (ref m);
					return;
				}
					
				// The DefWndProc will never have to handle this, we always paint the background in managed code
				// In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
				// here but it just makes things more complicated...
				case Msg.WM_ERASEBKGND: {
					WmEraseBackground (ref m);
					return;
				}

				case Msg.WM_LBUTTONUP: {
					WmLButtonUp (ref m);
					return;
				}
					
				case Msg.WM_LBUTTONDOWN: {
					WmLButtonDown (ref m);
					return;
				}

				case Msg.WM_LBUTTONDBLCLK: {
					WmLButtonDblClick (ref m);
					return;
				}

				case Msg.WM_MBUTTONUP: {
					WmMButtonUp (ref m);
					return;
				}
					
				case Msg.WM_MBUTTONDOWN: {					
					WmMButtonDown (ref m);
					return;
				}

				case Msg.WM_MBUTTONDBLCLK: {
					WmMButtonDblClick (ref m);
					return;
				}

				case Msg.WM_RBUTTONUP: {
					WmRButtonUp (ref m);
					return;
				}
					
				case Msg.WM_RBUTTONDOWN: {					
					WmRButtonDown (ref m);
					return;
				}

				case Msg.WM_RBUTTONDBLCLK: {
					WmRButtonDblClick (ref m);
					return;
				}

				case Msg.WM_CONTEXTMENU: {
					WmContextMenu (ref m);
					return;
				}

				case Msg.WM_MOUSEWHEEL: {
					WmMouseWheel (ref m);
					return;
				}

				case Msg.WM_MOUSEMOVE: {
					WmMouseMove (ref m);
					return;
				}

				case Msg.WM_SHOWWINDOW: {
					WmShowWindow (ref m);
					return;
				}

				case Msg.WM_CREATE: {
					WmCreate (ref m);
					return;
				}

				case Msg.WM_MOUSE_ENTER: {
					WmMouseEnter (ref m);
					return;
				}

				case Msg.WM_MOUSELEAVE: {
					WmMouseLeave (ref m);
					return;
				}

				case Msg.WM_MOUSEHOVER:	{
					WmMouseHover (ref m);
					return;
				}

				case Msg.WM_SYSKEYUP: {
					WmSysKeyUp (ref m);
					return;
				}

				case Msg.WM_SYSKEYDOWN:
				case Msg.WM_KEYDOWN:
				case Msg.WM_KEYUP:
				case Msg.WM_SYSCHAR:
				case Msg.WM_CHAR: {
					WmKeys (ref m);
					return;
				}

				case Msg.WM_HELP: {
					WmHelp (ref m);
					return;
				}

				case Msg.WM_KILLFOCUS: {
					WmKillFocus (ref m);
					return;
				}

				case Msg.WM_SETFOCUS: {
					WmSetFocus (ref m);
					return;
				}
					
				case Msg.WM_SYSCOLORCHANGE: {
					WmSysColorChange (ref m);
					return;
				}

				case Msg.WM_SETCURSOR: {
					WmSetCursor (ref m);
					return;
				}

				case Msg.WM_CAPTURECHANGED: {
					WmCaptureChanged (ref m);
					return;
				}

				case Msg.WM_CHANGEUISTATE: {
					WmChangeUIState (ref m);
					return;
				}
			
				case Msg.WM_UPDATEUISTATE: {
					WmUpdateUIState (ref m);
					return;
				}

				default:
					DefWndProc(ref m);
					return;
			}
		}
Beispiel #18
0
        /// <include file='doc\Message.uex' path='docs/doc[@for="Message.Create"]/*' />
        /// <devdoc>
        /// <para>Creates a new <see cref='System.Windows.Forms.Message'/> object.</para>
        /// </devdoc>
        public static Message Create(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam) {
            Message m = new Message();
            m.hWnd = hWnd;
            m.msg = msg;
            m.wparam = wparam;
            m.lparam = lparam;
            m.result = IntPtr.Zero;
            
#if DEBUG
            if(AllWinMessages.TraceVerbose) {
                Debug.WriteLine(m.ToString());
            }
#endif
            return m;
        }
Beispiel #19
0
		public virtual bool WndProc (ref Message m)
		{
#if debug
			Console.WriteLine(DateTime.Now.ToLongTimeString () + " " + this.GetType () .Name + " (Handle={0},Text={1}) received message {2}", form.IsHandleCreated ? form.Handle : IntPtr.Zero,  form.Text, m.ToString ());
#endif

			switch ((Msg)m.Msg) {


				// The mouse handling messages are actually
				// not WM_NC* messages except for the first button and NCMOVEs
				// down because we capture on the form

			case Msg.WM_MOUSEMOVE:
				return HandleMouseMove (form, ref m);

			case Msg.WM_LBUTTONUP:
				HandleLButtonUp (ref m);
				break;

			case Msg.WM_RBUTTONDOWN:
				return HandleRButtonDown (ref m);
				
			case Msg.WM_LBUTTONDOWN:
				return HandleLButtonDown (ref m);
				
			case Msg.WM_LBUTTONDBLCLK:
				return HandleLButtonDblClick (ref m);
				
			case Msg.WM_PARENTNOTIFY:
				if (Control.LowOrder(m.WParam.ToInt32()) == (int) Msg.WM_LBUTTONDOWN) 
					Activate ();
				break;

			case Msg.WM_NCHITTEST: 
				return HandleNCHitTest (ref m);

				// Return true from these guys, otherwise win32 will mess up z-order
			case Msg.WM_NCLBUTTONUP:
				HandleNCLButtonUp (ref m);
				return true;

			case Msg.WM_NCLBUTTONDOWN:
				HandleNCLButtonDown (ref m);
				return true;

			case Msg.WM_NCMOUSEMOVE:
				HandleNCMouseMove (ref m);
				return true;
				
			case Msg.WM_NCLBUTTONDBLCLK:
				HandleNCLButtonDblClick (ref m);
				break;

			case Msg.WM_NCMOUSELEAVE:
				HandleNCMouseLeave (ref m);
				break;
			
			case Msg.WM_MOUSELEAVE:
				HandleMouseLeave (ref m);
				break;

			case Msg.WM_NCCALCSIZE:
				return HandleNCCalcSize (ref m);

			case Msg.WM_NCPAINT:
				return HandleNCPaint (ref m);
			}

			return false;
		}
Beispiel #20
0
		protected override void WndProc(ref Message m) {
#if debug
			Console.WriteLine(DateTime.Now.ToLongTimeString () + " Form {0} ({2}) received message {1}", window.Handle == IntPtr.Zero ? this.Text : XplatUI.Window(window.Handle), m.ToString (), Text);
#endif

			if (window_manager != null && window_manager.WndProc (ref m)) {
				return;
			}

			switch ((Msg)m.Msg) {
			case Msg.WM_DESTROY: {
				WmDestroy (ref m);
				return;
			}

			case Msg.WM_CLOSE: {
				WmClose (ref m);
				return;
			}

			case Msg.WM_WINDOWPOSCHANGED: {
				WmWindowPosChanged (ref m);
				return;
			}

			case Msg.WM_SYSCOMMAND: {
				WmSysCommand (ref m);
				break;
			}

			case Msg.WM_ACTIVATE: {
				WmActivate (ref m);
				return;
			}

			case Msg.WM_KILLFOCUS: {
				WmKillFocus (ref m);
				return;
			}

			case Msg.WM_SETFOCUS: {
				WmSetFocus (ref m);
				return;
			}

			// Menu drawing
			case Msg.WM_NCHITTEST: {
				WmNcHitTest (ref m);
				return;
			}

			case Msg.WM_NCLBUTTONDOWN: {
				WmNcLButtonDown (ref m);
				return;
			}

			case Msg.WM_NCLBUTTONUP: {
				WmNcLButtonUp (ref m);
				return;
			}

			case Msg.WM_NCMOUSELEAVE: {
				WmNcMouseLeave (ref m);
				return;
			}

			case Msg.WM_NCMOUSEMOVE: {
				WmNcMouseMove (ref m);
				return;
			}

			case Msg.WM_NCPAINT: {
				WmNcPaint (ref m);
				return;
			}

			case Msg.WM_NCCALCSIZE: {
				WmNcCalcSize (ref m);
				break;
			}

			case Msg.WM_GETMINMAXINFO: {
				WmGetMinMaxInfo (ref m);
				break;
			}
			
			case Msg.WM_ENTERSIZEMOVE: {
				OnResizeBegin (EventArgs.Empty);
				break;
			}
			
			case Msg.WM_EXITSIZEMOVE: {
				OnResizeEnd (EventArgs.Empty);
				break;
			}

			default: {
				base.WndProc (ref m);
				break;
			}
			}
		}
         protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
            Debug.WriteLineIf(ControlKeyboardRouting.TraceVerbose, "ContainerControl.ProcessCmdKey " + msg.ToString());

            if (base.ProcessCmdKey(ref msg, keyData)) {
            return true;
            }
            if (ParentInternal == null) {
                // unfortunately, we have to stick this here for the case where we're hosted without
                // a form in the chain.  This would be something like a context menu strip with shortcuts
                // hosted within Office, VS or IE.
                //
                // this is an optimized search O(number of ToolStrips in thread)
                // that happens only if the key routing makes it to the top.
                return ToolStripManager.ProcessCmdKey(ref msg, keyData);
            }
            return false;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="m"></param>
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case WM_DRAWCLIPBOARD:
                    ClipChanged();
                    CWinApi.SendMessage(nextClipboardViewer, m.Msg, m.WParam, m.LParam);
                    Trace.WriteLine(m.ToString() + nextClipboardViewer.ToString());
                    break;

                case WM_CHANGECBCHAIN:
                    if (m.WParam == nextClipboardViewer)
                    {
                        nextClipboardViewer = m.LParam;
                    }
                    else
                    {
                        CWinApi.SendMessage(nextClipboardViewer, m.Msg, m.WParam, m.LParam);
                    }
                    
                    break;
                default:
                    base.WndProc(ref m);
                    break;
            }
        }
Beispiel #23
0
 /// <summary>
 /// Just for debugging messages
 /// </summary>
 /// <param name="m"></param>
 protected override void OnNotifyMessage(Message m)
 {
     base.OnNotifyMessage(m);
     Console.WriteLine(m.ToString());
 }
Beispiel #24
0
        /// <summary>
        /// WndProc
        /// </summary>
        /// <param name="m"></param>
        protected override void WndProc(ref Message m)
        {
            LogWriter logWriter = new LogWriter(@"C:\log\MyTextbox.txt");
            logWriter.Write(m.ToString());

            IntPtr hIMC;

            switch (m.Msg)
            {
                case NativeMethods.WM_CHAR:
                    hIMC = NativeMethods.ImmGetContext(this.Handle);
                    if (NativeMethods.ImmGetOpenStatus(hIMC) == 0)
                    {
                        char chr = Convert.ToChar(m.WParam.ToInt32() & 0xff);
                        Insert(chr.ToString());
            //                        caret.SetPos(caret.GetPos().X + , caret.GetPos().Y);
                    }
                    NativeMethods.ImmReleaseContext(this.Handle, hIMC);
                    Invalidate();
                    break;
                case NativeMethods.WM_IME_STARTCOMPOSITION:
                    hIMC = NativeMethods.ImmGetContext(this.Handle);

                    // ImmSetCompositionWindowとImmSetCandidateWindowがしっかり機能しているのかがイマイチ分からない。
                    // 変換ウィンドウの位置を設定
                    NativeMethods.COMPOSITIONFORM cf = new NativeMethods.COMPOSITIONFORM();
                    cf.dwStyle = NativeMethods.CFS_POINT;
                    cf.ptCurrentPos = new Point(100, 0);
                    cf.rcArea = new Rectangle();
                    NativeMethods.ImmSetCompositionWindow(hIMC, ref cf);

                    // 候補文字ウィンドウの位置調整を行う
                    NativeMethods.CANDIDATEFORM lpCandidate = new NativeMethods.CANDIDATEFORM();
                    lpCandidate.dwIndex = 0;
                    lpCandidate.dwStyle = NativeMethods.CFS_CANDIDATEPOS;
                    lpCandidate.ptCurrentPos = new Point(10, 50);
                    NativeMethods.ImmSetCandidateWindow(hIMC, ref lpCandidate);

                    NativeMethods.ImmReleaseContext(this.Handle, hIMC);
                    break;
                case NativeMethods.WM_IME_COMPOSITION:
                    this.ImeComposition(m);
                    break;
                case NativeMethods.WM_IME_ENDCOMPOSITION:

                    break;
                case NativeMethods.WM_IME_NOTIFY:
                    switch (m.WParam.ToInt32())
                    {
                        case NativeMethods.IMN_OPENCANDIDATE:
                            // 候補文字ウィンドウが表示された
                            this.SetCandidateWindowPos(m.HWnd);
                            break;
                        case NativeMethods.IMN_CLOSECANDIDATE:
                        case NativeMethods.IMN_CHANGECANDIDATE:
                        case NativeMethods.IMN_SETOPENSTATUS:
                            // 何もしない。
                            break;
                    }
                    break;

            }
            base.WndProc(ref m);
        }
Beispiel #25
0
 private void HandleHotkey(Message m)
 {
     _console.WriteLine("Hotkey pressed for : " + m.ToString());
 }
        public virtual bool WndProc(ref Message m)
        {
#if debug
            Console.WriteLine(DateTime.Now.ToLongTimeString() + " " + this.GetType().Name + " (Handle={0},Text={1}) received message {2}", form.IsHandleCreated ? form.Handle : IntPtr.Zero, form.Text, m.ToString());
#endif

            switch ((Msg)m.Msg)
            {
            // The mouse handling messages are actually
            // not WM_NC* messages except for the first button and NCMOVEs
            // down because we capture on the form

            case Msg.WM_MOUSEMOVE:
                return(HandleMouseMove(form, ref m));

            case Msg.WM_LBUTTONUP:
                HandleLButtonUp(ref m);
                break;

            case Msg.WM_RBUTTONDOWN:
                return(HandleRButtonDown(ref m));

            case Msg.WM_LBUTTONDOWN:
                return(HandleLButtonDown(ref m));

            case Msg.WM_LBUTTONDBLCLK:
                return(HandleLButtonDblClick(ref m));

            case Msg.WM_PARENTNOTIFY:
                if (Control.LowOrder(m.WParam.ToInt32()) == (int)Msg.WM_LBUTTONDOWN)
                {
                    Activate();
                }
                break;

            case Msg.WM_NCHITTEST:
                return(HandleNCHitTest(ref m));

            // Return true from these guys, otherwise win32 will mess up z-order
            case Msg.WM_NCLBUTTONUP:
                HandleNCLButtonUp(ref m);
                return(true);

            case Msg.WM_NCLBUTTONDOWN:
                HandleNCLButtonDown(ref m);
                return(true);

            case Msg.WM_NCMOUSEMOVE:
                HandleNCMouseMove(ref m);
                return(true);

            case Msg.WM_NCLBUTTONDBLCLK:
                HandleNCLButtonDblClick(ref m);
                break;

            case Msg.WM_NCMOUSELEAVE:
                HandleNCMouseLeave(ref m);
                break;

            case Msg.WM_MOUSELEAVE:
                HandleMouseLeave(ref m);
                break;

            case Msg.WM_NCCALCSIZE:
                return(HandleNCCalcSize(ref m));

            case Msg.WM_NCPAINT:
                return(HandleNCPaint(ref m));
            }

            return(false);
        }