Jump to content

What is the default form color in _GDIPlus_BrushCreateSolid?


Recommended Posts

I'm trying to clear a image if something goes wrong. I don't know if there is a function for that in the _GDIPlus UDF, but I have tried to use:

Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFEE88BB) ; Pink I think
                _GDIPlus_GraphicsFillRect($hGraphics, 5, 5, 99, 144, $hBrush)

;color format AARRGGBB (hex)

It works, but the color is not right.

So does anyone know what the the default color for the form is?

Edited by Valnurat

Yours sincerely

Kenneth.

Link to post
Share on other sites
30 minutes ago, Valnurat said:

Not the same color.

Same for me (tested on Win7 and Win10)

#include <WindowsConstants.au3>
#include <WinAPISysWin.au3>
#include <GDIPlus.au3>

_GDIPlus_Startup()

$GUI = GUICreate("Test")
$Btn = GUICtrlCreateButton("   Click me   ", 320, 10)
GUISetState()
$hGraphics = _GDIPlus_GraphicsCreateFromHWND($GUI)

$hBrush = _GDIPlus_BrushCreateSolid(0xFFEE88BB)
_GDIPlus_GraphicsFillRect($hGraphics, 10, 10, 300, 300, $hBrush)
_GDIPlus_BrushDispose($hBrush)

Do
  Switch GUIGetMsg()
    Case -3
      ExitLoop
    Case $Btn
      $iColor = BitOR(0xFF000000, _WinAPI_GetSysColor($COLOR_3DFACE))
      $hBrush = _GDIPlus_BrushCreateSolid($iColor)
      _GDIPlus_GraphicsFillRect($hGraphics, 10, 10, 250, 250, $hBrush)
      _GDIPlus_BrushDispose($hBrush)
  EndSwitch
Until 0

_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_Shutdown()

 

test.png

Link to post
Share on other sites
On 8/7/2019 at 7:48 AM, Valnurat said:

So does anyone know what the the default color for the form is?

You can use au3info.exe tool under mouse tab to find a color on screen...

Link to post
Share on other sites
22 hours ago, Nine said:

You can use au3info.exe tool under mouse tab to find a color on screen...

If I do that I don't get 8 digit number as required, but only 6 as you can see in the attachment.

Capture.JPG

Yours sincerely

Kenneth.

Link to post
Share on other sites
On 8/7/2019 at 5:34 PM, InnI said:
Local $iColor = BitOR(0xFF000000, _WinAPI_GetSysColor($COLOR_3DFACE))

Local $hBrush = _GDIPlus_BrushCreateSolid($iColor)

; or easier
_GDIPlus_GraphicsClear($hGraphics, $iColor)

 

If I use _GDIPlus_GraphicsClear it will clear my entire form. I might have created it wrong.

 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=FindComputer.Exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <ScreenCapture.au3>
#include <GuiStatusBar.au3>
#include <AD.au3>

$cEnterPressed = GUICtrlCreateDummy()
Global $hGUI, $hBitmap, $hBitmap_Scaled, $hGraphics, $sUserName, $COLOR_3DFACE
Global $aAccelKeys[1][2] = [["{ENTER}", $cEnterPressed]];x <<<<<<<<<<<<<<<<<<<<<<<<< accelerator  ON
GUISetAccelerators($aAccelKeys);x

_GDIPlus_Startup()
Local Const $iWidth = 300, $iHeight = 305, $aParts[3] = [75, 150, -1], $iBgColor = 0xFFE8FF ;$iBgColor format RRGGBB
Local $iColor = BitOR(0xFF000000, _WinAPI_GetSysColor($COLOR_3DFACE))
$hGUI = GUICreate("GDI+ test", $iWidth, $iHeight, -1, -1) ;create a test gui to display the resized image
;GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
GUICtrlCreateLabel("Enter shortname:",110, 5)
$idShortName = GUICtrlCreateInput("", 110, 20, 185, 20) ; First
GUICtrlCreateLabel("Name:",110, 42)
$idName = GUICtrlCreateInput("", 110, 55, 185, 20) ; First
GUICtrlSetState($idName,$gui_disable)
GUICtrlCreateLabel("Email:",110, 80)
$idEmail = GUICtrlCreateInput("", 110, 93, 185, 20) ; First
GUICtrlSetState($idEmail,$gui_disable)
GUICtrlCreateLabel("Manager:",110, 115)
$idManager = GUICtrlCreateInput("", 110, 130, 185, 20) ; First
GUICtrlSetState($idManager,$gui_disable)

