goldenix Posted June 20, 2011 Share Posted June 20, 2011 (edited) hi,i remember I skinned some guis like this in the past, see the sample. But it was years ago, Im wondering if there is any easier way of doing it these days?Sample will download the images & will delete them after you close the gui.expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.6.1 Author: myName Script Function: #ce ---------------------------------------------------------------------------- ToolTip('Downloading background image, please wait',0,0) if not FileExists('bak2.png') Then InetGet("http://tinyurl.com/6jbew48", "bak2.png") if not FileExists('grey.gif') Then InetGet("http://tinyurl.com/6x7hh96", "grey.gif") ToolTip('') $MY_GUIIMAGE = 'bak2.png' $MY_GUIIMAGE2 = 'grey.gif' #include <GUIConstantsEx.au3> #include <GDIPlus.au3>; this is where the magic happens, people #include <WindowsConstants.au3> Opt("MustDeclareVars", 0) Global Const $AC_SRC_ALPHA = 1 ;~ Global Const $ULW_ALPHA = 2 Global $old_string = "", $runthis = "" ; Load PNG file as GDI bitmap _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($MY_GUIIMAGE) ; This is UR GUI IMAGE ; Extract image width and height from PNG $width = _GDIPlus_ImageGetWidth($hImage) $height = _GDIPlus_ImageGetHeight($hImage) ; Create layered window $GUI = GUICreate("The Main Gui pic", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED) SetBitmap($GUI, $hImage, 0) ; Register notification messages GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUISetState(@SW_SHOW) ;fade in png background For $i = 0 To 255 Step 10 SetBitmap($GUI, $hImage, $i) Next ;~ ========================================== ;~ UDF MAKE GUI ;~ $Form1 = _UDF_SKINGUI_MAKE('My Gui') ;~ ========================================== Func _UDF_SKINGUI_MAKE($GUI_NAME) ; create child MDI gui window to hold controls ; this part could use some work - there is some flicker sometimes... $GUI_NAME = GUICreate($GUI_NAME, $width, $height, 4, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $GUI) ; child window transparency is required to accomplish the full effect, so $WS_EX_LAYERED above, and ; I think the way this works is the transparent window color is based on the image you set here: GUICtrlCreatePic($MY_GUIIMAGE2, 0, 0, $width, $height) GUICtrlSetState(-1, $GUI_DISABLE) Return $GUI_NAME EndFunc ;~ ========================================== ;~ UDF _LABEL ;~ $MyLabe = _UDF_SKINGUI_label("Some Text",0x000000, 8, 504, 200, 17) ;~ ========================================== Func _UDF_SKINGUI_label($TEXT_COLOR,$TEXT,$LEFT,$TOP,$WIDTH,$HEIGHT) $Label_Create = GUICtrlCreateLabel($TEXT, $LEFT, $TOP, $WIDTH, $HEIGHT) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, $TEXT_COLOR) Return $Label_Create EndFunc ;~ ========================================== ;~ UDF _BUTTON ;~ [T_Color],[BG_Color],[Text],[LEFT],[TOP],[WIDTH],[HEIGHT] ;~ $Button4_Filter = _UDF_SKINGUI_BUTTON(0x000000,0xEAF3FA,"Edit Filter", 488, 468, 75, 25, 0) ;~ ========================================== Func _UDF_SKINGUI_BUTTON($TEXT_COLOR,$TEXT_BKCOLOR,$TEXT,$LEFT,$TOP,$WIDTH,$HEIGHT) $Button_Create = GUICtrlCreateButton($TEXT, $LEFT, $TOP, $WIDTH, $HEIGHT) GUICtrlSetBkColor(-1, $TEXT_BKCOLOR) GUICtrlSetColor(-1, $TEXT_COLOR) Return $Button_Create EndFunc ;~ ========================================== ;~ UDF _Checkbox ;~ ;[Text],[T_Color],[BG_Color],[LEFT],[TOP],[WIDTH],[HEIGHT],[State -1 = Checkked / State 0 = UNCheckked ] ;~ $Checkbox1 = _UDF_SKINGUI_Checkbox("Filter Enabled",0x000000,0xEAF3FA, 488, 446, 97, 17,-1) ;~ ========================================== Func _UDF_SKINGUI_Checkbox($TEXT_COLOR,$TEXT_BKCOLOR,$TEXT,$LEFT,$TOP,$WIDTH,$HEIGHT,$STATE) $Checkbox_Create = GUICtrlCreateCheckbox($TEXT, $LEFT, $TOP, $WIDTH, $HEIGHT) GUICtrlSetBkColor(-1, $TEXT_BKCOLOR) GUICtrlSetColor(-1, $TEXT_COLOR) If $STATE = -1 Then GUICtrlSetState(-1, $GUI_CHECKED) Return $Checkbox_Create EndFunc ;~ ========================================== ;~ UDF _RADIO ;~ ;[Text],[T_Color],[BG_Color],[LEFT],[TOP],[WIDTH],[HEIGHT],[State -1 = Checkked / State 0 = UNCheckked ] ;~ $Radio_ = _UDF_SKINGUI_RADIO("Radio1",0x000000,0xEAF3FA, 488, 446, 97, 17,-1) ;~ ========================================== Func _UDF_SKINGUI_RADIO($TEXT_COLOR,$TEXT_BKCOLOR,$TEXT,$LEFT,$TOP,$WIDTH,$HEIGHT,$STATE) $Radio_Create = GUICtrlCreateRadio($TEXT, $LEFT, $TOP, $WIDTH, $HEIGHT) GUICtrlSetBkColor(-1, $TEXT_BKCOLOR) GUICtrlSetColor(-1, $TEXT_COLOR) If $STATE = -1 Then GUICtrlSetState(-1, $GUI_CHECKED) Return $Radio_Create EndFunc ;~ ========================================== ;~ UDF DELETE GUI - Will only Delete GUI ;~ _UDF_SKINGUI_DELETE($Form1) ;~ ========================================== Func _UDF_SKINGUI_DELETE($Form1_GUI) GUIDelete($Form1_GUI) ;fade out png background For $i = 255 To 0 Step -10 SetBitmap($GUI, $hImage, $i) Next ; Release resources _WinAPI_DeleteObject($hImage) _GDIPlus_Shutdown() ;~ FileDelete($MY_GUIIMAGE) EndFunc ; ==================================================================================================== ; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image. ; ==================================================================================================== Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndFunc ;==>WM_NCHITTEST ; ==================================================================================================== ; SetBitMap ; ==================================================================================================== Func SetBitmap($hGUI, $hImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetBitmap Opt("GUIOnEventMode", 1); Change to OnEvent mode HotKeySet('{esc}','CLOSEClicked'); ALT+1 Show / Hode Gui to tray #Region ### START Koda GUI section ### Form= $Form1 = _UDF_SKINGUI_MAKE('Form1') $Button1 = _UDF_SKINGUI_BUTTON(0xFFFFFF,0x448CAF,"Load Sample Data", 50, 250, 99, 20);~ [T_Color],[BG_Color],[Text],[LEFT],[TOP],[WIDTH],[HEIGHT] $Button2 = _UDF_SKINGUI_BUTTON(0xFFFFFF,0x448CAF,"X", 360, 29, 15, 15);~ [T_Color],[BG_Color],[Text],[LEFT],[TOP],[WIDTH],[HEIGHT] _UDF_SKINGUI_Checkbox(0xFFFFFF,0x448CAF,"Checkbox1", 46, 80, 97, 17,-1);~ [T_Color],[BG_Color],[Text],[LEFT],[TOP],[WIDTH],[HEIGHT],[State -1 = Checkked / State 0 = UNCheckked ] _UDF_SKINGUI_label(0xFFFFFF,'Hit Esc To exit',40, 56, 86, 17);~ [T_Color],[Text],[LEFT],[TOP],[WIDTH],[HEIGHT] _UDF_SKINGUI_RADIO(0xFFFFFF,0x448CAF,"Radio1", 68, 104, 80, 17,0);~ [T_Color],[BG_Color],[Text],[LEFT],[TOP],[WIDTH],[HEIGHT],[State -1 = Checkked / State 0 = UNCheckked ] GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ; GUI events GUICtrlSetOnEvent($Button1, "_Buttonclick") GUICtrlSetOnEvent($Button2, "CLOSEClicked") ;~ ======================================= Func _Buttonclick() MsgBox(0,'','You hit The button') EndFunc ;~ ======================================= Func CLOSEClicked() _UDF_SKINGUI_DELETE($Form1) Sleep(1000) FileDelete('bak2.png') FileDelete('grey.gif') Exit EndFunc ;~ ======================================= While 1 Sleep(1000); Idle around WEnd Edited June 20, 2011 by goldenix My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list] Link to comment Share on other sites More sharing options...
monoscout999 Posted June 20, 2011 Share Posted June 20, 2011 (edited) I don`t know if theres an easy way to do it, but you can set the BkColor of the controls to transparent using this UDF and using this function_WinAPI_SetThemeAppProperties($STAP_ALLOW_WEBCONTENT)Using it this wayexpandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.6.1 Author: myName Script Function: #ce ---------------------------------------------------------------------------- ToolTip('Downloading background image, please wait',0,0) if not FileExists('bak2.png') Then InetGet("http://tinyurl.com/6jbew48", "bak2.png") if not FileExists('grey.gif') Then InetGet("http://tinyurl.com/6x7hh96", "grey.gif") ToolTip('') $MY_GUIIMAGE = 'bak2.png' $MY_GUIIMAGE2 = 'grey.gif' #include <GUIConstantsEx.au3> #include <GDIPlus.au3>; this is where the magic happens, people #include <WindowsConstants.au3> #include <WinAPIEx.au3> Opt("MustDeclareVars", 0) Global Const $AC_SRC_ALPHA = 1 ;~ Global Const $ULW_ALPHA = 2 Global $old_string = "", $runthis = "" ; Load PNG file as GDI bitmap _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($MY_GUIIMAGE) ; This is UR GUI IMAGE ; Extract image width and height from PNG $width = _GDIPlus_ImageGetWidth($hImage) $height = _GDIPlus_ImageGetHeight($hImage) _WinAPI_SetThemeAppProperties($STAP_ALLOW_WEBCONTENT) ; Create layered window $GUI = GUICreate("The Main Gui pic", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED) SetBitmap($GUI, $hImage, 0) ; Register notification messages GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUISetState(@SW_SHOW) ;fade in png background For $i = 0 To 255 Step 10 SetBitmap($GUI, $hImage, $i) Next ;~ ========================================== ;~ UDF MAKE GUI ;~ $Form1 = _UDF_SKINGUI_MAKE('My Gui') ;~ ========================================== Func _UDF_SKINGUI_MAKE($GUI_NAME) ; create child MDI gui window to hold controls ; this part could use some work - there is some flicker sometimes... $GUI_NAME = GUICreate($GUI_NAME, $width, $height, 4, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $GUI) ; child window transparency is required to accomplish the full effect, so $WS_EX_LAYERED above, and ; I think the way this works is the transparent window color is based on the image you set here: GUICtrlCreatePic($MY_GUIIMAGE2, 0, 0, $width, $height) GUICtrlSetState(-1, $GUI_DISABLE) Return $GUI_NAME EndFunc ;~ ========================================== ;~ UDF _LABEL ;~ $MyLabe = _UDF_SKINGUI_label("Some Text",0x000000, 8, 504, 200, 17) ;~ ========================================== Func _UDF_SKINGUI_label($TEXT_COLOR,$TEXT,$LEFT,$TOP,$WIDTH,$HEIGHT) $Label_Create = GUICtrlCreateLabel($TEXT, $LEFT, $TOP, $WIDTH, $HEIGHT) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, $TEXT_COLOR) Return $Label_Create EndFunc ;~ ========================================== ;~ UDF _BUTTON ;~ [T_Color],[BG_Color],[Text],[LEFT],[TOP],[WIDTH],[HEIGHT] ;~ $Button4_Filter = _UDF_SKINGUI_BUTTON(0x000000,0xEAF3FA,"Edit Filter", 488, 468, 75, 25, 0) ;~ ========================================== Func _UDF_SKINGUI_BUTTON($TEXT_COLOR,$TEXT_BKCOLOR,$TEXT,$LEFT,$TOP,$WIDTH,$HEIGHT) $Button_Create = GUICtrlCreateButton($TEXT, $LEFT, $TOP, $WIDTH, $HEIGHT) GUICtrlSetBkColor(-1, $TEXT_BKCOLOR) GUICtrlSetColor(-1, $TEXT_COLOR) Return $Button_Create EndFunc ;~ ========================================== ;~ UDF _Checkbox ;~ ;[Text],[T_Color],[BG_Color],[LEFT],[TOP],[WIDTH],[HEIGHT],[State -1 = Checkked / State 0 = UNCheckked ] ;~ $Checkbox1 = _UDF_SKINGUI_Checkbox("Filter Enabled",0x000000,0xEAF3FA, 488, 446, 97, 17,-1) ;~ ========================================== Func _UDF_SKINGUI_Checkbox($TEXT_COLOR,$TEXT_BKCOLOR,$TEXT,$LEFT,$TOP,$WIDTH,$HEIGHT,$STATE) $Checkbox_Create = GUICtrlCreateCheckbox($TEXT, $LEFT, $TOP, $WIDTH, $HEIGHT) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, $TEXT_COLOR) If $STATE = -1 Then GUICtrlSetState(-1, $GUI_CHECKED) Return $Checkbox_Create EndFunc ;~ ========================================== ;~ UDF _RADIO ;~ ;[Text],[T_Color],[BG_Color],[LEFT],[TOP],[WIDTH],[HEIGHT],[State -1 = Checkked / State 0 = UNCheckked ] ;~ $Radio_ = _UDF_SKINGUI_RADIO("Radio1",0x000000,0xEAF3FA, 488, 446, 97, 17,-1) ;~ ========================================== Func _UDF_SKINGUI_RADIO($TEXT_COLOR,$TEXT_BKCOLOR,$TEXT,$LEFT,$TOP,$WIDTH,$HEIGHT,$STATE) $Radio_Create = GUICtrlCreateRadio($TEXT, $LEFT, $TOP, $WIDTH, $HEIGHT) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, $TEXT_COLOR) If $STATE = -1 Then GUICtrlSetState(-1, $GUI_CHECKED) Return $Radio_Create EndFunc ;~ ========================================== ;~ UDF DELETE GUI - Will only Delete GUI ;~ _UDF_SKINGUI_DELETE($Form1) ;~ ========================================== Func _UDF_SKINGUI_DELETE($Form1_GUI) GUIDelete($Form1_GUI) ;fade out png background For $i = 255 To 0 Step -10 SetBitmap($GUI, $hImage, $i) Next ; Release resources _WinAPI_DeleteObject($hImage) _GDIPlus_Shutdown() ;~ FileDelete($MY_GUIIMAGE) EndFunc ; ==================================================================================================== ; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image. ; ==================================================================================================== Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndFunc ;==>WM_NCHITTEST ; ==================================================================================================== ; SetBitMap ; ==================================================================================================== Func SetBitmap($hGUI, $hImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetBitmap Opt("GUIOnEventMode", 1); Change to OnEvent mode HotKeySet('{esc}','CLOSEClicked'); ALT+1 Show / Hode Gui to tray #Region ### START Koda GUI section ### Form= $Form1 = _UDF_SKINGUI_MAKE('Form1') $Button1 = _UDF_SKINGUI_BUTTON(0xFFFFFF,0x448CAF,"Load Sample Data", 50, 250, 99, 20);~ [T_Color],[BG_Color],[Text],[LEFT],[TOP],[WIDTH],[HEIGHT] $Button2 = _UDF_SKINGUI_BUTTON(0xFFFFFF,0x448CAF,"X", 360, 29, 15, 15);~ [T_Color],[BG_Color],[Text],[LEFT],[TOP],[WIDTH],[HEIGHT] _UDF_SKINGUI_Checkbox(0xFFFFFF,0x448CAF,"Checkbox1", 46, 80, 97, 17,-1);~ [T_Color],[BG_Color],[Text],[LEFT],[TOP],[WIDTH],[HEIGHT],[State -1 = Checkked / State 0 = UNCheckked ] _UDF_SKINGUI_label(0xFFFFFF,'Hit Esc To exit',40, 56, 86, 17);~ [T_Color],[Text],[LEFT],[TOP],[WIDTH],[HEIGHT] _UDF_SKINGUI_RADIO(0xFFFFFF,0x448CAF,"Radio1", 68, 104, 80, 17,0);~ [T_Color],[BG_Color],[Text],[LEFT],[TOP],[WIDTH],[HEIGHT],[State -1 = Checkked / State 0 = UNCheckked ] GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ; GUI events GUICtrlSetOnEvent($Button1, "_Buttonclick") GUICtrlSetOnEvent($Button2, "CLOSEClicked") ;~ ======================================= Func _Buttonclick() MsgBox(0,'','You hit The button') EndFunc ;~ ======================================= Func CLOSEClicked() _UDF_SKINGUI_DELETE($Form1) Sleep(1000) FileDelete('bak2.png') FileDelete('grey.gif') Exit EndFunc ;~ ======================================= While 1 Sleep(1000); Idle around WEndI add the function and set the Back color of the radio and the Checkbox to transparent..PD:¿Are you [X]Gold from other forum? Edited June 20, 2011 by monoscout999 Link to comment Share on other sites More sharing options...
goldenix Posted June 20, 2011 Author Share Posted June 20, 2011 (edited) I add the function and set the Back color of the radio and the Checkbox to transparent.. PD:¿Are you [X]Gold from other forum? This looks pretty neat. But it seems its a little bugged. it gets selected & then it starts blinking. And sometimes if u click on the checkbox label it gets checked, & sometimes it does not. My question was if there has been any development in the area where you can create the gui with just 1 line. as you can see from the code its friggin long. I was hoping for some proper functions, you can easily make guis with the help of gdiplus. I dont know, maybe, maybe not, depends on a forum. Edited June 20, 2011 by goldenix My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list] Link to comment Share on other sites More sharing options...
monoscout999 Posted June 20, 2011 Share Posted June 20, 2011 (edited) This looks pretty neat. But it seems its a little bugged. it gets selected & then it starts blinking. And sometimes if u click on the checkbox label it gets checked, & sometimes it does not.My question was if there has been any development in the area where you can create the gui with just 1 line. as you can see from the code its friggin long. I was hoping for some proper functions, you can easily make guis with the help of gdiplus.The checkbox bug is because you need to click on the text and NOT in the background... :S i dont know how to fix it....Yes the script is a little long but for me is well organized in functions, maybe doing the functions in other order can help you to make it more accesible... something like this...-Includes--Global declarations--GUI and Controls creation--Main loop--Functions-and deleting the _UDF_SKINGUI_MAKE() functions and related... but that is my taste on scripting...I don`t Think that theres a 1 or 10 lines function to do that the script do..I dont know, maybe, maybe not, depends on a forum.EDIT: I`m monoscout999 if you know me from other forum then you are what i think you are Edited June 20, 2011 by monoscout999 Link to comment Share on other sites More sharing options...
picea892 Posted June 21, 2011 Share Posted June 21, 2011 (edited) You no longer need gray gif to render transparent. Search for _WinAPI_SetLayeredWindowAttributes or look in helpfile. For your checkbox and radio I would do the following. #include <GUIConstants.au3> #Include <WinAPI.au3> #include <GUIConstants.au3> #include <WindowsConstants.au3> $hWndMain = GUICreate("My CheckBox Button with Transparency", 300, 200, -1, -1,$WS_OVERLAPPEDWINDOW) GUISetBkColor(0x00ff00) $btnCheckBox = GUICtrlCreateCheckbox('Checkbox', 100, 30, 12, 12) $label = GUICtrlCreateLabel('Checkbox', 118, 29, 122, 12) GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) $btnCheckBox2 = GUICtrlCreateRadio('radio', 100, 150, 12, 12) $radio = GUICtrlCreateLabel('radio', 118, 149, 112, 12) GUISetState() While True Switch GUIGetMsg() Case -3 Exit EndSwitch WEnd Edited June 21, 2011 by picea892 Link to comment Share on other sites More sharing options...
monoscout999 Posted June 21, 2011 Share Posted June 21, 2011 You no longer need gray gif to render transparent. Search for _WinAPI_SetLayeredWindowAttributes or look in helpfile. For your checkbox and radio I would do the following.When i try that way in a GUI whit a semi transparent PNG as Background dont work well.as you can see from the code its friggin longYou can take all the functions and constants and make an UDF script then include it in the main script. Link to comment Share on other sites More sharing options...
goldenix Posted June 21, 2011 Author Share Posted June 21, 2011 You no longer need gray gif to render transparent. Search for _WinAPI_SetLayeredWindowAttributes or look in helpfile. For your checkbox and radio I would do the following. I tried to use the winapi attributes, but it screwed up my whole gui. How should I use it? I made 2 samples, first one is clean & works with the gray gif. Second one is where I tried to use SetLayeredWindowAttributes, have a look, it does not work, or maybe im using it wrong? And it does not fade in or out. Sample1 expandcollapse popup;Sample 1 ToolTip('Downloading background image, please wait',0,0) if not FileExists('bak2.png') Then InetGet("http://tinyurl.com/6jbew48", "bak2.png") if not FileExists('grey.gif') Then InetGet("http://tinyurl.com/6x7hh96", "grey.gif") ToolTip('') $MY_GUIIMAGE = 'bak2.png' $MY_GUIIMAGE2 = 'grey.gif' Opt("GUIOnEventMode", 1); Change to OnEvent mode HotKeySet('{esc}','_exit'); ALT+1 Show / Hode Gui to tray #include <GDIPlus.au3>; this is where the magic happens, people #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> Opt("MustDeclareVars", 0) Global Const $AC_SRC_ALPHA = 1 ;~ Global Const $ULW_ALPHA = 2 Global $old_string = "", $runthis = "" ; Load PNG file as GDI bitmap _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($MY_GUIIMAGE) ; This is UR GUI IMAGE ; Extract image width and height from PNG $width = _GDIPlus_ImageGetWidth($hImage) $height = _GDIPlus_ImageGetHeight($hImage) ; Create layered window $GUI = GUICreate("The Main Gui pic", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED) SetBitmap($GUI, $hImage, 0) ; Register notification messages GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUISetState(@SW_SHOW) ;fade in png background For $i = 0 To 255 Step 10 SetBitmap($GUI, $hImage, $i) Next ; create child MDI gui window to hold controls ; this part could use some work - there is some flicker sometimes... Global $GUI_NAME = GUICreate('childgui', $width, $height, 4, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $GUI) ; child window transparency is required to accomplish the full effect, so $WS_EX_LAYERED above, and ; I think the way this works is the transparent window color is based on the image you set here: GUICtrlCreatePic($MY_GUIIMAGE2, 0, 0, $width, $height) GUICtrlSetState(-1, $GUI_DISABLE) $Label_Create = GUICtrlCreateLabel('Press esc to exit', 100, 106, 86, 17) GUICtrlSetColor(-1, 0xffffff) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUISetState(@SW_SHOW) ; ==================================================================================================== ; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image. ; ==================================================================================================== Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndFunc ;==>WM_NCHITTEST ; ==================================================================================================== ; SetBitMap ; ==================================================================================================== Func SetBitmap($hGUI, $hImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetBitmap While 1 Sleep(100); Idle around WEnd Func _exit() GUIDelete($GUI_NAME) ;fade out png background For $i = 255 To 0 Step -10 SetBitmap($GUI, $hImage, $i) Next ; Release resources _WinAPI_DeleteObject($hImage) _GDIPlus_Shutdown() Sleep(700) FileDelete('bak2.png') FileDelete('grey.gif') Exit EndFunc Sample 2: expandcollapse popup;Sample 2 ToolTip('Downloading background image, please wait',0,0) if not FileExists('bak2.png') Then InetGet("http://tinyurl.com/6jbew48", "bak2.png") if not FileExists('grey.gif') Then InetGet("http://tinyurl.com/6x7hh96", "grey.gif") ToolTip('') $MY_GUIIMAGE = 'bak2.png' $MY_GUIIMAGE2 = 'grey.gif' Opt("GUIOnEventMode", 1); Change to OnEvent mode HotKeySet('{esc}','_exit'); ALT+1 Show / Hode Gui to tray #include <GDIPlus.au3>; this is where the magic happens, people #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WINAPI.au3> Opt("MustDeclareVars", 0) Global Const $AC_SRC_ALPHA = 1 ;~ Global Const $ULW_ALPHA = 2 Global $old_string = "", $runthis = "" ; Load PNG file as GDI bitmap _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($MY_GUIIMAGE) ; This is UR GUI IMAGE ; Extract image width and height from PNG $width = _GDIPlus_ImageGetWidth($hImage) $height = _GDIPlus_ImageGetHeight($hImage) ; Create layered window $GUI = GUICreate("The Main Gui pic", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED) ;~ SetBitmap($GUI, $hImage, 0) _WinAPI_SetLayeredWindowAttributes($gui, 0x010101, 150) ; Register notification messages GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUISetState(@SW_SHOW) ;fade in png background ;~ For $i = 0 To 255 Step 10 ;~ SetBitmap($GUI, $hImage, $i) ;~ Next ; create child MDI gui window to hold controls ; this part could use some work - there is some flicker sometimes... Global $GUI_NAME = GUICreate('childgui', $width, $height, 4, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $GUI) ; child window transparency is required to accomplish the full effect, so $WS_EX_LAYERED above, and ; I think the way this works is the transparent window color is based on the image you set here: GUICtrlCreatePic($MY_GUIIMAGE2, 0, 0, $width, $height) GUICtrlSetState(-1, $GUI_DISABLE) $Label_Create = GUICtrlCreateLabel('Press esc to exit', 100, 106, 86, 17) GUICtrlSetColor(-1, 0xffffff) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUISetState(@SW_SHOW) ; ==================================================================================================== ; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image. ; ==================================================================================================== Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndFunc ;==>WM_NCHITTEST ; ==================================================================================================== ; SetBitMap ; ==================================================================================================== Func SetBitmap($hGUI, $hImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetBitmap While 1 Sleep(100); Idle around WEnd Func _exit() GUIDelete($GUI_NAME) ;fade out png background For $i = 255 To 0 Step -10 SetBitmap($GUI, $hImage, $i) Next ; Release resources _WinAPI_DeleteObject($hImage) _GDIPlus_Shutdown() Sleep(500) FileDelete('bak2.png') FileDelete('grey.gif') Exit EndFunc My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list] Link to comment Share on other sites More sharing options...
BrewManNH Posted June 21, 2011 Share Posted June 21, 2011 (edited) Here's how I did it with a bmp (can use jpg or gif too), not a PNG, but still it works for me. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $MainGUI = GUICreate("Media Player", 434, 434, -1, -1, $WS_POPUP, $WS_EX_LAYERED) GUISetBkColor(0x808080) GUICtrlCreatePic(@ScriptDir & "\cdrom.bmp", 0, 0, 0, 0) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState() While GUIGetMsg() <> -3 WEnd You can use this one to try it out with. http://media.itsalltech.com/2010/02/358pbu8.jpg Edited June 21, 2011 by BrewManNH If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator Link to comment Share on other sites More sharing options...
monoscout999 Posted June 21, 2011 Share Posted June 21, 2011 http://media.itsalltech.com/2010/02/358pbu8.jpgThe link doesn`t work Link to comment Share on other sites More sharing options...
BrewManNH Posted June 21, 2011 Share Posted June 21, 2011 Well, you can always try another image that is in the correct format, save it to your hard drive and then use that in place of the "cdrom.bmp" I have in the example I gave. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator Link to comment Share on other sites More sharing options...
goldenix Posted June 21, 2011 Author Share Posted June 21, 2011 my last question was regarding the use of grey.gif picea892 said there is a way without using this file. but I was not able to get it to work. I was also wondering, maybe it would be possible to convert grey.gif into binary & then paste those 111 bytes into your script & then use this binary instead of the real file. The main problem is that everyone wants to have just 1 file, not one exe file & 2 image files. My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list] Link to comment Share on other sites More sharing options...
BrewManNH Posted June 21, 2011 Share Posted June 21, 2011 If you FileInstall the image file, then delete it during the program's close sequence, there shouldn't be much of a problem. Or you could use the Resources UDF in Example Scripts to help with that. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator Link to comment Share on other sites More sharing options...
picea892 Posted June 22, 2011 Share Posted June 22, 2011 Hi GoldenixSee my example Make sure to have a png image named appropriately in the script directory. Link to comment Share on other sites More sharing options...
goldenix Posted June 22, 2011 Author Share Posted June 22, 2011 Hi Goldenix See my example Make sure to have a png image named appropriately in the script directory. Alright now we are talking, but how do you add buttons & labels? I tried & it does not work. expandcollapse popup#include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> ToolTip('Downloading background image, please wait',0,0) if not FileExists('bak2.png') Then InetGet("http://tinyurl.com/6jbew48", "bak2.png") ToolTip('') Global $hImage HotKeySet('{esc}','_exit'); ALT+1 Show / Hode Gui to tray _GDIPlus_Startup() $GUI = _GUICreate_Alpha("Look at the shiny", "bak2.png", 100, 162) $myGuiHandle = WinGetHandle("Look at the shiny") $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($myGuiHandle) _GDIPlus_GraphicsDrawString ($hGraphic, "Hello world", 10, 30) $label = GUICtrlCreateLabel('Checkbox', 118, 129, 122, 12) GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) ;This allows the png to be dragged by clicking anywhere on the main image. GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUISetState() Func _GUICreate_Alpha($sTitle, $sPath, $iX=-1, $iY=-1, $iOpacity=255) Local $hGUI, $hImage, $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hImage = _GDIPlus_ImageLoadFromFile($sPath) $width = _GDIPlus_ImageGetWidth($hImage) $height = _GDIPlus_ImageGetHeight($hImage) $hGUI = GUICreate($sTitle, $width, $height, $iX, $iY, $WS_POPUP, $WS_EX_LAYERED) $label = GUICtrlCreateLabel('Checkbox', 118, 129, 122, 12) GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", $width) DllStructSetData($tSize, "Y", $height) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, 2) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hImage) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>_GUICreate_Alpha Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If ($hwnd = WinGetHandle("Look at the shiny")) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndIf EndFunc Func _exit() _WinAPI_DeleteObject($hImage) _GDIPlus_Shutdown() GUIDelete($GUI) Sleep(700) FileDelete('bak2.png') Exit EndFunc While 1 Sleep(100) WEnd My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list] Link to comment Share on other sites More sharing options...
monoscout999 Posted June 22, 2011 Share Posted June 22, 2011 (edited) You forget _GDIPlus_GraphicsDispose($hGraphic) on the _exit() funcPD: I was tryng to create a Guifor the controls or something and i end up whit this... :SOnly that... sorry if i SpaM Edited June 22, 2011 by monoscout999 Link to comment Share on other sites More sharing options...
picea892 Posted June 22, 2011 Share Posted June 22, 2011 Hi there Here is a control on your gui. recently learned how to change font quality and so incorporated that as well. Added Monoscout999 fix as well expandcollapse popup#include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> Global Const $NONANTIALIASED_QUALITY = 3 ToolTip('Downloading background image, please wait',0,0) if not FileExists('bak2.png') Then InetGet("http://tinyurl.com/6jbew48", "bak2.png") ToolTip('') Global $hImage HotKeySet('{esc}','_exit'); ALT+1 Show / Hode Gui to tray _GDIPlus_Startup() $GUI = _GUICreate_Alpha("Look at the shiny", "bak2.png", 100, 162) $myGuiHandle = WinGetHandle("Look at the shiny") $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($myGuiHandle) GUISetState() $butGui = GUICreate("ControlGUI", 400, 400, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $myGuiHandle) GUISetBkColor(0xABCDEF) $label = GUICtrlCreateLabel('Checkbox', 118, 129, 132, 32) GUICtrlSetFont($label, 14, 550, Default, "Arial", $NONANTIALIASED_QUALITY) ; GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) _WinAPI_SetLayeredWindowAttributes($butGui, 0xABCDEF, 255) ;This allows the png to be dragged by clicking anywhere on the main image. GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUISetState() Func _GUICreate_Alpha($sTitle, $sPath, $iX=-1, $iY=-1, $iOpacity=255) Local $hGUI, $hImage, $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hImage = _GDIPlus_ImageLoadFromFile($sPath) $width = _GDIPlus_ImageGetWidth($hImage) $height = _GDIPlus_ImageGetHeight($hImage) $hGUI = GUICreate($sTitle, $width, $height, $iX, $iY, $WS_POPUP, $WS_EX_LAYERED) $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", $width) DllStructSetData($tSize, "Y", $height) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, 2) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hImage) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>_GUICreate_Alpha Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If ($hwnd = WinGetHandle("Look at the shiny")) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndIf EndFunc Func _exit() _WinAPI_DeleteObject($hImage) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($GUI) Sleep(700) FileDelete('bak2.png') Exit EndFunc While 1 Sleep(100) WEnd Link to comment Share on other sites More sharing options...
goldenix Posted June 22, 2011 Author Share Posted June 22, 2011 Hi there Here is a control on your gui. recently learned how to change font quality and so incorporated that as well. Added Monoscout999 fix as well I see, thank you, looks like you must make separate label for each control then. But how comes it fails to delete bak2.png when exiting? see sample: expandcollapse popup#include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> ToolTip('Downloading background image, please wait',0,0) if not FileExists('bak2.png') Then InetGet("http://tinyurl.com/6jbew48", "bak2.png") ToolTip('') Opt("GUIOnEventMode", 1); Change to OnEvent mode HotKeySet('{esc}','_exit'); ALT+1 Show / Hode Gui to tray _GDIPlus_Startup() $GUI = _GUICreate_Alpha("Look at the shiny", "bak2.png", 100, 162) $myGuiHandle = WinGetHandle("Look at the shiny") $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($myGuiHandle) GUISetState() $butGui = GUICreate("ControlGUI", 400, 400, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $myGuiHandle) GUISetBkColor(0xABCDEF) $label = GUICtrlCreateLabel('Checkbox', 118, 130, 122, 22) $btnCheckBox = GUICtrlCreateCheckbox('Checkbox', 100, 130, 12, 12) $btnCheckBox2 = GUICtrlCreateRadio('radio', 100, 150, 12, 12) $radio = GUICtrlCreateLabel('radio', 118, 149, 112, 12) $Button1 = GUICtrlCreateButton('exit', 110, 220, 60, 23) GUICtrlSetBkColor(-1, 0x5099C0) GUICtrlSetColor(-1, 0xFFFFFF) $label = GUICtrlCreateLabel('_ x', 350, 25, 50, 25) GUICtrlSetColor(-1, 0xFFFFFF) _WinAPI_SetLayeredWindowAttributes($butGui, 0xABCDEF, 255) ;This allows the png to be dragged by clicking anywhere on the main image. GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUICtrlSetOnEvent($Button1, "_exit") GUISetState() Func _GUICreate_Alpha($sTitle, $sPath, $iX=-1, $iY=-1, $iOpacity=255) Local $hGUI, $hImage, $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hImage = _GDIPlus_ImageLoadFromFile($sPath) $width = _GDIPlus_ImageGetWidth($hImage) $height = _GDIPlus_ImageGetHeight($hImage) $hGUI = GUICreate($sTitle, $width, $height, $iX, $iY, $WS_POPUP, $WS_EX_LAYERED) $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", $width) DllStructSetData($tSize, "Y", $height) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, 2) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hImage) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>_GUICreate_Alpha Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If ($hwnd = WinGetHandle("Look at the shiny")) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndIf EndFunc Func _exit() _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($GUI) Sleep(200) FileDelete('bak2.png') Exit EndFunc While 1 Sleep(100) WEnd My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list] Link to comment Share on other sites More sharing options...
picea892 Posted June 22, 2011 Share Posted June 22, 2011 There are two GUIs, there is one created in the _GUICreate_Alpha function. See attached fixed version, expandcollapse popup#include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> Global Const $NONANTIALIASED_QUALITY = 3 Global $hGUI ToolTip('Downloading background image, please wait',0,0) if not FileExists('bak2.png') Then InetGet("http://tinyurl.com/6jbew48", "bak2.png") ToolTip('') Opt("GUIOnEventMode", 1); Change to OnEvent mode HotKeySet('{esc}','_exit'); ALT+1 Show / Hode Gui to tray _GDIPlus_Startup() $GUI = _GUICreate_Alpha("Look at the shiny", "bak2.png", 100, 162) $myGuiHandle = WinGetHandle("Look at the shiny") $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($myGuiHandle) GUISetState() $butGui = GUICreate("ControlGUI", 400, 400, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $myGuiHandle) GUISetBkColor(0xABCDEF) $label = GUICtrlCreateLabel('Checkbox', 118, 127, 122, 22) GUICtrlSetFont(-1, 12, 600, Default, "Arial", $NONANTIALIASED_QUALITY) $btnCheckBox = GUICtrlCreateCheckbox('Checkbox', 100, 130, 12, 12) $btnCheckBox2 = GUICtrlCreateRadio('radio', 100, 150, 12, 12) $radio = GUICtrlCreateLabel('radio', 118, 146, 112, 22) GUICtrlSetFont(-1, 12, 600, Default, "Arial", $NONANTIALIASED_QUALITY) $Button1 = GUICtrlCreateButton('exit', 110, 220, 60, 23) GUICtrlSetBkColor(-1, 0x5099C0) GUICtrlSetColor(-1, 0xFFFFFF) $label = GUICtrlCreateLabel('_ x', 350, 25, 50, 25) GUICtrlSetColor(-1, 0xFFFFFF) _WinAPI_SetLayeredWindowAttributes($butGui, 0xABCDEF, 255) ;This allows the png to be dragged by clicking anywhere on the main image. GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUICtrlSetOnEvent($Button1, "_exit") GUISetState() Func _GUICreate_Alpha($sTitle, $sPath, $iX=-1, $iY=-1, $iOpacity=255) Local $hGUI, $hImage, $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hImage = _GDIPlus_ImageLoadFromFile($sPath) $width = _GDIPlus_ImageGetWidth($hImage) $height = _GDIPlus_ImageGetHeight($hImage) $hGUI = GUICreate($sTitle, $width, $height, $iX, $iY, $WS_POPUP, $WS_EX_LAYERED) $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", $width) DllStructSetData($tSize, "Y", $height) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, 2) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hImage) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>_GUICreate_Alpha Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If ($hwnd = WinGetHandle("Look at the shiny")) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndIf EndFunc Func _exit() _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($GUI) GUIDelete($hGUI) Sleep(200) FileDelete('bak2.png') Exit EndFunc While 1 Sleep(100) WEnd Link to comment Share on other sites More sharing options...
goldenix Posted June 22, 2011 Author Share Posted June 22, 2011 (edited) There are two GUIs, there is one created in the _GUICreate_Alpha function. See attached fixed version, There was an error in your example, you used wrong gui variables, I fiexd it, but It still fails to deete the bak2.npg: see the sample expandcollapse popup#include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> Global Const $NONANTIALIASED_QUALITY = 3 Global $hGUI, $butGui ToolTip('Downloading background image, please wait',0,0) if not FileExists('bak2.png') Then InetGet("http://tinyurl.com/6jbew48", "bak2.png") ToolTip('') Opt("GUIOnEventMode", 1); Change to OnEvent mode HotKeySet('{esc}','_exit'); ALT+1 Show / Hode Gui to tray _GDIPlus_Startup() $GUI = _GUICreate_Alpha("Look at the shiny", "bak2.png", 100, 162) $myGuiHandle = WinGetHandle("Look at the shiny") $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($myGuiHandle) GUISetState() $butGui = GUICreate("ControlGUI", 400, 400, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $myGuiHandle) GUISetBkColor(0xABCDEF) $label = GUICtrlCreateLabel('Checkbox', 118, 127, 122, 22) GUICtrlSetFont(-1, 12, 600, Default, "Arial", $NONANTIALIASED_QUALITY) $btnCheckBox = GUICtrlCreateCheckbox('Checkbox', 100, 130, 12, 12) $btnCheckBox2 = GUICtrlCreateRadio('radio', 100, 150, 12, 12) $radio = GUICtrlCreateLabel('radio', 118, 146, 112, 22) GUICtrlSetFont(-1, 12, 600, Default, "Arial", $NONANTIALIASED_QUALITY) $Button1 = GUICtrlCreateButton('exit', 110, 220, 60, 23) GUICtrlSetBkColor(-1, 0x5099C0) GUICtrlSetColor(-1, 0xFFFFFF) $label = GUICtrlCreateLabel('_ x', 350, 25, 50, 25) GUICtrlSetColor(-1, 0xFFFFFF) _WinAPI_SetLayeredWindowAttributes($butGui, 0xABCDEF, 255) ;This allows the png to be dragged by clicking anywhere on the main image. GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUICtrlSetOnEvent($Button1, "_exit") GUISetState() Func _GUICreate_Alpha($sTitle, $sPath, $iX=-1, $iY=-1, $iOpacity=255) Local $hGUI, $hImage, $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hImage = _GDIPlus_ImageLoadFromFile($sPath) $width = _GDIPlus_ImageGetWidth($hImage) $height = _GDIPlus_ImageGetHeight($hImage) $hGUI = GUICreate($sTitle, $width, $height, $iX, $iY, $WS_POPUP, $WS_EX_LAYERED) $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", $width) DllStructSetData($tSize, "Y", $height) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, 2) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hImage) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>_GUICreate_Alpha Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If ($hwnd = WinGetHandle("Look at the shiny")) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndIf EndFunc Func _exit() _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($butGui) GUIDelete($GUI) GUIDelete($hGUI) Sleep(1000) FileDelete('bak2.png') Exit EndFunc While 1 Sleep(100) WEnd Edited June 22, 2011 by goldenix My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list] Link to comment Share on other sites More sharing options...
picea892 Posted June 22, 2011 Share Posted June 22, 2011 I don't know why the file is not deleting, I'm guessing the file is still open and can't be deleted...perhaps there is a variable that wasn't disposed of? I'm at a loss, perhaps someone else knows the answer. Yes, you are right about the error, thanks 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