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

📄 gtransparentrichtextbox.cs

📁 语音视频功能 里面实现了基本的QQ与语音对话
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace gowk.controls
{
	/// <summary>
	/// UserControl1 的摘要说明。
	/// </summary>
	public class GTransparentRichTextBox : GRichTextBox
	{

		public GTransparentRichTextBox():base()
		{
			//	this.SetStyle(ControlStyles.SupportsTransparentBackColor,true);
			//	this.SetStyle(ControlStyles.UserPaint,true);
			this.SetStyle(ControlStyles.AllPaintingInWmPaint,true);
			this.SetStyle(ControlStyles.DoubleBuffer,true);
			this.ScrollBars=System.Windows.Forms.RichTextBoxScrollBars.None;
		}
		/*override protected CreateParams CreateParams
			{
				get
				{
					CreateParams cp = base.CreateParams;
				cp.ExStyle |= 0x20;
					return cp;
				}
			}
				protected override void OnKeyDown(KeyEventArgs e)
			{
				base.OnKeyDown (e);
				this.Rp();
			}
			protected override void OnKeyUp(KeyEventArgs e)
			{
				base.OnKeyUp (e);
				this.Rp();
			}


			protected override void OnMouseDown(MouseEventArgs e)
			{
				base.OnMouseDown (e);
				this.Rp();
			}
			protected override void OnMouseHover(EventArgs e)
			{
				base.OnMouseHover (e);
				this.Rp();
			}
			protected override void OnMouseEnter(EventArgs e)
			{
				base.OnMouseEnter (e);
				this.Rp();
			}
			protected override void OnMouseMove(MouseEventArgs e)
			{
				base.OnMouseMove (e);
				this.Rp();
			}
			protected override void OnMouseWheel(MouseEventArgs e)
			{
				base.OnMouseWheel (e);
				this.Rp();
			}

	*/

		protected override void WndProc(ref Message m)
		{//base.DefWndProc(ref m);return;
			//m.Msg==0x204e ||m.Msg==0x118 ||m.Msg==0x2111||
			if(m.Msg==gowk.common.API.WM_PAINT ||m.Msg==gowk.common.API.WM_ERASEBKGND)
			{
				base.DefWndProc(ref m);
				this.Rp();
			}
			else
			{
				base.WndProc(ref m);
			}
		}


		private void Rp()
		{
			if(!this.Visible)return;
			if(this.Width<=0 ||this.Height<=0)return;
			Bitmap bitmap=new Bitmap(this.Width,this.Height);
			Graphics gb=Graphics.FromImage(bitmap);
			gb.TranslateTransform(-this.Left,-this.Top);
			this.InvokePaintBackground(this.Parent,new PaintEventArgs(gb,this.Bounds));
			this.InvokePaint(this.Parent,new PaintEventArgs(gb,this.Bounds));

			System.IntPtr hdc=gowk.common.API.GetWindowDC(this.Handle);
			Bitmap bm2=new Bitmap(this.Width,this.Height);
			Graphics fg=Graphics.FromImage(bm2);
			IntPtr p=fg.GetHdc();
			gowk.common.API.BitBlt(p,0,0,this.Width,this.Height,hdc,0,0,gowk.common.API.SRCCOPY);
			fg.ReleaseHdc(p);
			fg.Dispose();

			bm2.MakeTransparent(this.BackColor);
			Graphics g=Graphics.FromHdc(hdc);
			
			g.DrawImage(bitmap,0,0);
			g.DrawImage(bm2,0,0);
			g.Flush();
			g.Dispose();
			gb.Dispose();
			gowk.common.API.ReleaseDC(this.Handle,hdc);
			//	this.richTextBox1.Hide();
			/*	Bitmap bitmap=new Bitmap(this.Width,this.Height);
				Graphics g=Graphics.FromImage(bitmap);
				g.TranslateTransform(-this.Left,-this.Top);
				this.InvokePaintBackground(this.Parent,new PaintEventArgs(g,this.Bounds));
				this.InvokePaint(this.Parent,new PaintEventArgs(g,this.Bounds));
				System.IntPtr hdc=gowk.common.API.GetWindowDC(this.Handle);
				System.IntPtr hdst=g.GetHdc();
				gowk.common.API.BitBlt(hdst,0,0,100,100,hdc,0,0,gowk.common.API.SRCAND);
				gowk.common.API.BitBlt(hdc,0,0,100,100,hdst,0,0,gowk.common.API.SRCCOPY);
			//	this.pictureBox1.Image=bitmap;
				g.ReleaseHdc(hdst);
				gowk.common.API.ReleaseDC(this.Handle,hdc);
				g.Dispose();*/
		}

		[DllImport("USER32.DLL", EntryPoint= "SendMessage")]
		public static extern int SendMessage(IntPtr hwnd, int msg, int wParam,
			int lParam);
	}
}

⌨️ 快捷键说明

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