When making a Windows Forms Application in vb.net, I ran into this error:
System.OverflowException: 'Arithmetic operation resulted in an overflow.'
My code:
Imports System.Runtime.InteropServices
Public Class Form1
<DllImport("dwmapi.dll")>
Private Shared Sub DwmGetColorizationColor(ByRef ColorizationColor As UInteger, ByRef ColorizationOpaqueBlend As Boolean)
End Sub
Private Function UintToColor(ByVal argb As UInteger)
Dim a = argb >> 24
Dim r = argb >> 16
Dim g = argb >> 8
Dim b = argb >> 0
Return Color.FromArgb(a, r, g, b)
End Function
Dim windowColor
Dim windowBlend
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Show()
DwmGetColorizationColor(windowColor, windowBlend)
Me.BackColor = UintToColor(windowColor)
End Sub
End Class
The function returns (from "autos"):
a: 227
r: 55182
g: 14876783
b: 3808456647
argb: 3808456647