/// <summary> /// /// </summary> /// <param name="m"></param> protected override void WndProc(ref System.Windows.Forms.Message m) { switch (m.Msg) { case WM_NOTIFY: { base.WndProc(ref m); NMHDR nm1 = ( NMHDR )m.GetLParam(typeof(NMHDR)); switch (nm1.code) { case ( int )NotificationMessages.NM_CUSTOMDRAW: { m.Result = ( IntPtr )CustomDrawReturnFlags.CDRF_DODEFAULT; NMCUSTOMDRAW nmcd = ( NMCUSTOMDRAW )m.GetLParam(typeof(NMCUSTOMDRAW)); switch (nmcd.dwDrawStage) { case ( int )CustomDrawDrawStateFlags.CDDS_PREPAINT: CddsPrePaint(ref m); break; case ( int )CustomDrawDrawStateFlags.CDDS_POSTPAINT: CddsPostPaint(ref m); break; case ( int )CustomDrawDrawStateFlags.CDDS_ITEMPREPAINT: CddsItemPrePaint(ref m); break; case ( int )CustomDrawDrawStateFlags.CDDS_ITEMPOSTPAINT: CddsItemPostPaint(ref m); break; case ( int )CustomDrawDrawStateFlags.CDDS_SUBITEMPREPAINT: CddsSubItemPrePaint(ref m); break; case ( int )CustomDrawDrawStateFlags.CDDS_SUBITEMPOSTPAINT: CddsSubItemPostPaint(ref m); break; } } break; } } break; default: base.WndProc(ref m); break; } }
protected override void DefWndProc(ref System.Windows.Forms.Message m) { string token = ""; COPYDATASTRUCT mystr; Type mytype = null; //MessageBox.Show(m.Msg.ToString()); switch (m.Msg) { case WM_MESSAGE: mystr = new COPYDATASTRUCT(); mytype = mystr.GetType(); mystr = (COPYDATASTRUCT)m.GetLParam(mytype); token = mystr.bstrData; eterm_bga.is_eterm_status = mystr.bstrData; eterm_bga.ib_connect_status = false; eterm_bga.ib_dataflag = false; // MessageBox.Show(this, mystr.bstrData, mystr.bstrCategory); break; case WM_DATA: mystr = new COPYDATASTRUCT(); mytype = mystr.GetType(); mystr = (COPYDATASTRUCT)m.GetLParam(mytype); token = mystr.bstrData; ShowData(token); break; case WM_CTX: mystr = new COPYDATASTRUCT(); mytype = mystr.GetType(); mystr = (COPYDATASTRUCT)m.GetLParam(mytype); token = mystr.bstrToken; CreatingCtx((int)m.WParam, token); break; default: base.DefWndProc(ref m); if (eterm_bga.ib_connect_status) { eterm_bga.is_eterm_status = "Host system down"; eterm_bga.ib_connect_status = false; eterm_bga.ib_dataflag = false; } break; } }
/// <summary> /// 接收消息 /// </summary> /// <param name="m"></param> protected override void DefWndProc(ref System.Windows.Forms.Message m) { switch (m.Msg) { case NativeMethods.WM_COPYDATA: COPYDATASTRUCT mystr = new COPYDATASTRUCT(); Type mytype = mystr.GetType(); mystr = (COPYDATASTRUCT)m.GetLParam(mytype); if (mystr.lpData.StartsWith("open")) { showDetail(mystr.lpData.Substring(mystr.lpData.IndexOf("-") + 1), true); } else if (mystr.lpData.StartsWith("manualopen")) { showDetail(mystr.lpData.Substring(mystr.lpData.IndexOf("-") + 1), false); } else if (mystr.lpData.StartsWith("close")) { closeDetail(); } else { Detail_1.WINDOW_HANDLER = int.Parse(mystr.lpData); } break; default: base.DefWndProc(ref m); //MessageBox.Show("no"); break; } }
protected override void DefWndProc(ref System.Windows.Forms.Message m) { switch (m.Msg) { case WM_COPYDATA: COPYDATASTRUCT mystr = new COPYDATASTRUCT(); Type mytype = mystr.GetType(); mystr = (COPYDATASTRUCT)m.GetLParam(mytype); WndProcAgreement comm = StrToObject(mystr.lpData); if (comm.Identifier == WndProcAgreement_Identifiter.Activate) { Console.WriteLine(comm.Identifier); this.Activate(); //this.Close(); } else if (comm.Identifier == WndProcAgreement_Identifiter.Close) { this.Close(); } break; default: base.DefWndProc(ref m); break; } }
private static void // ERROR: Handles clauses are not supported in C# MainForm_WndProc(System.Windows.Forms.Message m, ref bool Cancel) { switch (m.Msg) { case WM_COPYDATA: byte[] B; try { COPYDATASTRUCT CD = m.GetLParam(typeof(COPYDATASTRUCT)); // ERROR: Not supported in C#: ReDimStatement IntPtr lpData = new IntPtr(CD.lpData); Marshal.Copy(lpData, B, 0, CD.cbData); string strData = Encoding.Default.GetString(B); MainForm.HandleCommand(strData); MainForm.SetToForeground(); Cancel = true; } catch { Cancel = false; } finally { B = null; } default: Cancel = false; } }
protected override void DefWndProc(ref System.Windows.Forms.Message m) { switch (m.Msg) { // 接收 CopyData 消息,读取发送过来的数据 case WM_COPYDATA: COPYDATASTRUCT cds = new COPYDATASTRUCT(); Type mytype = cds.GetType(); cds = (COPYDATASTRUCT)m.GetLParam(mytype); uint flag = (uint)(cds.dwData); byte[] bt = new byte[cds.cbData]; Marshal.Copy(cds.lpData, bt, 0, bt.Length); object obj = SerializeUtil.Deserialize(bt); NameEntity nameEntity = (NameEntity)obj; if (OnReceiveBytes != null) { OnReceiveBytes(this, flag, bt); } break; default: base.DefWndProc(ref m); break; } }
protected override void WndProc(ref Message m) { switch (m.Msg) { case WindowNative.WM_COPYDATA: // Get the COPYDATASTRUCT struct from LParam COPYDATASTRUCT cds = (COPYDATASTRUCT)m.GetLParam( typeof(COPYDATASTRUCT)); if (cds.cbData == Marshal.SizeOf(typeof(MyStruct))) { // Marshal the data from the unmanaged memory block object data = Marshal.PtrToStructure(cds.lpData, typeof(MyStruct)); // Cast the data to MyStruct MyStruct myStruct = (MyStruct)data; // Display the MyStruct data this.lbNumber.Text = myStruct.nNumber.ToString(); this.lbMessage.Text = myStruct.strMessage; } break; } base.WndProc(ref m); }
//接收消息 protected override void DefWndProc(ref System.Windows.Forms.Message m) { try { switch (m.Msg) { case WM_COPYDATA: COPYDATASTRUCT mystr1 = new COPYDATASTRUCT(); Type mytype = mystr1.GetType(); mystr1 = (COPYDATASTRUCT)m.GetLParam(mytype); //this.textBoxPass.Text = mystr1.lpData; m.Result = Marshal.StringToHGlobalAnsi("222"); CallDll.CallDll(mystr1.lpData.Replace("CALL_SOURCE=1", "")); //strError = "测试"; //char[] cError = strError.ToCharArray(); //int len = cError.Length; //m.Result = (IntPtr)len; //strError = CallDll.CallDll(mystr.lpData); break; default: base.DefWndProc(ref m); break; } } catch { } }
protected override void DefWndProc(ref System.Windows.Forms.Message m) { if (m.Msg == (int)MessageType.UpdateProgressBar) { if (receive_progressBar.Value < receive_progressBar.Maximum - 1) { receive_progressBar.Value++; } } else if (m.Msg == (int)MessageType.FileReceiveSuccess) { receive_progressBar.Value = receive_progressBar.Maximum; MessageBox.Show("文件接收完毕"); string savePath = Path.Combine(new string[] { ChatRoom.DOWNLOAD_DIR, Path.GetFileName(filePath) }); Process.Start("explorer.exe", "/select, " + savePath); this.Close(); } else if (m.Msg == (int)MessageType.FileReceiveError) { Win32API.My_lParam ml = new Win32API.My_lParam(); Type t = ml.GetType(); ml = (Win32API.My_lParam)m.GetLParam(t); MessageBox.Show(ml.s); this.Close(); } else { base.DefWndProc(ref m); } }
protected override void WndProc(ref System.Windows.Forms.Message m) { base.WndProc(ref m); switch (m.Msg) { case (int)ReflectedMessages.OCM_DRAWITEM: { DrawItemStruct dis = (DrawItemStruct)m.GetLParam(typeof(DrawItemStruct)); Graphics graph = Graphics.FromHdc(dis.hDC); Rectangle rect = new Rectangle(dis.rcItem.left, dis.rcItem.top, dis.rcItem.right - dis.rcItem.left, dis.rcItem.bottom - dis.rcItem.top); int index = dis.itemID; DrawItemState state = DrawItemState.None; System.Windows.Forms.DrawItemEventArgs e = new System.Windows.Forms.DrawItemEventArgs(graph, Font, rect, index, state, ForeColor, BackColor); if (this.DrawItem != null) { this.DrawItem(this, e); } OnDrawItem(e); graph.Dispose(); break; } case 8236: WmReflectMeasureItem(ref m); break; } }
/// <summary> /// Override the DefWndProc function, in order to receive the message through it. /// </summary> /// <param name="m">message</param> protected override void DefWndProc(ref System.Windows.Forms.Message m) { switch (m.Msg) { // Here, we use WM_COPYDATA message to receive the COPYDATASTRUCT case CSharpProxy.ProxyObject.WM_DATA_TRANSFER: CSharpProxy.ProxyObject.COPYDATASTRUCT cds = new CSharpProxy.ProxyObject.COPYDATASTRUCT(); cds = (CSharpProxy.ProxyObject.COPYDATASTRUCT)m.GetLParam(typeof(CSharpProxy.ProxyObject.COPYDATASTRUCT)); byte[] bytData = new byte[cds.cbData]; Marshal.Copy(cds.lpData, bytData, 0, bytData.Length); var msg = Encoding.Default.GetString(bytData); var msgInfo = CSharpProxy.EactMsgInfo.DeserializeObject(msg); if (msgInfo.Type == 0) { DispMsg(msgInfo.Msg); } else { DispMsg(msgInfo.Msg, listBox2); } break; default: base.DefWndProc(ref m); break; } }
protected override void DefWndProc(ref System.Windows.Forms.Message m) { switch (m.Msg) { case Win32API.WM_SYSCOMMAND: //prevent the form from being moved int command = m.WParam.ToInt32() & 0xfff0; if (command == Win32API.SC_MOVE) { return; } break; case Win32API.WM_COPYDATA: mystr = (COPYDATASTRUCT)m.GetLParam(mystr.GetType()); String[] type_params = mystr.lpData.Split(this.SplitArray, StringSplitOptions.RemoveEmptyEntries); String Type = type_params[0]; String[] parameters = type_params.Skip(1).ToArray <String>(); CustomDataDelegate customDeal = lookup[Type]; customDeal(parameters); break; default: base.DefWndProc(ref m); break; } }
protected override void WndProc(ref Message m) { if (m.Msg == 74) { Type type = new MessageHelper.COPYDATASTRUCT().GetType(); MessageHelper.COPYDATASTRUCT copydatastruct = (MessageHelper.COPYDATASTRUCT)m.GetLParam(type); try { IntPtr num = new IntPtr(m.WParam.ToInt32()); string str = string.Copy(copydatastruct.lpData); foreach (D2Profile pro in HandlerClass.Instance.bpro) { if (pro.D2Process.MainWindowHandle == pro.D2Process.MainWindowHandle)//Cheking For the real Window so its not wrong one! This fix will allow more clients! HandlerClass.Instance.HandleMessage(num, str); } } catch { } m.Result = (IntPtr)1; } base.WndProc(ref m); }
protected override void WndProc(ref Message m) { switch (m.Msg) { case Win32FunctionHelper.MouseMove.WM_MOVING: case Win32FunctionHelper.MouseMove.WM_SIZING: { if (this.Visible) { RECT prc = (RECT)m.GetLParam(typeof(RECT)); if (this.m_isMiniMode == true && this.m_isUsingSystemTrayMode == false) { Screen currentScreen = Screen.FromPoint(this.Location); int currentLeft = currentScreen.WorkingArea.Right - 64; Win32FunctionHelper.SetWindowPos(m.HWnd, (IntPtr)Win32FunctionHelper.CmdShow.HWND_TOP, currentLeft, prc.Top, 64, prc.Bottom - prc.Top, 0); } else { Win32FunctionHelper.SetWindowPos(m.HWnd, (IntPtr)Win32FunctionHelper.CmdShow.HWND_TOP, prc.Left, prc.Top, prc.Right - prc.Left, prc.Bottom - prc.Top, 0); } } } break; default: break; } base.WndProc(ref m); }
/// <summary> /// 接收消息 /// </summary> /// <example> /// 在窗体中覆盖接收消息函数 /// protected override void DefWndProc(ref System.Windows.Forms.Message m) /// { /// switch(m.Msg) /// { /// case WinMessageHelper.WM_COPYDATA: /// string str = WinMessageHelper.Receive(ref m); /// break; /// default: /// base.DefWndProc(ref m); /// break; /// /// } /// } public static string Receive(ref System.Windows.Forms.Message m) { COPYDATASTRUCT cds = new COPYDATASTRUCT(); Type cdsType = cds.GetType(); cds = (COPYDATASTRUCT)m.GetLParam(cdsType); return(cds.lpData); }
public static string ReciveMessage(ref Message m) { COPYDATASTRUCT mystr = new COPYDATASTRUCT(); Type mytype = mystr.GetType(); mystr = (COPYDATASTRUCT)m.GetLParam(mytype); string data = mystr.lpData; Debug.WriteLine("WM_COPYDATA message:" + data); return data; }
protected override void WndProc(ref System.Windows.Forms.Message m) { if (m.Msg == WM_COPYDATA) { COPYDATASTRUCT cds = (COPYDATASTRUCT)m.GetLParam(typeof(COPYDATASTRUCT)); OnAddNewLog(cds.lpData); } base.WndProc(ref m); }
protected override void WndProc(ref Message m) { switch (m.Msg) { case 0x302: if (OnTextPasted != null) { string text = (string)m.GetLParam(m.GetType()); base.WndProc(ref m); OnTextPasted.Invoke(this, new EventArgs()); } else { string text = (string)m.GetLParam(m.GetType()); base.WndProc(ref m); } break; default: base.WndProc(ref m); break; } }
// protected override void WndProc(ref System.Windows.Forms.Message e) { if (e.Msg == WM_COPYDATA) { CopyDataStruct cds = (CopyDataStruct)e.GetLParam(typeof(CopyDataStruct)); //将文本信息显示到文本框 string reuselt = cds.lpData.Trim(); string[] reustype = reuselt.Split('_'); } base.WndProc(ref e); }
/// <summary> /// Overwritten window handler, that intercepts the NM_CUSTOMDRAW message and ignores it. /// </summary> /// <param name="m"></param> protected override void WndProc(ref Message m) { if (m.Msg == 0x204E) { NMHDR hdr = (NMHDR)m.GetLParam(typeof(NMHDR)); if (hdr.code == NM_CUSTOMDRAW) { m.Result = (IntPtr)0; return; } } base.WndProc(ref m); }
protected override void WndProc(ref System.Windows.Forms.Message m) { var P_DBT_DEVICEARRIVAL = new IntPtr(DBT_DEVICEARRIVAL); try { if (m.Msg == WM_DEVICECHANGE) { debug("WM_DEVICECHANGE"); // http://msdn.microsoft.com/en-us/library/aa363205.aspx if (m.WParam == P_DBT_DEVICEARRIVAL) { debug("DBT_DEVICEARRIVAL"); // http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.framework.interop/2007-01/msg00224.html DEV_BROADCAST_HDR hdr = (DEV_BROADCAST_HDR)m.GetLParam(typeof(DEV_BROADCAST_HDR)); if (hdr.dbch_DeviceType == DBT_DEVTYP_VOLUME) { debug("DBT_DEVTYP_VOLUME"); DEV_BROADCAST_VOLUME vol = (DEV_BROADCAST_VOLUME)m.GetLParam(typeof(DEV_BROADCAST_VOLUME)); //debug(String.Format("vol.dbcv_flags & DBTF_MEDIA == {0}", vol.dbcv_flags & DBTF_MEDIA)); if ((vol.dbcv_flags & DBTF_MEDIA) == 0) { debug("DBTF_MEDIA"); debug(String.Format("vol.dbcv_unitmask : {0}", vol.dbcv_unitmask)); var unitmask = vol.dbcv_unitmask; var letters = GetDriveLettersFromMask(unitmask); CheckDriveLetters(letters); } } } } } catch (Exception ex) { DisplayException(ex); throw ex; } base.WndProc(ref m); }
/// <summary> /// 获取消息类型为 WM_COPYDATA 中的数据 /// </summary> /// <param name="m"></param> /// <param name="dwData">附加数据</param> /// <param name="lpdata">接收到的发送数据</param> public static void ReceivCopyData(ref System.Windows.Forms.Message m, out int dwData, out byte[] lpdata) { COPYDATASTRUCT cds = (COPYDATASTRUCT)m.GetLParam(typeof(COPYDATASTRUCT)); dwData = cds.dwData.ToInt32(); lpdata = new byte[cds.cbData]; Marshal.Copy(cds.lpData, lpdata, 0, cds.cbData); m.Result = (IntPtr)0; }
protected override void WndProc(ref Message m) { if(m.Msg==QuizRoom.WM_COPYDATA) { if(isRunning) { QuizRoom.COPYDATASTRUCT dataStruct=(QuizRoom.COPYDATASTRUCT)m.GetLParam(typeof(QuizRoom.COPYDATASTRUCT)); ThreadPool.QueueUserWorkItem(callbackThread,dataStruct.lpData); } return; } base.WndProc (ref m); }
protected override void WndProc(ref Message m) { if (m.Msg == TCM_ADJUSTRECT) { RECT rc = (RECT)m.GetLParam(typeof(RECT)); rc.Left -= 3; rc.Right += 0; rc.Top -= 1; rc.Bottom += 2; Marshal.StructureToPtr(rc, m.LParam, true); } base.WndProc(ref m); }
protected override void WndProc(ref Message m) { base.WndProc(ref m); // trap TVM_SETITEM message if (m.Msg == TVM_SETITEM || m.Msg == TVM_SETITEMA || m.Msg == TVM_SETITEMW) // check if CheckBoxes are turned on if (CheckBoxes) { // get information about the node TV_ITEM tv_item = (TV_ITEM)m.GetLParam(typeof(TV_ITEM)); HideCheckBox(tv_item); } }
protected override void WndProc(ref Message m) { if (m.Msg == Interop.WindowMessages.WM_REFLECT + Interop.WindowMessages.WM_NOTIFY) { NativeMethods.NMHDR nmh = (NativeMethods.NMHDR)m.GetLParam(typeof(NativeMethods.NMHDR)); if (nmh.code == NativeMethods.NM_CUSTOMDRAW) { OnCustomDraw(ref m); return; } } base.WndProc(ref m); }
protected override void WndProc(ref Message m) { switch (m.Msg) { case Win32Api.WM_COPYDATA: Type tp = typeof(MyModel); MyModel model = (MyModel)m.GetLParam(tp); textBox1.Text = model.LpData; break; default: base.WndProc(ref m); break; } }
protected override void WndProc(ref wfMsg m) { base.WndProc(ref m); if (DesignMode || m.Msg != WM_REFLECT + WM_NOTIFY) { return; } var nm = (NMHDR)m.GetLParam(typeof(NMHDR)); if (nm.code == DTN_DATETIMECHANGE) { OnValueChangedSpecial(); } }
/// <summary> /// 接收来自详细页面的消息 /// </summary> /// <param name="m"></param> protected override void DefWndProc(ref System.Windows.Forms.Message m) { switch (m.Msg) { case NativeMethods.WM_COPYDATA: COPYDATASTRUCT mystr = new COPYDATASTRUCT(); Type mytype = mystr.GetType(); mystr = (COPYDATASTRUCT)m.GetLParam(mytype); if (mystr.lpData.StartsWith("isdetailclick")) { LogUtil.debug("isdetailclick:" + mystr.lpData); ControlCenter.pauseTime = DateTime.Now; ControlCenter.isPause = true; } else if (mystr.lpData.StartsWith("startindex")) //回首页 { LogUtil.debug("startindex:" + mystr.lpData); cc.playIndex(); } else if (mystr.lpData.StartsWith("nextdetail")) //播放下一个详情页面 { LogUtil.debug("nextdetail:" + mystr.lpData); ControlCenter.isColseDetail = true; } else if (mystr.lpData.StartsWith("exit")) //退出系统 { //先kill SystemUtil.KillProcess("sungrow_touch"); //先清理资源再退出程序 if (Main.cc != null) { Main.cc.clear(); } //为防本程序的进程不能成功退出而导致GE出现问题,强制杀掉本程序的进程 //System.Diagnostics.Process geProcess = System.Diagnostics.Process.GetCurrentProcess(); //geProcess.Kill(); this.Close(); LogUtil.debug("exit:" + mystr.lpData); Environment.Exit(0); } break; default: base.DefWndProc(ref m); //MessageBox.Show("no"); break; } }
protected override void DefWndProc(ref System.Windows.Forms.Message m) { switch (m.Msg) { case 0x004A: //处理消息 COPYDATASTRUCT mystr = new COPYDATASTRUCT(); Type mytype = mystr.GetType(); mystr = (COPYDATASTRUCT)m.GetLParam(mytype); //MessageBox.Show(mystr.lpData); string txt_messege = mystr.lpData; string[] txts = SGFunction.DataOperate.ConvertStringsToStringArryBySTR(txt_messege, " "); //MessageBox.Show(txts.Length.ToString()); string ct; string[] args; SGFunction.RunCommand.GetCommandArgsDetails(txts, out ct, out args); if (ct.ToUpper() == "?" || ct.ToUpper() == "S") { if (ct.ToUpper() == "S") { bool p = SGFunction.RunCommand.ShellSGFunction(this, this.sgstyfrm, args[0], out this.sgstyfrm); if (p == true) { this.Visible = true; this.Hide(); } else { this.Visible = true; } } else { SGFunction.RunCommand.ShellTextFile("command"); } } break; default: base.DefWndProc(ref m); //调用基类函数处理非自定义消息。 break; } }
protected override void WndProc(ref Message m) { switch (m.Msg) { case NativeMethods.WM_NOTIFY: var nmhdr = (NativeMethods.NMHDR)m.GetLParam(typeof(NativeMethods.NMHDR)); switch (nmhdr.code) { case NativeMethods.LVN_GETEMPTYMARKUP: if (Control.FromHandle(nmhdr.hwndFrom) == listViewFileList) { var markup = (NativeMethods.NMLVEMPTYMARKUP)m.GetLParam(typeof(NativeMethods.NMLVEMPTYMARKUP)); markup.szMarkup = "要添加文件,请单击“导入”按钮;或将文件拖曳到此处;或双击空白处。"; Marshal.StructureToPtr(markup, m.LParam, false); m.Result = new IntPtr(1); return; } break; } break; } base.WndProc(ref m); }
protected override void WndProc(ref Message message) { if (message.Msg == WmCopydata) { var dataStruct = (CopyDataStruct)message.GetLParam(typeof(CopyDataStruct)); presenter.ManageIncomingMassage(dataStruct.LpData); } else if (message.WParam.ToInt64() == ScClose) { closeRequested = true; } base.WndProc(ref message); }
//接收第二个窗口传来的消息 protected override void WndProc(ref System.Windows.Forms.Message e) { if (e.Msg == WM_COPYDATA) { CopyDataStruct cds = (CopyDataStruct)e.GetLParam(typeof(CopyDataStruct)); string msgStr = cds.lpData.ToString(); if (this.args.Length != 0) { Thread thread = new Thread(new ParameterizedThreadStart(RunYouGet)); thread.Start(msgStr.Substring(19)); } } base.WndProc(ref e); }
//获取传递过来的字符串 private string getCopyMessage(ref System.Windows.Forms.Message m) { COPYDATASTRUCT mystr = new COPYDATASTRUCT(); Type mytype = mystr.GetType(); mystr = (COPYDATASTRUCT)m.GetLParam(mytype); int flag = (int)mystr.dwData; byte[] bt = new byte[mystr.cbData]; Marshal.Copy(mystr.lpData, bt, 0, bt.Length); string m2 = System.Text.Encoding.Unicode.GetString(bt); Console.WriteLine(m2); return(m2); }
protected override void WndProc(ref Message m) { if((m.Msg==WM_COPYDATA) && (m.WParam == id)) { CD = (COPYDATASTRUCT)m.GetLParam(typeof(COPYDATASTRUCT)); strData = Marshal.PtrToStringAnsi(new IntPtr(CD.lpData), CD.cbData); if (OnMessage != null) OnMessage( strData, CD.dwData ); return; } base.WndProc(ref m); }
protected override void WndProc(ref Message m) { base.WndProc(ref m); if (m.Msg == TCM_ADJUSTRECT) { Rectangle rect = (Rectangle)m.GetLParam(typeof(Rectangle)); string text = rect.ToString(); rect.X -= 4; rect.Y += -1; rect.Width += 4; rect.Height += 2; Marshal.StructureToPtr(rect, m.LParam, true); } }
protected override void WndProc(ref Message message) { base.WndProc(ref message); switch (message.Msg) { case NativeMethods.WM_COMMAND + NativeMethods.WM_REFLECT: int index = (int)message.WParam & 0xFFFF; this.PerformClick(this.items[index]); base.WndProc(ref message); this.ResetMouseEventArgs(); break; case NativeMethods.WM_MENUCHAR: this.WmMenuChar(ref message); break; case NativeMethods.WM_NOTIFY: case NativeMethods.WM_NOTIFY + NativeMethods.WM_REFLECT: NativeMethods.NMHDR note = (NativeMethods.NMHDR)message.GetLParam(typeof(NativeMethods.NMHDR)); switch (note.code) { case NativeMethods.TTN_NEEDTEXTA: NotifyNeedTextA(ref message); break; case NativeMethods.TTN_NEEDTEXTW: NotifyNeedTextW(ref message); break; case NativeMethods.TBN_QUERYINSERT: message.Result = (IntPtr)1; break; case NativeMethods.TBN_DROPDOWN: this.NotifyDropDown(ref message); break; case NativeMethods.NM_CUSTOMDRAW: this.NotifyCustomDraw(ref message); break; case NativeMethods.TBN_HOTITEMCHANGE: break; } break; } }
protected override void DefWndProc(ref System.Windows.Forms.Message m) { switch (m.Msg) { case WM_COPYDATA: COPYDATASTRUCT mystr = new COPYDATASTRUCT(); Type mytype = mystr.GetType(); mystr = (COPYDATASTRUCT)m.GetLParam(mytype); this.textBox1.Text = mystr.lpData; break; default: base.DefWndProc(ref m); break; } }
private void WmDrawItemMenuItem(ref Message m) { // Obtain the menu item object NativeMethods.DRAWITEMSTRUCT dis = (NativeMethods.DRAWITEMSTRUCT)m.GetLParam(typeof(NativeMethods.DRAWITEMSTRUCT)); // A pointer to the correct MenuItem is stored in the draw item // information sent with the message. // (See MenuItem.CreateMenuItemInfo) MenuItem menuItem = MenuItem.GetMenuItemFromItemData(dis.itemData); // Delegate this message to the menu item if (menuItem != null) { menuItem.WmDrawItem(ref m); } }
protected override void DefWndProc(ref System.Windows.Forms.Message m) //copydata接收消息 { switch (m.Msg) { case WM_COPYDATA: COPYDATASTRUCT mystr = new COPYDATASTRUCT(); Type mytype = mystr.GetType(); mystr = (COPYDATASTRUCT)m.GetLParam(mytype); Serial_SendProcess(mystr.lpData); break; default: base.DefWndProc(ref m); break; } }
internal virtual bool HandleHeaderCustomDraw(ref Message m) { const int CDRF_NEWFONT = 2; const int CDRF_SKIPDEFAULT = 4; const int CDRF_NOTIFYPOSTPAINT = 0x10; const int CDRF_NOTIFYITEMDRAW = 0x20; const int CDDS_PREPAINT = 1; const int CDDS_POSTPAINT = 2; const int CDDS_ITEM = 0x00010000; const int CDDS_ITEMPREPAINT = (CDDS_ITEM | CDDS_PREPAINT); const int CDDS_ITEMPOSTPAINT = (CDDS_ITEM | CDDS_POSTPAINT); APIsStructs.NMCUSTOMDRAW_ nmcustomdraw = (APIsStructs.NMCUSTOMDRAW_)m.GetLParam(typeof(APIsStructs.NMCUSTOMDRAW_)); //System.Diagnostics.Debug.WriteLine(String.Format("header cd: {0:x}, {1}, {2:x}", nmcustomdraw.dwDrawStage, nmcustomdraw.dwItemSpec, nmcustomdraw.uItemState)); switch (nmcustomdraw.dwDrawStage) { case CDDS_PREPAINT: m.Result = (IntPtr)CDRF_NOTIFYITEMDRAW; return(true); case CDDS_ITEMPREPAINT: int columnIndex = nmcustomdraw.dwItemSpec.ToInt32(); if (columnIndex > ListView.Columns.Count - 1) { return(true); } using (Graphics g = Graphics.FromHdc(nmcustomdraw.hdc)) { g.TextRenderingHint = TreeListView.TextRenderingHint; this.CustomDrawHeaderCell(g, columnIndex, nmcustomdraw.uItemState); } m.Result = (IntPtr)CDRF_SKIPDEFAULT; return(true); case CDDS_ITEMPOSTPAINT: break; } return(false); }
//************************************************************************* // Method: WndProc // Description: Handles window messages to the listview // // Parameters: // m - the message sent to the control // // Return Value: None //************************************************************************* protected override void WndProc(ref System.Windows.Forms.Message m) { NMHDR nm1; bool messageProcessed = false; switch (m.Msg) { case (int)WindowsMessage.WM_REFLECT + (int)WindowsMessage.WM_NOTIFY: nm1 = (NMHDR)m.GetLParam(typeof(NMHDR)); switch (nm1.code) { case (int)ListViewNotices.LVN_GETDISPINFOW: OnDispInfoNotice(ref m); messageProcessed = true; break; case (int)ListViewNotices.LVN_BEGINDRAG: case (int)ListViewNotices.LVN_BEGINRDRAG: messageProcessed = true; break; default: break; } break; case (int)WindowsMessage.WM_DESTROY: messageProcessed = true; break; default: break; } if (!messageProcessed) { try { base.WndProc(ref m); } catch (ArgumentOutOfRangeException) { // vs.net 2003 and later throws an exception on get and set focus // but just catching it solves the problem } } }
protected override void DefWndProc(ref System.Windows.Forms.Message m) { switch (m.Msg) { case 0x004A: LOLReplay.Program.COPYDATASTRUCT mystr = new LOLReplay.Program.COPYDATASTRUCT(); Type mytype = mystr.GetType(); mystr = (LOLReplay.Program.COPYDATASTRUCT)m.GetLParam(mytype); cmd = mystr.lpData; ProcessFile(); break; default: base.DefWndProc(ref m); break; } }
//接收传递的消息 protected override void DefWndProc(ref Message m) { switch (m.Msg) { case WM_COPYDATA: COPYDATASTRUCT mystr = new COPYDATASTRUCT(); Type mytype = mystr.GetType(); mystr = (COPYDATASTRUCT)m.GetLParam(mytype); receiveMsg = mystr.lpData; displayMessage(receiveMsg); break; default: base.DefWndProc(ref m); break; } }
/// <summary> /// Our WndProc which raise to user OnShow and OnHide events /// </summary> /// <param name="m"></param> protected virtual void WndProc(ref System.Windows.Forms.Message m) { if (m.Msg == (int)Msg.WM_NOTIFY) { NMHDR note = (NMHDR)m.GetLParam(typeof(NMHDR)); if (note.code == (int)ToolTipNotifyMsg.TTN_SHOW) { m.Result = IntPtr.Zero; RaiseOnShowEvent(); } else if (note.code == (int)ToolTipNotifyMsg.TTN_POP) { RaiseOnHideEvent(); } } }
protected override void WndProc(ref Message m) { if (m.Msg == (int)W32_WM.WM_NOTIFY) { // notify messages can come from the header and are used for column sorting and item filtering if wanted var h1 = (NMHEADER)m.GetLParam(typeof(NMHEADER)); // get the notify message header from this message LParam if ((this._header != null) && (h1.hdr.hwndFrom == this._header.Handle)) { // process messages ONLY from our header control this.NotifyHeaderMessage(h1); } } else if (m.Msg == (int)W32_WM.WM_LBUTTONUP) { this.DefWndProc(ref m); } base.WndProc(ref m); }
protected override void WndProc(ref Message m) { switch (m.Msg) { case WM_RBUTTONUP: if (MouseUpEx != null) { Point p = new Point(m.LParam.ToInt32()); MouseUpEx(this, new MouseEventArgs(MouseButtons.Right, 1, p.X, p.Y, 0)); } base.WndProc(ref m); break; case WM_LBUTTONDBLCLK: if (DoubleClickEx != null) { Point p = new Point(m.LParam.ToInt32()); DoubleClickEx(this, new MouseEventArgs(MouseButtons.Left, 1, p.X, p.Y, 0)); } base.WndProc(ref m); break; case 0x0F: // WM_PAINT this.isInWmPaintMsg = true; base.WndProc(ref m); this.isInWmPaintMsg = false; break; case 0x204E: // WM_REFLECT_NOTIFY NMHDR nmhdr = (NMHDR)m.GetLParam(typeof(NMHDR)); if (nmhdr.code == -12) { // NM_CUSTOMDRAW if (this.isInWmPaintMsg) base.WndProc(ref m); } else base.WndProc(ref m); break; default: base.WndProc(ref m); break; } //if (m.Msg == WM_RBUTTONUP){ // if (MouseUpEx != null) { // Point p = new Point(m.LParam.ToInt32()); // MouseUpEx(this, new MouseEventArgs(MouseButtons.Right, 1, p.X, p.Y, 0)); // } //} //base.WndProc(ref m); }
protected override void WndProc(ref Message m) { base.WndProc(ref m); switch ((uint)m.Msg) { case WM_COPYDATA: var cds = (COPYDATASTRUCT)m.GetLParam(typeof(COPYDATASTRUCT)); byte[] buffer = new byte[cds.cbData]; Marshal.Copy(cds.lpData, buffer, 0, (int)cds.cbData); switch ((uint)cds.dwData) { case 0: byte[] hash = new byte[32]; byte[] name = new byte[24]; Array.Copy(buffer, hash, 32); Array.Copy(buffer, 76, name, 0, 24); Trace.TraceInformation($"\"{Encoding.Unicode.GetString(name).TrimEnd('\0')}\" joined your local game, their hash is \"{Encoding.ASCII.GetString(hash)}\"."); break; } break; } }
protected override void WndProc(ref Message m) { if (!_allowColumnResize) { if (m.Msg == NativeMethods.WM_NOTIFY) { NativeMethods.NMHDR nmhdr = (NativeMethods.NMHDR)m.GetLParam(typeof(NativeMethods.NMHDR)); switch (nmhdr.code) { case NativeMethods.HDN_BEGINTRACKA: case NativeMethods.HDN_BEGINTRACKW: m.Result = new IntPtr(1); return; } } } base.WndProc(ref m); }
protected override void WndProc(ref Message m) { switch (m.Msg) { case 0x0F: // WM_PAINT this.isInWmPaint = true; base.WndProc(ref m); this.isInWmPaint = false; break; case 0x204E: // WM_REFLECT_NOTIFY NMHDR nmhdr = (NMHDR)m.GetLParam(typeof(NMHDR)); if (nmhdr.code == -12) { // NM_CUSTOMDRAW if (this.isInWmPaint) base.WndProc(ref m); } else base.WndProc(ref m); break; default: base.WndProc(ref m); break; } }
private bool NotifyTreeCustomDraw(ref Message m) { m.Result = (IntPtr)CustomDrawReturnFlags.CDRF_DODEFAULT; NMTVCUSTOMDRAW tvcd = (NMTVCUSTOMDRAW)m.GetLParam(typeof(NMTVCUSTOMDRAW)); //IntPtr thisHandle = Handle; if ( tvcd.nmcd.hdr.hwndFrom != Handle) return false; switch (tvcd.nmcd.dwDrawStage) { case (int)CustomDrawDrawStateFlags.CDDS_PREPAINT: // Ask for Item painting notifications m.Result = (IntPtr)CustomDrawReturnFlags.CDRF_NOTIFYITEMDRAW; break; case (int)CustomDrawDrawStateFlags.CDDS_ITEMPREPAINT: itemHasFocus = false; if( (tvcd.nmcd.uItemState & (int)CustomDrawItemStateFlags.CDIS_FOCUS) != 0) itemHasFocus = true; // Set the text and background text color to the window bakcground // text so that we don't see the text being painted tvcd.clrText = ColorUtil.RGB(SystemColors.Window.R, SystemColors.Window.G, SystemColors.Window.B); tvcd.clrTextBk = ColorUtil.RGB(SystemColors.Window.R, SystemColors.Window.G, SystemColors.Window.B); // Put structure back in the message Marshal.StructureToPtr(tvcd, m.LParam, true); m.Result = (IntPtr)CustomDrawReturnFlags.CDRF_NOTIFYPOSTPAINT; break; case (int)CustomDrawDrawStateFlags.CDDS_ITEMPOSTPAINT: DoTreeCustomDrawing(ref m); break; default: break; } return false; }
protected override void WndProc(ref Message m) { if (m.Msg == WM_COPYDATA) { // 从lParam获取COPYDATASTRUCT结构 COPYDATASTRUCT cds = (COPYDATASTRUCT)m.GetLParam(typeof(COPYDATASTRUCT)); // 如果大小匹配 if (cds.cbData == Marshal.SizeOf(typeof(MyStruct))) { // 封装非托管内存数据到MyStruct托管结构 MyStruct myStruct = (MyStruct)Marshal.PtrToStructure(cds.lpData, typeof(MyStruct)); // 显示MyStruct数据成员 this.lbNumber.Text = myStruct.Number.ToString(); this.lbMessage.Text = myStruct.Message; } } base.WndProc(ref m); }
protected override void WndProc(ref Message m) { switch (m.Msg) { case (int)Messages.WM_COPYDATA: { COPYDATASTRUCT cds = (COPYDATASTRUCT)m.GetLParam(typeof(COPYDATASTRUCT)); string strData = Marshal.PtrToStringUni(cds.lpData); Logger.LogTrace("WmCopyDataWindow wndName: {0} received data: {1}", _wndName, strData); if (DataReceived != null) { DataReceived(strData); } } break; default: base.WndProc(ref m); break; } }
protected override void WndProc(ref Message m) { if (m.Msg == WM_COPYDATA) { // Get the COPYDATASTRUCT struct from lParam. COPYDATASTRUCT cds = (COPYDATASTRUCT)m.GetLParam(typeof(COPYDATASTRUCT)); // If the size matches if (cds.cbData == Marshal.SizeOf(typeof(MyStruct))) { // Marshal the data from the unmanaged memory block to a // MyStruct managed struct. MyStruct myStruct = (MyStruct)Marshal.PtrToStructure(cds.lpData, typeof(MyStruct)); // Display the MyStruct data members. this.lbNumber.Text = myStruct.Number.ToString(); this.lbMessage.Text = myStruct.Message; } } base.WndProc(ref m); }
protected override void WndProc(ref Message m) { if((m.Msg == NativeMethods.WM_NOTIFY_REFLECT) && m_bSupported) { try { NativeMethods.NMHDR nm = (NativeMethods.NMHDR)m.GetLParam( typeof(NativeMethods.NMHDR)); if(nm.code == BCN_DROPDOWN) { if(m_ctx != null) { m_ctx.Show(this, new Point(0, this.Height)); return; // We handled it } else { Debug.Assert(false); } } } catch(Exception) { Debug.Assert(false); } } base.WndProc(ref m); }
protected override void WndProc(ref Message message) { base.WndProc(ref message); switch (message.Msg) { // Reflected Messages come from the treeview control itself case (int)ReflectedMessages.OCM_NOTIFY: NMHDR nm2 = (NMHDR) message.GetLParam(typeof(NMHDR)); switch (nm2.code) { case (int)NotificationMessages.NM_CUSTOMDRAW: NotifyTreeCustomDraw(ref message); break; default: break; } break; default: break; } }
protected override void WndProc(ref Message m) { //if native updown is destroyed we need release our hook if (m.Msg == NativeMethods.WM_DESTROY || m.Msg == NativeMethods.WM_NCDESTROY) this.ReleaseHandle(); else if (m.Msg == NativeMethods.WM_WINDOWPOSCHANGING) { //When a scroller position is changed we should remember that new position. NativeMethods.WINDOWPOS wp = (NativeMethods.WINDOWPOS)m.GetLParam(typeof(NativeMethods.WINDOWPOS)); this.x = wp.x; } else if (m.Msg == NativeMethods.WM_MOUSEMOVE && parentControl.lastHotIndex > 0 && parentControl.lastHotIndex != parentControl.SelectedIndex) { //redrawing a former hot tab as normal one using (Graphics context = Graphics.FromHwnd(parentControl.Handle)) { VisualStyleRenderer rend = new VisualStyleRenderer(VisualStyleElement.Tab.TabItem.Normal); parentControl.DrawTabItem(context, parentControl.lastHotIndex, parentControl.GetTabRect(parentControl.lastHotIndex), rend); if (parentControl.lastHotIndex - parentControl.SelectedIndex == 1) { Rectangle selRect = parentControl.GetTabRect(parentControl.SelectedIndex); selRect.Inflate(2, 2); rend.SetParameters(rend.Class, rend.Part, (int)TabItemState.Selected); parentControl.DrawTabItem(context, parentControl.SelectedIndex, selRect, rend); } } } else if (m.Msg == NativeMethods.WM_LBUTTONDOWN) { Rectangle invalidRect = parentControl.GetTabRect(parentControl.SelectedIndex); invalidRect.X = 0; invalidRect.Width = 2; invalidRect.Inflate(0, 2); parentControl.Invalidate(invalidRect); } base.WndProc(ref m); }
// [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")] protected override void WndProc(ref Message m) { // Raise the OnDataReceived event if WM_COPYDATA... if (m.Msg == Plugin.WM_COPYDATA) { // Get the COPYDATASTRUCT struct from lParam. Plugin.COPYDATASTRUCT cds = (Plugin.COPYDATASTRUCT)m.GetLParam(typeof(Plugin.COPYDATASTRUCT)); // If the size and registered windows messages match... if (cds.cbData == Marshal.SizeOf(typeof(Plugin.COLORIZENETSTRUCT)) && (int)cds.dwData == RWM_ColorizeNet) { // Marshal the data from the unmanaged memory block to a COLORIZENET struct Plugin.COLORIZENETSTRUCT cns = (Plugin.COLORIZENETSTRUCT)Marshal.PtrToStructure(cds.lpData, typeof(Plugin.COLORIZENETSTRUCT)); // Send data to our main Plugin object via GlobalNotifier... GlobalNotifier.OnDataReceived(cns); } } base.WndProc(ref m); }
protected override void WndProc(ref Message m) { if (m.Msg == 0x4A) { COPYDATASTRUCT cds = (COPYDATASTRUCT)m.GetLParam(typeof(COPYDATASTRUCT)); string Message = ReceiveMessage.GetMessageString(cds); //Console.WriteLine("Debug: " + Message); if (Message.StartsWith("ZUNE")) { string[] Split = Message.Split(new string[] { "\\0" }, StringSplitOptions.None); if (Split.Length >= 7) { string ZuneRunning = Split[2]; string ZuneTrack = Split[4]; string ZuneArtist = Split[5]; string ZuneAlbum = Split[6]; SongInfo SongInfo = new SongInfo(); SongInfo.ZuneRunning = 1; SongInfo.ZuneTrack = ZuneTrack; SongInfo.ZuneArtist = ZuneArtist; SongInfo.ZuneAlbum = ZuneAlbum; SongInfo.SendSongInfo(); } else { SongInfo SongInfo = new SongInfo(); SongInfo.ZuneRunning = 0; SongInfo.SendSongInfo(); } } } base.WndProc(ref m); }
/// <summary> /// Handle the window position changing. /// </summary> /// <param name="m">The m to be processed</param> /// <returns>bool to indicate if the m has been handled</returns> protected virtual bool HandleWindowPosChanging(ref Message m) { const int SWP_NOSIZE = 1; NativeMethods.WINDOWPOS pos = (NativeMethods.WINDOWPOS)m.GetLParam(typeof(NativeMethods.WINDOWPOS)); if ((pos.flags & SWP_NOSIZE) == 0) { if (pos.cx < this.Bounds.Width) // only when shrinking // pos.cx is the window width, not the client area width, so we have to subtract the border widths this.ResizeFreeSpaceFillingColumns(pos.cx - (this.Bounds.Width - this.ClientSize.Width)); if (this.ShowGroups) this.ResizeLastGroup(); } return false; }