Valnurat Posted August 7, 2019 Share Posted August 7, 2019 (edited) 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 August 7, 2019 by Valnurat Yours sincerely Kenneth. Link to comment Share on other sites More sharing options...
InnI Posted August 7, 2019 Share Posted August 7, 2019 Local $iColor = BitOR(0xFF000000, _WinAPI_GetSysColor($COLOR_3DFACE)) Local $hBrush = _GDIPlus_BrushCreateSolid($iColor) ; or easier _GDIPlus_GraphicsClear($hGraphics, $iColor) Link to comment Share on other sites More sharing options...
Valnurat Posted August 8, 2019 Author Share Posted August 8, 2019 Not the same color. Yours sincerely Kenneth. Link to comment Share on other sites More sharing options...
InnI Posted August 8, 2019 Share Posted August 8, 2019 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() Link to comment Share on other sites More sharing options...
Nine Posted August 8, 2019 Share Posted August 8, 2019 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... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Valnurat Posted August 9, 2019 Author Share Posted August 9, 2019 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. Yours sincerely Kenneth. Link to comment Share on other sites More sharing options...
Nine Posted August 9, 2019 Share Posted August 9, 2019 The 2 missing is alpha. Put FF in front so full color is 0xFFF0F0F0 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Valnurat Posted August 9, 2019 Author Share Posted August 9, 2019 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. expandcollapse popup#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 comment Share on other sites More sharing options...
Valnurat Posted August 9, 2019 Author Share Posted August 9, 2019 11 minutes ago, Nine said: The 2 missing is alpha. Put FF in front so full color is 0xFFF0F0F0 Thank you. It worked. Yours sincerely Kenneth. Link to comment Share on other sites More sharing options...
InnI Posted August 9, 2019 Share Posted August 9, 2019 (edited) @Valnurat Variable $COLOR_3DFACE is declared in WindowsConstants.au3 You need to include this UDF and not declare $COLOR_3DFACE in script. Edited August 9, 2019 by InnI Link to comment Share on other sites More sharing options...
InnI Posted August 9, 2019 Share Posted August 9, 2019 33 minutes ago, Valnurat said: If I use _GDIPlus_GraphicsClear it will clear my entire form It should be so. If you need to clear only a part of window use _GDIPlus_GraphicsFillRect() Link to comment Share on other sites More sharing options...
Valnurat Posted August 9, 2019 Author Share Posted August 9, 2019 Ok. That's also what I do. Thank you. Yours sincerely Kenneth. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now