Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. public partial class Form1 : Form {
  2. public Form1() {
  3. InitializeComponent();
  4. this.BackColor = Color.White;
  5. panel1.BackColor = Color.FromArgb(25, Color.Black);
  6. }
  7. protected override void OnPaint(PaintEventArgs e) {
  8. e.Graphics.DrawLine(Pens.Yellow, 0, 0, 100, 100);
  9. }
  10. }
  11.  
  12. public class TransparentPanel : Panel
  13. {
  14. protected override CreateParams CreateParams
  15. {
  16. get {
  17. CreateParams cp = base.CreateParams;
  18. cp.ExStyle |= 0x00000020; // WS_EX_TRANSPARENT
  19. return cp;
  20. }
  21. }
  22. protected override void OnPaintBackground(PaintEventArgs e)
  23. {
  24. //base.OnPaintBackground(e);
  25. }
  26. }
  27.  
  28. Public Class TransparentPanel
  29. Inherits Panel
  30. Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
  31. Get
  32. Dim cp As CreateParams = MyBase.CreateParams
  33. cp.ExStyle = cp.ExStyle Or &H20 ''#WS_EX_TRANSPARENT
  34. Return cp
  35. End Get
  36. End Property
  37. Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
  38. ''#MyBase.OnPaintBackground(e)
  39. End Sub
  40. End Class
  41.  
  42. public class TransparentPanel : Panel
  43. {
  44. protected override CreateParams CreateParams
  45. {
  46. get
  47. {
  48. CreateParams cp = base.CreateParams;
  49. cp.ExStyle |= 0x00000020; // WS_EX_TRANSPARENT
  50. return cp;
  51. }
  52. }
  53.  
  54. protected override void OnPaint(PaintEventArgs e)
  55. {
  56. e.Graphics.FillRectangle(new SolidBrush(this.BackColor), this.ClientRectangle);
  57. }
  58. }
  59.  
  60. panel1.BackColor = Color.FromArgb(100, 88, 44, 55);
  61.  
  62. panel1 = new TransparentPanel();
  63. panel1.BackColor = System.Drawing.Color.Transparent;
  64. panel1.Location = new System.Drawing.Point(0, 0);
  65. panel1.Name = "panel1";
  66. panel1.Size = new System.Drawing.Size(717, 92);
  67. panel1.TabIndex = 0;
  68. tab2.Controls.Add(panel1);
  69. panel1.BringToFront();
  70.  
  71. Imports System.Windows.Forms
  72.  
  73. Imports System.Drawing.Printing.PrintEventArgs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement