/// <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); }