Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
- Select Case m.Msg
- 'WM_CREATE message is the 1st to be sent and is good for initial settings.
- Case Win32Messages.WM_CREATE
- SetWindowTheme(Me.Handle, String.Empty, String.Empty)
- 'For NC area painting
- Case Win32Messages.WM_NCPAINT
- Using g As Graphics = Graphics.FromHdc(GetDCEx(Me.Handle, IntPtr.Zero, (DeviceContextValues.Window Or DeviceContextValues.Cache Or DeviceContextValues.LockWindowUpdate)))
- 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))
- g.FillRectangle(Brushes.DarkRed, New Rectangle(0, 0, Me.Width, Me.Height))
- g.DrawRectangle(Pens.Blue, New Rectangle(0, 0, Me.Width - 1, Me.Height - 1))
- g.DrawString(Me.Text, New Font("Tahoma", 10), Brushes.LightCyan, New PointF(Me.Width / 2 - Len(Me.Text) / 2, 4))
- End Using
- Case Win32Messages.WM_ACTIVATEAPP
- If m.WParam = 1 Then
- Using g As Graphics = Graphics.FromHdc(GetWindowDC(Me.Handle)) 'Graphics.FromHdc(GetDCEx(Me.Handle, IntPtr.Zero, (DeviceContextValues.Window Or DeviceContextValues.Cache)))
- 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))
- g.FillRectangle(Brushes.DarkRed, New Rectangle(0, 0, Me.Width, Me.Height))
- g.DrawRectangle(Pens.Blue, New Rectangle(0, 0, Me.Width - 1, Me.Height - 1))
- g.DrawString(Me.Text, New Font("Tahoma", 10), Brushes.LightCyan, New PointF(Me.Width / 2 - Len(Me.Text) / 2, 4))
- End Using
- ElseIf m.WParam = 0 Then
- Using g As Graphics = Graphics.FromHdc(GetDCEx(Me.Handle, IntPtr.Zero, (DeviceContextValues.Window Or DeviceContextValues.Cache)))
- 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))
- g.FillRectangle(Brushes.DarkBlue, New Rectangle(0, 0, Me.Width, Me.Height))
- g.DrawRectangle(Pens.Blue, New Rectangle(0, 0, Me.Width - 1, Me.Height - 1))
- g.DrawString(Me.Text, New Font("Tahoma", 10), Brushes.LightCyan, New PointF(Me.Width / 2 - Len(Me.Text) / 2, 4))
- End Using
- End If
- Case Else
- MyBase.WndProc(m)
- End Select
- End Sub
- Private Sub Form2_Resize(sender As Object, e As EventArgs) Handles Me.Resize
- Using g As Graphics = Graphics.FromHdc(GetWindowDC(Me.Handle))
- 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))
- g.FillRectangle(Brushes.DarkRed, New Rectangle(0, 0, Me.Width, Me.Height))
- g.DrawRectangle(Pens.Blue, New Rectangle(0, 0, Me.Width - 1, Me.Height - 1))
- g.DrawString(Me.Text, New Font("Tahoma", 10), Brushes.LightCyan, New PointF(Me.Width / 2 - Len(Me.Text) / 2, 4))
- End Using
- End Sub
- Private Sub Form2_SizeChanged(sender As Object, e As EventArgs) Handles Me.SizeChanged
- Using g As Graphics = Graphics.FromHdc(GetWindowDC(Me.Handle))
- 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))
- g.FillRectangle(Brushes.DarkRed, New Rectangle(0, 0, Me.Width, Me.Height))
- If Me.WindowState <> FormWindowState.Maximized Then
- g.DrawRectangle(Pens.Blue, New Rectangle(0, 0, Me.Width - 1, Me.Height - 1))
- End If
- g.DrawString(Me.Text, New Font("Tahoma", 10), Brushes.LightCyan, New PointF(Me.Width / 2 - Len(Me.Text) / 2, 4))
- End Using
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement