本文整理汇总了C#中System.Windows.Forms.Message.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Message.ToString方法的具体用法?C# Message.ToString怎么用?C# Message.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Message
的用法示例。
在下文中一共展示了Message.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WndProc
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);
}
示例2: WndProc
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);
}
示例3: WndProc
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);
}
}
示例4: KeybindingPrompt_KeyPress
/*
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);
}
示例5: WndProc
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);
}
示例6: ProcessCmdKey
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;
}
示例7: SequenceWndProc
/// <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
}
示例8: WndProc
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;
}
示例9: WndProc
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;
}
//.........这里部分代码省略.........
示例10: WndProc
protected override void WndProc(ref Message m)
{
Console.WriteLine ("WndProc: " + m.ToString ());
Messages.Add (m);
base.WndProc (ref m);
}
示例11: TransformMessage
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;
}
示例12: WndProc
/// <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;
}
示例13: WndProc
/// <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);
}
示例14: WndProc
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;
}
//.........这里部分代码省略.........
示例15: Create
/// <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;
}