Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.15 KB | None | 0 0
  1. Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
  2.  
  3. Select Case m.Msg
  4.  
  5. 'WM_CREATE message is the 1st to be sent and is good for initial settings.
  6. Case Win32Messages.WM_CREATE
  7. SetWindowTheme(Me.Handle, String.Empty, String.Empty)
  8.  
  9. 'For NC area painting
  10. Case Win32Messages.WM_NCPAINT
  11.  
  12. Using g As Graphics = Graphics.FromHdc(GetDCEx(Me.Handle, IntPtr.Zero, (DeviceContextValues.Window Or DeviceContextValues.Cache Or DeviceContextValues.LockWindowUpdate)))
  13.  
  14. g.ExcludeClip(New Rectangle((Me.Width - Me.ClientSize.Width) / 2, (Me.Height - Me.ClientSize.Height) - ((Me.Width - Me.ClientSize.Width) / 2), Me.ClientRectangle.Width, Me.ClientRectangle.Height))
  15.  
  16. g.FillRectangle(Brushes.DarkRed, New Rectangle(0, 0, Me.Width, Me.Height))
  17. g.DrawRectangle(Pens.Blue, New Rectangle(0, 0, Me.Width - 1, Me.Height - 1))
  18. g.DrawString(Me.Text, New Font("Tahoma", 10), Brushes.LightCyan, New PointF(Me.Width / 2 - Len(Me.Text) / 2, 4))
  19. End Using
  20. Case Win32Messages.WM_ACTIVATEAPP
  21.  
  22. If m.WParam = 1 Then
  23.  
  24. Using g As Graphics = Graphics.FromHdc(GetWindowDC(Me.Handle)) 'Graphics.FromHdc(GetDCEx(Me.Handle, IntPtr.Zero, (DeviceContextValues.Window Or DeviceContextValues.Cache)))
  25.  
  26. g.ExcludeClip(New Rectangle((Me.Width - Me.ClientSize.Width) / 2, (Me.Height - Me.ClientSize.Height) - ((Me.Width - Me.ClientSize.Width) / 2), Me.ClientRectangle.Width, Me.ClientRectangle.Height))
  27. g.FillRectangle(Brushes.DarkRed, New Rectangle(0, 0, Me.Width, Me.Height))
  28. g.DrawRectangle(Pens.Blue, New Rectangle(0, 0, Me.Width - 1, Me.Height - 1))
  29. g.DrawString(Me.Text, New Font("Tahoma", 10), Brushes.LightCyan, New PointF(Me.Width / 2 - Len(Me.Text) / 2, 4))
  30. End Using
  31. ElseIf m.WParam = 0 Then
  32.  
  33.  
  34. Using g As Graphics = Graphics.FromHdc(GetDCEx(Me.Handle, IntPtr.Zero, (DeviceContextValues.Window Or DeviceContextValues.Cache)))
  35. g.ExcludeClip(New Rectangle((Me.Width - Me.ClientSize.Width) / 2, (Me.Height - Me.ClientSize.Height) - ((Me.Width - Me.ClientSize.Width) / 2), Me.ClientRectangle.Width, Me.ClientRectangle.Height))
  36. g.FillRectangle(Brushes.DarkBlue, New Rectangle(0, 0, Me.Width, Me.Height))
  37. g.DrawRectangle(Pens.Blue, New Rectangle(0, 0, Me.Width - 1, Me.Height - 1))
  38. g.DrawString(Me.Text, New Font("Tahoma", 10), Brushes.LightCyan, New PointF(Me.Width / 2 - Len(Me.Text) / 2, 4))
  39. End Using
  40.  
  41. End If
  42.  
  43. Case Else
  44.  
  45. MyBase.WndProc(m)
  46. End Select
  47.  
  48.  
  49. End Sub
  50.  
  51. Private Sub Form2_Resize(sender As Object, e As EventArgs) Handles Me.Resize
  52.  
  53.  
  54. Using g As Graphics = Graphics.FromHdc(GetWindowDC(Me.Handle))
  55.  
  56. g.ExcludeClip(New Rectangle((Me.Width - Me.ClientSize.Width) / 2, (Me.Height - Me.ClientSize.Height) - ((Me.Width - Me.ClientSize.Width) / 2), Me.ClientRectangle.Width, Me.ClientRectangle.Height))
  57.  
  58. g.FillRectangle(Brushes.DarkRed, New Rectangle(0, 0, Me.Width, Me.Height))
  59. g.DrawRectangle(Pens.Blue, New Rectangle(0, 0, Me.Width - 1, Me.Height - 1))
  60. g.DrawString(Me.Text, New Font("Tahoma", 10), Brushes.LightCyan, New PointF(Me.Width / 2 - Len(Me.Text) / 2, 4))
  61. End Using
  62.  
  63. End Sub
  64.  
  65. Private Sub Form2_SizeChanged(sender As Object, e As EventArgs) Handles Me.SizeChanged
  66.  
  67. Using g As Graphics = Graphics.FromHdc(GetWindowDC(Me.Handle))
  68.  
  69. g.ExcludeClip(New Rectangle((Me.Width - Me.ClientSize.Width) / 2, (Me.Height - Me.ClientSize.Height) - ((Me.Width - Me.ClientSize.Width) / 2), Me.ClientRectangle.Width, Me.ClientRectangle.Height))
  70.  
  71. g.FillRectangle(Brushes.DarkRed, New Rectangle(0, 0, Me.Width, Me.Height))
  72. If Me.WindowState <> FormWindowState.Maximized Then
  73. g.DrawRectangle(Pens.Blue, New Rectangle(0, 0, Me.Width - 1, Me.Height - 1))
  74. End If
  75. g.DrawString(Me.Text, New Font("Tahoma", 10), Brushes.LightCyan, New PointF(Me.Width / 2 - Len(Me.Text) / 2, 4))
  76. End Using
  77.  
  78.  
  79. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement