Private Function GetWindowPicture(ByVal hWnd As Integer) As Bitmap
Dim g As Graphics
Dim hdcDest As IntPtr
Dim hdcSrc As Integer
Dim bm As Bitmap
Dim r As New SafeNativeMethods.RECT()
Dim w, h As Integer
SafeNativeMethods.GetWindowRect(hWnd, r)
w = r.Right - r.Left
h = r.Bottom - r.Top
bm = New Bitmap(w, h)
g = Graphics.FromImage(bm)
hdcSrc = SafeNativeMethods.GetWindowDC(hWnd)
hdcDest = g.GetHdc
SafeNativeMethods.BitBlt(hdcDest.ToInt32, 0, 0, w, h, hdcSrc, 0, 0, SafeNativeMethods.TernaryRasterOperations.SRCCOPY)
g.ReleaseHdc(hdcDest)
SafeNativeMethods.ReleaseDC(hWnd, hdcSrc)
Return bm
End Function
Private Sub SetColorFromWindow(ByRef p_hwnd As Integer, ByVal p_Point As Drawing.Point)
Dim objBMP As Bitmap
objBMP = GetWindowPicture(p_hwnd)
'Clipboard.SetImage(objBMP)
Dim rgbclr As System.Drawing.Color = Color.FromArgb(objBMP.GetPixel(p_Point.X, p_Point.Y).ToArgb)
If GWThemes.ThemeBGColor(GWThemes.GroupwiseTheme.Blue) = rgbclr Then
GWThemes.CurrentTheme = GWThemes.GroupwiseTheme.Blue
ElseIf GWThemes.ThemeBGColor(GWThemes.GroupwiseTheme.GW65) = rgbclr Then
GWThemes.CurrentTheme = GWThemes.GroupwiseTheme.GW65
ElseIf GWThemes.ThemeBGColor(GWThemes.GroupwiseTheme.OliveGreen) = rgbclr Then
GWThemes.CurrentTheme = GWThemes.GroupwiseTheme.OliveGreen
ElseIf GWThemes.ThemeBGColor(GWThemes.GroupwiseTheme.Silver) = rgbclr Then
GWThemes.CurrentTheme = GWThemes.GroupwiseTheme.Silver
ElseIf GWThemes.ThemeBGColor(GWThemes.GroupwiseTheme.SkyBlue) = rgbclr Then
GWThemes.CurrentTheme = GWThemes.GroupwiseTheme.SkyBlue
ElseIf GWThemes.ThemeBGColor(GWThemes.GroupwiseTheme.SpringGreen) = rgbclr Then
GWThemes.CurrentTheme = GWThemes.GroupwiseTheme.SpringGreen
ElseIf GWThemes.ThemeBGColor(GWThemes.GroupwiseTheme.SterlingSilver) = rgbclr Then
GWThemes.CurrentTheme = GWThemes.GroupwiseTheme.SterlingSilver
Else
GWThemes.CurrentTheme = GWThemes.GroupwiseTheme.GW65
End If
End Sub |