예제 #1
0
		/// <summary>
		/// Implementation of the INotifiable Notify method.
		/// </summary>
		/// <remarks>Receives notification messages from the native HTMLViewer control.</remarks>
		/// <param name="notifydata">Pointer to a Notification struct.</param>
		void INotifiable.Notify(IntPtr notifydata)
		{
			//marshal data to custom nmhtml struct
			//Marshal.PtrToStructure doesn't work so marshalling items individually
			NM_HTMLVIEW nmhtml = new NM_HTMLVIEW();
			nmhtml.hwndFrom = (IntPtr)Marshal.ReadInt32(notifydata, 0);
			nmhtml.idFrom = Marshal.ReadInt32(notifydata, 4);
			nmhtml.code = Marshal.ReadInt32(notifydata, 8);
			nmhtml.szTarget = (IntPtr)Marshal.ReadInt32(notifydata, 12);
			nmhtml.szData = (IntPtr)Marshal.ReadInt32(notifydata, 16);
			nmhtml.dwCookie = (IntPtr)Marshal.ReadInt32(notifydata, 20);
			nmhtml.szExInfo = (IntPtr)Marshal.ReadInt32(notifydata, 24);

			//check the incoming message code and process as required
			switch(nmhtml.code)
			{
					//hotspotclick
				case (int)HtmlNotification.Hotspot:
					//use the new PtrToStringAuto to get string whether Unicode or ASCII
					string url = OpenNETCF.Runtime.InteropServices.MarshalEx.PtrToStringAuto(nmhtml.szTarget);

					HotSpotClickEventArgs e = new HotSpotClickEventArgs(url);
					OnHotSpotClick(e);
					break;
					//navigate complete
				case (int)HtmlNotification.NavigateComplete:
					OnNavigateComplete(new EventArgs());
					break;
					//document complete
				case (int)HtmlNotification.DocumentComplete:
					OnDocumentComplete(new EventArgs());
					break;
					//title notification
				case (int)HtmlNotification.Title:
					//copy target to title field
					//byte[] titlechars = new byte[256];
					//Marshal.Copy(nmhtml.szTarget, titlechars, 0, 256);
					//m_title = System.Text.Encoding.ASCII.GetString(titlechars, 0, 256);
					//marshal the title
					m_title = MarshalEx.PtrToStringAuto(nmhtml.szTarget);
					break;
			}
		}
예제 #2
0
		/// <summary>
		/// Raises the HotSpotClick event.
		/// </summary>
		/// <param name="e">HotSpotClickEventArgs containing the Url of the requested page</param>
		internal void OnHotSpotClick(HotSpotClickEventArgs e)
		{
			if(this.HotSpotClick!=null)
			{
				this.HotSpotClick(this, e);
			}
		}