protected override void WndProc(ref Microsoft.WindowsCE.Forms.Message m) { if (m.Msg == (int)WM.NOTIFY) { //marshal notification data into NMHDR struct NMHDR hdr = (NMHDR)Marshal.PtrToStructure(m.LParam, typeof(NMHDR)); if (hdr.hwndFrom == parent.Handle) { switch (hdr.code) { //definite selection case (int)DTN.DROPDOWN: //raise dropdown event parent.OnDropDown(EventArgs.Empty); break; case (int)DTN.CLOSEUP: //raise closeup event parent.OnCloseUp(EventArgs.Empty); break; } } } base.WndProc(ref m); }
/// <summary> /// Перехват системных сообщений для обработки сервисом /// </summary> /// <param name="message"></param> static void ServiceApplication_OnRegisteredMessage(ref Microsoft.WindowsCE.Forms.Message message) { switch (message.Msg) { case Interprocess.WM_QUIT_SERVICE: try { if (_notification != null) { _notification.Visible = false; } } catch (Exception) { } ServiceApplication.Exit(); break; case Interprocess.WM_TIMER_TICK: if ((SystemState.PhoneRoaming && _baseLogic.IDataLogic.GetInRoumingValue() == "1") || !SystemState.PhoneRoaming) { OnTimerTick(); } break; } }
protected override void WndProc(ref Microsoft.WindowsCE.Forms.Message m) { if (m.Msg == (int)WM.NOTIFY) { //marshal notification data into NMHDR struct NMHDR hdr = (NMHDR)Marshal.PtrToStructure(m.LParam, typeof(NMHDR)); if (hdr.hwndFrom == parent.Handle) { switch (hdr.code) { //definite selection case (int)MCN.SELECT: //copy date range SystemTime stStart = new SystemTime(); Marshal.Copy((IntPtr)((int)m.LParam + 12), stStart.ToByteArray(), 0, stStart.ToByteArray().Length); SystemTime stEnd = new SystemTime(); Marshal.Copy((IntPtr)((int)m.LParam + 28), stEnd.ToByteArray(), 0, stEnd.ToByteArray().Length); //raise datechanged event parent.OnDateSelected(new DateRangeEventArgs(stStart.ToDateTime(), stEnd.ToDateTime())); break; } } } base.WndProc(ref m); }
public bool PreFilterMessage(ref Microsoft.WindowsCE.Forms.Message m) { const int WM_LBUTTONDOWN = 0x0201; const int WM_LBUTTONUP = 0x0202; // If the message code isn't one of the ones we're interested in // then we can stop here if (m.Msg != WM_LBUTTONDOWN && m.Msg != WM_LBUTTONDOWN) { return(false); } // see if the control is a watched button foreach (Control c in ControlList) { if (m.HWnd == c.Handle) { int i = (int)m.LParam; int x = i & 0xFFFF; int y = (i >> 16) & 0xFFFF; MouseEventArgs args = new MouseEventArgs(MouseButtons.Left, 1, x, y, 0); if (m.Msg == WM_LBUTTONDOWN) { MouseDown(c, args); } else { MouseUp(c, args); } // returning true means we've processed this message return(true); } } return(false); }
/// <summary> /// If host control erase background message has been set then VoiceRecorder probably was closed. /// </summary> /// <param name="m"></param> protected override void OnEraseBkgndMessage(ref Microsoft.WindowsCE.Forms.Message m) { if (OpenNETCF.Windows.Forms.StaticMethods.IsDesignMode(this)) { return; } Hide(); CleanFileName(); }
void addItem(Microsoft.WindowsCE.Forms.Message msg) { ListViewItem lvi = new ListViewItem(((WindowsMessages.WM_MESG)msg.Msg).ToString()); //lvi.SubItems.Add(win32.helpers.hex8(hookArgs.hookstruct.vkCode)); lvi.SubItems.Add(((vkcodes.VKEY)msg.WParam).ToString()); lvi.SubItems.Add(win32.helpers.hex8(msg.LParam)); listView1.Items.Add(lvi); listView1.EnsureVisible(listView1.Items.Count - 1); }
private void Keytest3AKwm61_KeyDown(object sender, KeyEventArgs e) { Microsoft.WindowsCE.Forms.Message msg = new Microsoft.WindowsCE.Forms.Message(); msg.Msg = WindowsMessages.WM_KEYDOWN; msg.WParam = (IntPtr)e.KeyCode; int modFlags = (int)e.Modifiers; IntPtr pmodFlags = new IntPtr(modFlags); msg.LParam = pmodFlags; addItem(msg); }
/// <summary> /// Listening to incoming windows messages /// </summary> /// <param name="m"></param> protected override void WndProc(ref Microsoft.WindowsCE.Forms.Message m) { foreach (int message in _registeredMessages) { if (message == m.Msg && OnRegisteredMessage != null) { OnRegisteredMessage(ref m); } } base.WndProc(ref m); }
protected override void WndProc(ref Microsoft.WindowsCE.Forms.Message m) { switch (m.Msg) { case WM_SER_SCANDONE: this.msgform.RespondToMessage(WM_SER_SCANDONE); break; default: break; } base.WndProc(ref m); }
public bool PreFilterMessage(ref Microsoft.WindowsCE.Forms.Message m) { switch ((WM)m.Msg) { case WM.KEYUP: case WM.LBUTTONUP: case WM.MOUSEMOVE: // reset the timer m_inactivityTimer.Enabled = false; m_inactivityTimer.Enabled = true; break; } return(false); }
public bool PreFilterMessage(ref Microsoft.WindowsCE.Forms.Message m) { switch ((WM)m.Msg) { case WM.ACTIVATE: if ((WA)NativeMethods.LOWORD(m.WParam.ToInt32()) != WA.INACTIVE) { m_currentActiveFormHandle = m.HWnd; return(false); } break; } return(true); }
protected override void WndProc(ref Microsoft.WindowsCE.Forms.Message m) { base.WndProc(ref m); switch ((WM)m.Msg) { // do this *after* the base so it can do the focus, etc. for us case WM.LBUTTONDOWN: var handler = MouseDown; if (handler != null) { handler(this, EventArgs.Empty); } break; } }
protected override void WndProc(ref Microsoft.WindowsCE.Forms.Message msg) { switch (msg.Msg) { case (Int32)LibDef.WM_BT_SCAN: // When reading is successful if (msg.WParam.ToInt32() == (Int32)LibDef.BTMSG_WPARAM.WP_SCN_SUCCESS) { //Thread.Sleep(200); //Bt.SysLib.Device. //Console.WriteLine(msg.Result.ToString()); Byte[] codedataGet; String strCodedata = ""; Int32 codeLen = 0; UInt16 symbolGet = 0; codeLen = Bt.ScanLib.Control.btScanGetStringSize(); codedataGet = new Byte[codeLen]; int ret = Bt.ScanLib.Control.btScanGetString(codedataGet, ref symbolGet); if (ret != LibDef.BT_OK) { Form1.resultOut = "ERROR BAMBANG"; } Form1.resultOut = System.Text.Encoding.GetEncoding(0).GetString(codedataGet, 0, codeLen); EventHandler handler = ScanSuccess; if (null != handler) { handler(this, EventArgs.Empty); } //Form1. //Console.Write("OK"); //if (ScanMode == 1) //{ // // Reading (individual) // //ScanData_kobetu(); //} //else if (ScanMode == 2) //{ // // Reading (batch) // //ScanData_ikkatu(); //} } break; } base.WndProc(ref msg); }
protected override void WndProc(ref Microsoft.WindowsCE.Forms.Message msg) { if (msg.Msg == WM_NOTIFY_TRAY) { if ((int)msg.LParam == WM_LBUTTONDOWN) { if ((int)msg.WParam == m_uID) { //If somebody hooked, raise the event if (notifyIcon.Click != null) { notifyIcon.Click(notifyIcon, null); } } } } }
/// <summary> /// Handles notification messages from the native control /// </summary> /// <param name="m">Message</param> protected override void OnNotifyMessage(ref Microsoft.WindowsCE.Forms.Message m) { if (OpenNETCF.Windows.Forms.StaticMethods.IsDesignMode(this)) { return; } //marshal data to custom nmhtml struct //Marshal.PtrToStructure doesn't work so marshalling items individually NM_VOICERECORDER nmvr = new NM_VOICERECORDER(); nmvr.hwndFrom = (IntPtr)Marshal.ReadInt32(m.LParam, 0); nmvr.idFrom = Marshal.ReadInt32(m.LParam, 4); nmvr.code = (VoiceRecorderNotification)Marshal.ReadInt32(m.LParam, 8); nmvr.dwExtra = Marshal.ReadInt32(m.LParam, 12); //check the incoming message code and process as required switch (nmvr.code) { case VoiceRecorderNotification.VRN_PLAY_START: OnPlay(EventArgs.Empty); break; case VoiceRecorderNotification.VRN_PLAY_STOP: case VoiceRecorderNotification.VRN_RECORD_STOP: OnStop(EventArgs.Empty); break; case VoiceRecorderNotification.VRN_RECORD_START: OnRecord(EventArgs.Empty); break; case VoiceRecorderNotification.VRN_OK: OnOk(EventArgs.Empty); break; case VoiceRecorderNotification.VRN_CANCEL: OnCancel(EventArgs.Empty); break; case VoiceRecorderNotification.VRN_ERROR: OnError(EventArgs.Empty); break; } }
public bool PreFilterMessage(ref Microsoft.WindowsCE.Forms.Message m) { System.Diagnostics.Debug.WriteLine("msghandler1: " + m.HWnd.ToInt32().ToString("X8") + ", " + m.Msg.ToString("X8") + ", " + m.WParam.ToInt32().ToString("X8") + ", " + m.LParam.ToInt32().ToString("X8")); //only process msg to our windows if (_hwnd.Contains(m.HWnd)) { return(MsgHandler(m)); } else { return(false); } }
protected override void WndProc(ref Microsoft.WindowsCE.Forms.Message msg) { switch (msg.Msg) { case (Int32)LibDef.WM_BT_SCAN: // When reading is successful if (msg.WParam.ToInt32() == (Int32)LibDef.BTMSG_WPARAM.WP_SCN_SUCCESS) { if (BarcodeRead != null) { BarcodeRead(); } } break; } base.WndProc(ref msg); }
private bool MsgHandler(Microsoft.WindowsCE.Forms.Message m) { if (m.Msg == WindowsMessages.WM_KEYDOWN || m.Msg == WindowsMessages.WM_KEYUP) { //add the msg to our listview addItem(m); Keys k = (Keys)m.WParam.ToInt32(); System.Diagnostics.Debug.WriteLine("msghandler2: " + m.HWnd.ToInt32().ToString("X8") + //", " + m.Msg.ToString("X8") + ", " + ((WindowsMessages.WM_MESG)m.Msg).ToString() + ", " + m.WParam.ToInt32().ToString("X8") + ", " + m.LParam.ToInt32().ToString("X8")); if (_bForwardKeys == false) { return(true);//let windows now that we handled the message } else { return(false); } } return(false);//let windows now that we DID NOT handled the message }
// if host control erase background message has been set // then VoiceRecorder probably was closed. internal override void OnEraseBkgndMessage(ref Microsoft.WindowsCE.Forms.Message m) { Hide(); CleanFileName(); }
protected override void WndProc(ref Microsoft.WindowsCE.Forms.Message msg) { if (msg.Msg == WM_FILECHANGEINFO) { if (msg.LParam == IntPtr.Zero) { return; } FILECHANGENOTIFY fchnot = (FILECHANGENOTIFY)Marshal.PtrToStructure(msg.LParam, typeof(FILECHANGENOTIFY)); string fullPath = Marshal.PtrToStringUni((IntPtr)fchnot.dwItem1); string fullPath2 = Marshal.PtrToStringUni((IntPtr)fchnot.dwItem2); string fileName = System.IO.Path.GetFileName(fullPath); string dirName = System.IO.Path.GetDirectoryName(fullPath); string newFileName = ""; if (ValidateByFilter(fileName)) { FileSystemEventArgs args; RenamedEventArgs renArgs; switch (fchnot.wEventId) { case (int)SHCNE_CREATE: if ((watcher.NotifyFilter & NotifyFilters.FileName) == NotifyFilters.FileName) { args = new FileSystemEventArgs(WatcherChangeTypes.Created, dirName, fileName); watcher.OnCreated(args); } break; case (int)SHCNE_MKDIR: if ((watcher.NotifyFilter & NotifyFilters.DirectoryName) == NotifyFilters.DirectoryName) { args = new FileSystemEventArgs(WatcherChangeTypes.Created, dirName, fileName); watcher.OnCreated(args); } break; case (int)SHCNE_UPDATEDIR: if ((watcher.NotifyFilter & NotifyFilters.DirectoryName) == NotifyFilters.DirectoryName) { args = new FileSystemEventArgs(WatcherChangeTypes.Changed, dirName, fileName); watcher.OnChanged(args); } break; case (int)SHCNE_RMDIR: if ((watcher.NotifyFilter & NotifyFilters.DirectoryName) == NotifyFilters.DirectoryName) { args = new FileSystemEventArgs(WatcherChangeTypes.Deleted, dirName, fileName); watcher.OnChanged(args); } break; case (int)SHCNE_DELETE: if ((watcher.NotifyFilter & NotifyFilters.FileName) == NotifyFilters.FileName) { args = new FileSystemEventArgs(WatcherChangeTypes.Deleted, dirName, fileName); watcher.OnDeleted(args); } break; case (int)SHCNE_UPDATEITEM: if ((watcher.NotifyFilter & NotifyFilters.FileName) == NotifyFilters.FileName) { args = new FileSystemEventArgs(WatcherChangeTypes.Changed, dirName, fileName); watcher.OnChanged(args); } break; case (int)SHCNE_RENAMEFOLDER: if ((watcher.NotifyFilter & NotifyFilters.DirectoryName) == NotifyFilters.DirectoryName) { //switched around the paths - new and old were reversed newFileName = System.IO.Path.GetFileName(fullPath2); renArgs = new RenamedEventArgs(WatcherChangeTypes.Renamed, dirName, newFileName, fileName); watcher.OnRenamed(renArgs); } break; case (int)SHCNE_RENAMEITEM: if ((watcher.NotifyFilter & NotifyFilters.FileName) == NotifyFilters.FileName) { //switched around the paths - new and old were reversed newFileName = System.IO.Path.GetFileName(fullPath2); renArgs = new RenamedEventArgs(WatcherChangeTypes.Renamed, dirName, newFileName, fileName); watcher.OnRenamed(renArgs); } break; case (int)SHCNE_ATTRIBUTES: if ((watcher.NotifyFilter & NotifyFilters.Attributes) == NotifyFilters.Attributes) { args = new FileSystemEventArgs(WatcherChangeTypes.Changed, dirName, fileName); watcher.OnChanged(args); } break; } } NativeMethods.SHChangeNotifyFree(msg.LParam); } msg.Result = (IntPtr)0; base.WndProc(ref msg); }
public bool PreFilterMessage(ref Microsoft.WindowsCE.Forms.Message m) { m_event.Set(); return(false); }
protected override void WndProc(ref Microsoft.WindowsCE.Forms.Message msg) { if (msg.Msg == NativeMethods.WM_FILECHANGEINFO) { if (msg.LParam == IntPtr.Zero) { return; } NativeMethods.FILECHANGENOTIFY fchnot = (NativeMethods.FILECHANGENOTIFY)Marshal.PtrToStructure(msg.LParam, typeof(NativeMethods.FILECHANGENOTIFY)); string fullPath = fchnot.dwItem1; string newfullPath = fchnot.dwItem2; string fileName = System.IO.Path.GetFileName(fullPath); string dirName = System.IO.Path.GetDirectoryName(fullPath); string newfileName = string.Empty; if (fchnot.dwItem2 != null) { newfileName = System.IO.Path.GetFileName(fchnot.dwItem2); } if (CheckFilter(fileName)) { FileSystemEventArgs args; RenamedEventArgs renArgs; switch (fchnot.wEventId) { case NativeMethods.SHCNE.CREATE: if ((watcher.notifyFilters & NotifyFilters.FileName) == NotifyFilters.FileName) { args = new FileSystemEventArgs(WatcherChangeTypes.Created, dirName, fileName); watcher.OnCreated(args); } break; case NativeMethods.SHCNE.MKDIR: if ((watcher.notifyFilters & NotifyFilters.DirectoryName) == NotifyFilters.DirectoryName) { args = new FileSystemEventArgs(WatcherChangeTypes.Created, dirName, fileName); watcher.OnCreated(args); } break; case NativeMethods.SHCNE.UPDATEDIR: if ((watcher.notifyFilters & NotifyFilters.DirectoryName) == NotifyFilters.DirectoryName) { args = new FileSystemEventArgs(WatcherChangeTypes.Changed, dirName, fileName); watcher.OnChanged(args); } break; case NativeMethods.SHCNE.RMDIR: if ((watcher.notifyFilters & NotifyFilters.DirectoryName) == NotifyFilters.DirectoryName) { args = new FileSystemEventArgs(WatcherChangeTypes.Deleted, dirName, fileName); watcher.OnDeleted(args); } break; case NativeMethods.SHCNE.DELETE: if ((watcher.notifyFilters & NotifyFilters.FileName) == NotifyFilters.FileName) { args = new FileSystemEventArgs(WatcherChangeTypes.Deleted, dirName, fileName); watcher.OnDeleted(args); } break; case NativeMethods.SHCNE.UPDATEITEM: if ((watcher.notifyFilters & NotifyFilters.FileName) == NotifyFilters.FileName) { args = new FileSystemEventArgs(WatcherChangeTypes.Changed, dirName, fileName); watcher.OnChanged(args); } break; case NativeMethods.SHCNE.RENAMEFOLDER: if ((watcher.notifyFilters & NotifyFilters.DirectoryName) == NotifyFilters.DirectoryName) { renArgs = new RenamedEventArgs(WatcherChangeTypes.Renamed, dirName, newfileName, fileName); watcher.OnRenamed(renArgs); } break; case NativeMethods.SHCNE.RENAMEITEM: if ((watcher.notifyFilters & NotifyFilters.FileName) == NotifyFilters.FileName) { renArgs = new RenamedEventArgs(WatcherChangeTypes.Renamed, dirName, newfileName, fileName); watcher.OnRenamed(renArgs); } break; case NativeMethods.SHCNE.ATTRIBUTES: if ((watcher.notifyFilters & NotifyFilters.Attributes) == NotifyFilters.Attributes) { args = new FileSystemEventArgs(WatcherChangeTypes.Changed, dirName, fileName); watcher.OnChanged(args); } break; } } NativeMethods.SHChangeNotifyFree(msg.LParam); } msg.Result = IntPtr.Zero; base.WndProc(ref msg); }
/// <summary> /// Handles notification messages from the native control /// </summary> /// <param name="m">Message</param> protected override void OnNotifyMessage(ref Microsoft.WindowsCE.Forms.Message m) { //check message is a notification if (m.Msg == (int)WM.NOTIFY) { //marshal notification data into NMHDR struct NMHDR hdr = (NMHDR)Marshal.PtrToStructure(m.LParam, typeof(NMHDR)); //context menu event is a special case if (hdr.code == (int)NM.CONTEXTMENU) { //if the ContextMenu property is set show the user's context menu //if no ContextMenu is set we ignore this notification and use the built in Context Menu. if (this.ContextMenu != null) { NM_HTMLCONTEXT nmhc = (NM_HTMLCONTEXT)Marshal.PtrToStructure(m.LParam, typeof(NM_HTMLCONTEXT)); //cancel default context menu m.Result = new IntPtr(-1); //set position System.Drawing.Point pos = new System.Drawing.Point(nmhc.x, nmhc.y); //show popup this.ContextMenu.Show(this, pos); } } else { //get html viwer specific data from the notification message NM_HTMLVIEW nmhtml = (NM_HTMLVIEW)Marshal.PtrToStructure(m.LParam, typeof(NM_HTMLVIEW)); //marshal the Target string string target = MarshalEx.PtrToStringAuto(nmhtml.szTarget); //check the incoming message code and process as required switch (nmhtml.code) { //hotspot click case (int)NM.HOTSPOT: case (int)NM.BEFORENAVIGATE: OnNavigating(new WebBrowserNavigatingEventArgs(target)); break; //navigate complete case (int)NM.NAVIGATECOMPLETE: OnNavigated(new WebBrowserNavigatedEventArgs(target)); break; //document complete case (int)NM.DOCUMENTCOMPLETE: OnDocumentCompleted(new WebBrowserDocumentCompletedEventArgs(target)); break; //title notification case (int)NM.TITLECHANGE: case (int)NM.TITLE: m_title = target; OnDocumentTitleChanged(new EventArgs()); break; } } } base.OnNotifyMessage(ref m); }