Laetterman Posted April 19, 2006 Posted April 19, 2006 How can I set the bk-Color transparent, in order to show nothing but the picture...? #include <GUIConstants.au3> $gui = GUICreate("gui0", @DesktopWidth, @DesktopHeight-20, 0, 0, $WS_POPUP, $WS_EX_Transparent) GUICtrlCreatePic("car.gif", 150, 150, 250, 150 ) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd thanx, Laetterman
Valuater Posted April 19, 2006 Posted April 19, 2006 To set the background to transparent, use GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT). just after creating the pic per help 8)
Laetterman Posted April 20, 2006 Author Posted April 20, 2006 ... it doesn't work neither. There Background is still gray with a small part shining trough... #include <GUIConstants.au3> $gui = GUICreate("gui0", @DesktopWidth, @DesktopHeight-20, 0, 0, $WS_POPUP, $WS_EX_Transparent) GUICtrlCreatePic("car.gif", 150, 150, 250, 150 ) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Laetterman
Valuater Posted April 20, 2006 Posted April 20, 2006 your picture is not a true Clear background it is white ( autoit does not change colors or make them dissappear there is a prog by larry in the scripts and scrapts that can "cut-out the car" note this #include <GUIConstants.au3> $gui = GUICreate("gui0", @DesktopWidth, @DesktopHeight-20, 0, 0, $WS_POPUP, $WS_EX_Transparent) GUISetBkColor( 0xFFFFFF) GUICtrlCreatePic("C:\Temp\car.gif", 150, 150, 250, 150 ) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUISetState() Sleep(2000) GUISetBkColor( 0x0E9EF1) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd 8)
Laetterman Posted April 20, 2006 Author Posted April 20, 2006 ok, thank u! I don't want the picture be transparent, but the rest of the gui window. Thought there is an easyer solution like GUISetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) ... bye, Laetterman
Moderators SmOke_N Posted April 20, 2006 Moderators Posted April 20, 2006 ok, thank u! I don't want the picture be transparent, but the rest of the gui window. Thought there is an easyer solution like GUISetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) ...bye, Laettermanhttp://www.autoitscript.com/forum/index.ph...opic=12827&st=0 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Laetterman Posted April 20, 2006 Author Posted April 20, 2006 (edited) mh, is it possible to move several Regions? In FAct I would like to realise drag and drop operation with for some pictures freely on the desktop. Here is what I made so far expandcollapse popup#include <GUIConstants.au3> #include <Array.au3> AutoItSetOption ( "TrayIconDebug", 1 ) Opt("WinTitleMatchMode", 3) Opt("GUIOnEventMode", 1) HotKeySet("{ESC}", "f_Terminate") DIM $anz = IniRead("test.ini", "Anzahl", "anz", 1) DIM $x[$anz], $y[$anz], $pic[$anz], $pic_ctrl[$anz], $region[$anz], $i $x[0] = IniRead("test.ini", "X-Position", "x0", 1) $y[0] = IniRead("test.ini", "Y-Position", "y0", 1) $guiArray = GUICreate("gui0", @DesktopWidth, @DesktopHeight-20, 0, 0, $WS_POPUP, $WS_EX_Transparent) WinSetOnTop ( $guiArray, "", 1 ) $close = GUICtrlCreatePic("close2.gif",-300,-200,22,22 ) GUISwitch($guiArray) For $i = 1 To $anz-1 $x[$i] = IniRead("test.ini", "X-Position", "x" & $i, 1) $y[$i] = IniRead("test.ini", "Y-Position", "y" & $i, 1) $pic[$i] = IniRead("test.ini", "Pic", "Pic" & $i, 1) $pic_ctrl[$i] = GUICtrlCreatePic($pic[$i], $x[$i], $y[$i], 150, 150 ) GUICtrlSetOnEvent(-1, "f_DragnDrop") $region[$i] = CreatePolyRgn($x[$i] & ',' & $y[$i] & ',' & $x[$i]+150 & ',' & $y[$i] & ',' & $x[$i]+150 & ',' & $y[$i]+150 & ',' & $x[$i] & ',' & $y[$i]+150 & ',' & $x[$i] & ',' & $y[$i]) If $i <> 1 Then CombineRgn($region[1],$region[$i]) Next SetWindowRgn($guiArray,$region[1]) GUISetState(@SW_SHOW,$guiArray) $i = 0 $act = 0 $last = 0 Global $TIMER=TimerInit() $THRESHOLD = Number( RegRead("HKEY_CURRENT_USER\Control Panel\Mouse", "DoubleClickSpeed") ) while 1 If UBound($x) > 1 Then $i = $i + 1 If _IsMouseOverControl($x[$i], $y[$i]) Then If ($act <> $i AND $guiArray <> @SW_DISABLE) Then GUICtrlSetPos ($close, $x[$i]-20, $y[$i]-20) $act = $i $last = $i EndIf Else If $i = $act Then $act=0 EndIf EndIf If $i = ($anz-1) Then $i = 0 WEnd Func f_DragnDrop() _DragRegion($pic_ctrl[$last], 150, 150, $x[$last], $y[$last]) EndFunc Func f_Terminate() If WinExists("Verknüpfung bearbeiten...", "") Then ; GUIDelete($win_verkn) Else $pos = WinGetPos("gui0", "") $r = 0 For $i = 1 To $anz-1 IniWrite("test.ini", "X-Position", "x0", $pos[0]) IniWrite("test.ini", "Y-Position", "y0", $pos[1]) If $x[$i] = 0 Then IniDelete("test.ini", "X-Position", "x" & $i) IniDelete("test.ini", "Y-Position", "y" & $i) IniDelete("test.ini", "Pic", "Pic" & $i) $r = $r +1 Else IniWrite("test.ini", "X-Position", "x" & $i-$r, $x[$i-$r]) IniWrite("test.ini", "Y-Position", "y" & $i-$r, $y[$i-$r]) IniWrite("test.ini", "Pic", "Pic" & $i-$r, $pic[$i-$r]) EndIf Next IniWrite("test.ini", "Anzahl", "anz", $anz-$r) Exit EndIf EndFunc Func _DragRegion ($g,$reg_x,$reg_y,ByRef $x,ByRef $y) Local $pos[2],$xm,$ym,$dx,$dy $pos = MouseGetPos() $xm=$pos[0] $ym=$pos[1] If ($xm<$x) or ($xm>($x+$reg_x)) then Return If ($ym<$y) or ($ym>($y+$reg_y)) then Return $dx=$xm-$x $dy=$ym-$y while _IsPressed(01) = 1; left mouse button $pos = MouseGetPos() IF $xm<>$pos[0] OR $ym<>$pos[1] Then $xm=$pos[0] $ym=$pos[1] $x = $xm - $dx $y = $ym - $dy GUICtrlSetPos( $g, $x, $y ) $region[$last] = CreatePolyRgn($x & ',' & $y & ',' & $x+150 & ',' & $y & ',' & $x+150 & ',' & $y+150 & ',' & $x & ',' & $y+150 & ',' & $x & ',' & $y) CombineRgn($region[1],$region[$last]) SetWindowRgn($guiArray,$region[1]) EndIf wend Return EndFunc Func _IsMouseOverControl($WinTitle,$WinText) If @error Then SetError(-1) Return 0 Else $M = MouseGetPos() $M_X = $M[0] $M_Y = $M[1] If (($M_X >= $x[$i] And $M_X <= $x[$i] + 150) And ($M_Y >= $y[$i] And $M_Y <= $y[$i] + 150)) Then Return 1 Else Return 0 EndIf EndIf EndFunc Func CreatePolyRgn($pt) Local $ALTERNATE = 1 Local $buffer = "" $pt = StringSplit($pt,",") For $i = 1 to $pt[0] $buffer = $buffer & "int;" Next $buffer = StringTrimRight($buffer,1) $lppt = DllStructCreate($buffer) For $i = 1 to $pt[0] DllStructSetData($lppt,$i,$pt[$i]) Next $ret = DllCall("gdi32.dll","long","CreatePolygonRgn","ptr",DllStructGetPtr($lppt),"int",Int($pt[0] / 2),"int",$ALTERNATE) $lppt = 0 Return $ret[0] EndFunc Func CombineRgn(ByRef $rgn1, ByRef $rgn2) DllCall("gdi32.dll", "long", "CombineRgn", "long", $rgn1, "long", $rgn1, "long", $rgn2, "int", 2) EndFunc Func SetWindowRgn($h_win, $rgn) DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $rgn, "int", 1) EndFunc Func _IsPressed($hexKey) Local $aR, $bRv $hexKey = '0x' & $hexKey $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey) If $aR[0] <> 0 Then $bRv = 1 Else $bRv = 0 EndIf Return $bRv EndFunc but it works not well... thanx in advance, Laettermanpics.zip Edited April 20, 2006 by Laetterman
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