diferent Posted July 3, 2009 Posted July 3, 2009 Hi people! First post. Using GDI to put a background image in my window the labels are not transparent. Using GUICtrlCreatePic to put a background image the labels are transparent. How to make labels trans with GDI? See examples down. Any help is welcome.quickimage.au3quickimage_gdi.au3
martin Posted July 3, 2009 Posted July 3, 2009 (edited) Hi people! First post. Using GDI to put a background image in my window the labels are not transparent. Using GUICtrlCreatePic to put a background image the labels are transparent. How to make labels trans with GDI? See examples down. Any help is welcome. Welcome diferent Interesting first post because it's not so easy as you would expect to get a transparent label over the area drawn using GDI. Here's one way to get what you want but I expect there are other ways. expandcollapse popup#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <FontConstants.au3> _GDIPlus_Startup () Global $BackG = _GDIPlus_ImageLoadFromFile ("C:\Documents and Settings\martin\My Documents\autoitimage2.jpg") $MainGui = GUICreate("Example", 640, 480, -1, -1) GUISetState() Global $Graphic = _GDIPlus_GraphicsCreateFromHWND ($MainGui) _GDIPlus_GraphicsDrawImageRect ($Graphic, $BackG, 0, 0, 640, 480) $_tst = GUICtrlCreateButton("Check", 280, 240, 76) DrawLabel($MainGui,"restore",280,200,75,22) GUISetState($MainGui) While 1 $MSG = GUIGetMsg() Switch $MSG Case - 3 Quit() EndSwitch WEnd Func Quit() _GDIPlus_ImageDispose ($BackG) _GDIPlus_GraphicsDispose ($Graphic) _GDIPlus_Shutdown () $tRECT = 0 Exit EndFunc ;==>Quit ;write text on window $hGui Func DrawLabel($hGui,$sLText,$iTX,$iTY,$iWid,$iHT) Local $hDC = _WinAPI_GetDC ($hGui) Local $tRECT = DllStructCreate($tagRect) DllStructSetData($tRECT, "Left",$iTX) DllStructSetData($tRECT, "Top", $iTY) DllStructSetData($tRECT, "Right", $iTX + $iWid) DllStructSetData($tRECT, "Bottom", $iTY + $iHt) Local $hFont = _WinAPI_CreateFont (14, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _ $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial') Local $hOldFont = _WinAPI_SelectObject ($hDC, $hFont) _WinAPI_SetTextColor ($hDC, 0);0x0000FF) _WinAPI_SetBkMode ($hDC, $TRANSPARENT) _WinAPI_DrawText ($hDC, $sLText, $tRECT, $DT_CENTER) _WinAPI_SelectObject ($hDC, $hOldFont) _WinAPI_DeleteObject ($hFont) _WinAPI_ReleaseDC ($hGui, $hDC) EndFunc ;==>DrawLabel EDIT:Spelling. Edited July 3, 2009 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
diferent Posted July 4, 2009 Author Posted July 4, 2009 Thanks martin for the help. Im using your solution now. You save me.
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