개발언어/C#
[C#] 투명배경 RichTextBox
창용이랑
2023. 4. 11. 13:14
728x90
배경이 투명한 리치텍스트박스(RichTextBox) 입니다.
메신저 대화창 작업중 투명한 넘이 필요해지는 바람에...
public class TransparentRichTextBox : System.Windows.Forms.RichTextBox
{
public TransparentRichTextBox()
{
base.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical;
}
[System.Runtime.InteropServices.DllImport("kernel32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
public static extern IntPtr LoadLibrary(string lpFileName);
protected override System.Windows.Forms.CreateParams CreateParams
{
get
{
System.Windows.Forms.CreateParams prams = base.CreateParams;
if (LoadLibrary("msftedit.dll") != IntPtr.Zero)
{
prams.ExStyle |= 0x020; // 투명설정
}
return prams;
}
}
override protected void OnPaintBackground(System.Windows.Forms.PaintEventArgs e)
{
}
}
출처 : https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=eternize&logNo=30032502297