⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nativetooltipwindow.cs

📁 语音视频功能 里面实现了基本的QQ与语音对话
💻 CS
字号:
using System;
using System.Windows.Forms;
using System.Drawing;
namespace ToolTipLibrary
{
	/// <summary>
	/// Native Tooltip window for use with the BallonTip control.
	/// </summary>
	internal sealed class NativeTooltipWindow : NativeWindow
	{
		private const string TOOLTIP_CLASS = "tooltips_class32";
		private const int TTS_BALLOON = 64;

		/// <summary>
		/// Initializes a new instance of the <see cref="ToolTipLibrary.NativeTooltipWindow"/> class.
		/// </summary>
		public NativeTooltipWindow()
		{
		}

		/// <summary>
		/// Gets whether the window handle has been created.
		/// </summary>
		/// <value>True if the handle has been created.  False otherwise.</value>
		public bool IsHandleCreated
		{
			get
			{
				return this.Handle != IntPtr.Zero;
			}
		}

		/// <summary>
		/// Creates the native window handle.
		/// </summary>
		/// <param name="topLevelControl">Parent window for the tooltip window.</param>
		public void CreateHandle(IWin32Window topLevelControl)
		{
			this.CreateHandle(GetCreateParams(topLevelControl));

			//Make the window topmost (otherwise, the tooltip may appear behind controls)
			NativeMethods.SetWindowPos(this.Handle, NativeMethods.HWND_TOPMOST, 0, 0,0, 0, 19); 
		}

		/// <summary>
		/// Generates the CreateParams object for this window type.
		/// </summary>
		/// <param name="topLevelControl">Parent window for the tooltip window.</param>
		/// <returns>Returns a CreateParams object filled in with value for this window type.</returns>
		public CreateParams GetCreateParams(IWin32Window topLevelControl)
		{
			CreateParams retval = new CreateParams();
			retval.Parent =topLevelControl.Handle;
			retval.ClassName = TOOLTIP_CLASS;
			retval.Style = NativeMethods.WS_POPUP | TTS_BALLOON;
		//	retval.ExStyle |= 0x20;
			retval.Caption = null;

			return retval;
		}
		protected override void WndProc(ref Message m)
		{
			base.WndProc(ref m);return;
			if(m.Msg==gowk.common.API.WM_ERASEBKGND)
			{
				//base.WndProc (ref m);
				System.Diagnostics.Trace.WriteLine("WM_ERASEBKGND");
			}
			else if(m.Msg==gowk.common.API.WM_PAINT)
			{
				System.Diagnostics.Trace.WriteLine("WM_PAINT");
				System.IntPtr hdc=gowk.common.API.GetWindowDC(this.Handle);
			//	int cor=gowk.common.API.SetBkColor(hdc,255 | 255<<8 | 255<<16);
				System.Drawing.Graphics g=System.Drawing.Graphics.FromHdc(hdc);
				
				Rectangle rect=new Rectangle();
				gowk.common.API.GetWindowRect(this.Handle,ref rect);

				Bitmap bm=new Bitmap(rect.Width,rect.Height);
				Graphics gbm=Graphics.FromImage(bm);
				System.IntPtr hbm=gbm.GetHdc();
				gowk.common.API.BitBlt(hbm,0,0,rect.Width,rect.Height,hdc,0,0,gowk.common.API.SRCCOPY);
				base.WndProc(ref m);

			//	int p=gowk.common.API.GetBkColor(hdc);
			//	byte[] bs=System.BitConverter.GetBytes(p);
				
				
			/*	base.WndProc (ref m);*/

				gowk.common.API.BitBlt(hdc,0,0,rect.Width,rect.Height,hbm,0,0,gowk.common.API.SRCCOPY);

				

				gbm.ReleaseHdc(hbm);

			//	g.FillRectangle(new SolidBrush(Color.FromArgb(bs[0],bs[1],bs[2])),0,0,1000,1000);
			//	g.FillRectangle(new SolidBrush(Color.White),0,0,1000,1000);
				g.Dispose();
				gowk.common.API.ReleaseDC(this.Handle,hdc);
			}
			else
			base.WndProc (ref m);
		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -