tip Posted December 11, 2010 Posted December 11, 2010 (edited) Hi to all, I'm trying to set transparency of a gui ctrl created with guictrlcreatepic(). It is not a background image and I don't want to make my gui transparent. I just want to set transparency of a single element to 60%. Just like the white box in following jpg: P.S.: It is not my gui. I just made it in Gimp to explain what I have in mind ... I've read more than several topics in the forum but all of them was about creating a transparent gui and transparent png background image. Thanks everybody in advance. Regards Tip Edited November 6, 2011 by tip [center]MsgBox_Tipped: Eye candy msgboxes/inputboxes/loginboxes. | CreateBlankBox: Semi-transparent layers with borders and rounded corners.[/center]
AdmiralAlkex Posted December 12, 2010 Posted December 12, 2010 Not perfect, but a child gui works. #include <WindowsConstants.au3> $hGUI = GUICreate(@ScriptName, 320, 240) GUISetState() $hChild = GUICreate(@ScriptName, 75, 25, 10, 10, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) GUISetState() $cIdButton = GUICtrlCreateButton("Press me!", 0, 0, 75, 25) WinSetTrans($hChild, "", 128) While 1 Switch GUIGetMsg() Case -3 Exit Case $cIdButton MsgBox(0, "I'm a title", "You pressed the button!!") EndSwitch WEnd .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
tip Posted December 12, 2010 Author Posted December 12, 2010 (edited) Thanks for the reply. I have thought of it too but I prefer not to use a child gui because on top of that transparent bar I'd like to put some labels. If I put the labels on the parent gui and then use a semi-transprent child gui, child gui(transparent bar) overlaps them. If I create a semi-transparent gui and put the labels on them, the labels look hazy . So, if possible, I perefer to set guictrlcreatepic's transparency ... Thanks again. Regards Tip Edited December 13, 2010 by tip [center]MsgBox_Tipped: Eye candy msgboxes/inputboxes/loginboxes. | CreateBlankBox: Semi-transparent layers with borders and rounded corners.[/center]
tip Posted December 20, 2010 Author Posted December 20, 2010 Hi to all again, With help from trancexx I've found a way to create a semi-transparent box over background pic and under the other ctrls. It is not perfect but it does the job. I've created a semi-transparent white box png with Gimp. Then I load it using trancexx GifAnimation UDF. The only catch is to set iARGB to 0xFFFFFF. I think that constant is responsible of the background color of semi-transparent elements. If I set to 0 or leave as default -I think it was 0xFF000000- it creates a greyish semi-transparent box. Regards Tip [center]MsgBox_Tipped: Eye candy msgboxes/inputboxes/loginboxes. | CreateBlankBox: Semi-transparent layers with borders and rounded corners.[/center]
Yashied Posted December 20, 2010 Posted December 20, 2010 Just create a single image. GUICreate('MyGUI', 600, 400) GUICtrlCreatePic('Ex.jpg', 0, 0, 600, 400) GUISetState() Do Until GUIGetMsg() = -3 My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
UEZ Posted December 20, 2010 Posted December 20, 2010 Try GDI+ - should be easy to implement. Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
Yashied Posted December 21, 2010 Posted December 21, 2010 (edited) Try GDI+ - should be easy to implement.Why? If the location is known in advance, will be easier to create ready-combined image. Edited December 21, 2010 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
UEZ Posted December 21, 2010 Posted December 21, 2010 Why? Why not! It is an alternative and not a must do stuff! And GDI+ isn't so complicated as it seems to be. It is a matter of taste... Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
Yashied Posted December 21, 2010 Posted December 21, 2010 (edited) It is a matter of taste...This matter of profitability and size of code. If there is a dialog "About" then what is the point to create the image programmatically when can we all do in one line by using the native AutoIt function GUICtrl... Edited December 21, 2010 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
UEZ Posted December 21, 2010 Posted December 21, 2010 (edited) Here one possible and very simple GDI+ code: #include <GDIPlus.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() $hBitmap = _GDIPlus_BitmapCreateFromFile("Ex.jpg") $iW = _GDIPlus_ImageGetWidth($hBitmap) $iH = _GDIPlus_ImageGetHeight($hBitmap) $hGUI = GUICreate("GDI+ Test", $iW, $iH) GUISetState() $hBrush = _GDIPlus_BrushCreateSolid(0x99E0E0F0) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsSetSmoothingMode($hGraphic, 2) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iW, $iH) _GDIPlus_GraphicsFillRect ($hGraphic, 25, 225, 550, 160, $hBrush) GUIRegisterMsg($WM_PAINT, "WM_PAINT") While GUIGetMsg() <> -3 WEnd _GDIPlus_BrushDispose($hBrush) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($hGUI) Exit Func WM_PAINT($hWnd, $Msg, $wParam, $lParam) #forceref $hWnd, $Msg, $wParam, $lParam _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW + $RDW_INVALIDATE) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iW, $iH) _GDIPlus_GraphicsFillRect ($hGraphic, 25, 225, 550, 160, $hBrush) Return "GUI_RUNDEFMSG" EndFunc It is larger than the "native" AutoIt function but much flexible in creating "effects"! If you just want to load an image and display it then use the native functions. You need the raw Ex.jpg without the polygon to see it properly. Br, UEZ Edited December 21, 2010 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
tip Posted December 21, 2010 Author Posted December 21, 2010 (edited) Hi, I found GDI+ func are not very good with semi-transparent images. I will try to explain the problem but it is a bit complicated, so bare with me. I maybe wrong here but, if I use GDI funcs to draw an image I need to register a "DrawAll" (WM_PAINT I think) func too, right? That DrawAll func redraws the image if a part/all of it goes of the screen etc. If I use GDI funcs to draw it and register a DrawAll func to keep it alive, when a part of it goes of the screen DrawAll func redraws it. So far so good. But it draws another image on top of the first image without removing the first one. This gives you 2 semi-transparent images on top of each other making a nearly non-transparent layer. It doesn't happen if all of the image goes of the screen, it happens only if a part of the image is off screen and you can see the rest. ). That's why I didn't use GDI+ func and prefered trancexx UDF. Edited May 24, 2011 by tip [center]MsgBox_Tipped: Eye candy msgboxes/inputboxes/loginboxes. | CreateBlankBox: Semi-transparent layers with borders and rounded corners.[/center]
UEZ Posted December 21, 2010 Posted December 21, 2010 I updated the GDI+ code. Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
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