$idListBox = _GUICtrlListBox_Create($hGUI, "", 4, 155, 101, 149)
$g_hStatus = _GUICtrlStatusBar_Create($hGUI)
_GUICtrlStatusBar_SetParts($g_hStatus, $aParts)

GUISetState(@SW_SHOW)

$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
Local $hPen = _GDIPlus_PenCreate()
_GDIPlus_GraphicsDrawRect($hGraphics, 4, 4, 100, 145)
Local $hBrush = _GDIPlus_BrushCreateSolid($iColor);0xFFEE88BB
_GDIPlus_GraphicsFillRect($hGraphics, 5, 5, 99, 144, $hBrush)
$hBrush = _GDIPlus_BrushCreateSolid(0x7F00007F)
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate("Arial")
$hFont = _GDIPlus_FontCreate($hFamily, 12, 2)
$tLayout = _GDIPlus_RectFCreate(15, 70, 100, 20)
_GDIPlus_GraphicsDrawStringEx($hGraphics, "No Image", $hFont, $tLayout, $hFormat, $hBrush)

_AD_Open()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idListBox
            $LBItem = GUICtrlRead($idListBox)
            MsgBox(0,"",$LBItem)
        Case $idShortName  ; Dummy
;           $sUserName = GUICtrlRead ( $idShortName )
            Local $sSamAccountNameToFQDN = _AD_SamAccountNameToFQDN(GUICtrlRead ( $idShortName ))
            Local $aResult = _AD_GetObjectAttribute($sSamAccountNameToFQDN, 'thumbnailPhoto')
            If @error Then
                Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFEE88BB);0xFFEE88BB
                _GDIPlus_GraphicsFillRect($hGraphics, 5, 5, 99, 144, $hBrush)
                $hBrush = _GDIPlus_BrushCreateSolid(0x7F00007F)
                $hFormat = _GDIPlus_StringFormatCreate()
                $hFamily = _GDIPlus_FontFamilyCreate("Arial")
                $hFont = _GDIPlus_FontCreate($hFamily, 12, 2)
                $tLayout = _GDIPlus_RectFCreate(15, 70, 100, 20)
                _GDIPlus_GraphicsDrawStringEx($hGraphics, "No Image", $hFont, $tLayout, $hFormat, $hBrush)
            Else
;               $hBitmap = _GDIPlus_BitmapCreateFromMemory(_AD_GetObjectAttribute(GUICtrlRead ( $idShortName ), 'thumbnailPhoto')) ;load binary saved GIF image and convert it to GDI+ bitmap format
                $hBitmap = _GDIPlus_BitmapCreateFromMemory($aResult) ;load binary saved GIF image and convert it to GDI+ bitmap format
                $hBitmap_Scaled = _GDIPlus_ImageResize($hBitmap, 99, 144) ;resize image
                _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap_Scaled, 5, 5) ;display scaled image
            EndIf
            GUICtrlSetData($idName,_AD_GetObjectAttribute($sSamAccountNameToFQDN, 'cn'))
            GUICtrlSetData($idEmail,_AD_GetObjectAttribute($sSamAccountNameToFQDN, 'mail'))
            local $sManager = _AD_GetObjectAttribute($sSamAccountNameToFQDN, 'manager')
            GUICtrlSetData($idManager,StringMid($sManager,4,StringInStr($sManager,',')-4))
            Local $aComputerOwner = _AD_GetObjectsInOU("OU=al,DC=AD,DC=AL,DC=ORG","(&(objectclass=computer)(managedby=" & $sSamAccountNameToFQDN & "))",Default,"cn")
;           _ArrayDisplay($aComputerOwner, $sSamAccountNameToFQDN)
            If IsArray($aComputerOwner) Then
                _GUICtrlListBox_BeginUpdate($idListBox)
                _GUICtrlListBox_ResetContent($idListBox)
                For $x = 1 to UBound($aComputerOwner)-1
                    _GUICtrlListBox_AddString($idListBox, $aComputerOwner[$x])
                Next
                _GUICtrlListBox_EndUpdate($idListBox)
            EndIf
    EndSwitch
WEnd
_AD_Close()

;cleanup resources
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_BitmapDispose($hBitmap_Scaled)
_GDIPlus_Shutdown()
GUIDelete($hGUI)

 

Yours sincerely

Kenneth.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...