Travis Posted October 7, 2015 Share Posted October 7, 2015 (edited) Okay so I've produced a model of my application in photoshop because I think it best clearly defines what I am trying to do and the questions I am asking.Shown in the picture is a GUI running on my desktop. I wished to create a window with a thin black border, and allow the background colour to be defined by the user as well as the transparency. I've used The POPUP windowstyle to accomplish this, and simply use GUISetBkColor and WinSetTrans for the latter (respectively)Now I have encountered an issue because I did not realize AutoIt's implementation of this functionality is more sophisticated than I had presumed.In the picture above I illustrate a Control I wish to create on the GUI. The control can be clicked by the user as if it were a button.Initially I simply planned to use GUICtrlCreatePic to point to a graphic I created for the control.The problem is, when the window is created it is set to an immediate default transparency and colour.Then the Pic control is created. This, in effect, causes the window to lose it's transparency and become solid. The picture control, then has its background set as transparent (which I believe it is defined by the top left pixel). So I result in a solid colour filled window, with a transparent square around my "Let's play" button graphic (ie, showing the desktop behind it in complete transparency).Now, if in the script I define the control first and then set transparency and color after (the exact same effect occurs if the control is defined after and the user then changes the transparency within the running application...) it results in the ENTIRE GUI including my picture control to become transparent. I know this is not a bug but simply the result of using WinSetTrans.I wish to have, as illustrated in the model picture here, the control to be transparent relative to the GUI, not the desktop. I do not wish to create a Button control and then define it's style to display a bitmap. I don't think that will allow me to program in the various visual effects that I later wish to add.I am looking at a control I was unaware of before, GUICtrlCreateGraphic (and ...SetGraphic).My ultimate question is where will I find the functionality I am seeking, is it in the ...CreateGraphic functions or CreatePic, or am I going to have to handle window transparency in my own way (without using WinSetTrans and or GUISetBkColor). Or are there other functions that I am unaware of that I should be looking into. I apologize for the lengthy and wordy post on what I feel the image can more or less simply describe what I am trying to do. But I find that achieving by desired outcome is not as obvious and I thought and simply referring to the documentation is not providing me an obvious solution for my task.... Edited October 7, 2015 by Travis removed some irrelevant information for clarity Link to comment Share on other sites More sharing options...
AutoBert Posted October 9, 2015 Share Posted October 9, 2015 (edited) In https://autoit.de/index.php/Thread/24514-UDF-GUICtrlPic-Update-am-27-12-2010/ you can find GuiCtrlPic.au3. i use this UDF for creating pictures on GUI. For Hover- and Click-Animation i extended it with:expandcollapse popup;================================================================================================== ; Function Name: _GuiCtrlPic_CheckHoverDisabled($hGui, ByRef $aHoverBtn) ; Description: prüft den Status ein PicControls Enabled/Disabled Hovered/Normal ; und setzt bei Statusänderung das dazugehörige Pic ; Parameter(s): $hGui Handle der GUI ; $aHoverBtn 2D-Array der HoverButtons ua mit Pfaden zu den Pics ; Author: autoBert ; getestet mit 3.3.14.1 ;================================================================================================== Func _GuiCtrlPic_CheckHoverDisabled($hGui, ByRef $aHoverBtn) Local $aInfo = GUIGetCursorInfo($hGui), $iNewState For $i = 0 To UBound($aHoverBtn) - 1 $iNewState = $aHoverBtn[$i][5] If BitAND(GUICtrlGetState($aHoverBtn[$i][0]), $Gui_DISABLE) = $Gui_DISABLE Then If $aHoverBtn[$i][5] <> 4 Then $iNewState = 4 ;disabled Else If $aInfo[4] = $aHoverBtn[$i][0] Then If $aHoverBtn[$i][5] <> 2 Then $iNewState = 2 ;hovered Else If $aHoverBtn[$i][5] <> 1 Then $iNewState = 1 ;normal EndIf EndIf If $iNewState <> $aHoverBtn[$i][5] Then _GUICtrlPic_SetImage($aHoverBtn[$i][0], $aHoverBtn[$i][$iNewState], True) ;ConsoleWrite('Error: '&@error&' Button: '&$i&' aktiv: '& ($aInfo[4]= $aHoverBtn[$i][0])&' -> ' &$aHoverBtn[$i][5]&' '&$iNewState&@CRLF) EndIf $aHoverBtn[$i][5] = $iNewState Next EndFunc ;==>_GuiCtrlPic_CheckHoverDisabled ;================================================================================================== ; Function Name: _GuiCtrlPic_AnimButton($IDgui, $IDbtn [$sNormal = "", [$sHover = "", [$sPress = "", $iDelay=150]]]]) ; Description: animiert ein Pic, wie einen geklickten Button ; Parameter(s): $IDgui ID der GUI- ; $IDbtn ID des Picture als Button ; $sNormal Pfad zum angezeigten Bild des Buttons im nrmalen Zustand ; $sHover Pfad zum angezeigten Bild des Buttons im Hover-Zustand ; $sPress Pfad zum angezeigten Bild des Buttons im gedrückten Zustand ; Author: BugFix _AnimButton ; modified: autoBert => _GuiCtrlPic_AnimButton ; getestet mit 3.3.14.1 ;================================================================================================== Func _GuiCtrlPic_AnimButton($IDgui, $IDbtn, $sNormal = "", $sHover = "", $sPress = "",$iDelay=150) ;ConsoleWrite($IDbtn & @TAB & $sNormal & @TAB & $sPress & @CRLF) Local $return, $x If $IDbtn = 0 Then Return Local $pos = ControlGetPos($IDgui, '', $IDbtn) ;Local $pWin = WinGetPos(GUICtrlGetHandle($IDbtn)) If $sPress <> "" And FileExists($sPress) Then _GUICtrlPic_SetImage($IDbtn, $sPress) ControlMove($IDgui, '', $IDbtn, $pos[0], $pos[1] + 1, $pos[2] - 1, $pos[3] - 1) $return = 1 Do $x = GUIGetCursorInfo($IDgui) If $x[4] <> $IDbtn Then If $sNormal <> "" And FileExists($sNormal) Then _GUICtrlPic_SetImage($IDbtn, $sNormal, True) return 0 EndIf Sleep($iDelay) Until $x[2] = 0 If $sHover <> "" And FileExists($sHover) Then _GUICtrlPic_SetImage($IDbtn, $sHover, True) ControlMove($IDgui, '', $IDbtn, $pos[0], $pos[1], $pos[2], $pos[3]) ;ConsoleWrite($return & @CRLF) Return $return EndFunc ;==>_GuiCtrlPic_AnimButtonIn ttps://autoit.de/index.php/Thread/24514-UDF-GUICtrlPic-Update-am-27-12-2010/?postID=667381#post667381 you find all what you need: the extended UDF and a example.Search also in this and the german forum for threads from UEZ, he's a GDI-Guru. Edited October 9, 2015 by AutoBert 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