StaticTank Posted October 12, 2012 Share Posted October 12, 2012 (edited) I am trying to write a program that has an set of images that can be dragged and dropped. I am having an issue where when I drag an image it will still show the edges of the image when dragged over a box or frame. Here is the code: expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> #Include <Icons.au3> ; Mouse coords relative to GUI client area Opt("MouseCoordMode", 2) ; Set target coords Global $iTgt_Left = 40, $iTgt_Top = 48, $iTgt_Right = 100, $iTgt_Bot = 108 #Region ### START Koda GUI section ### Form= $hGUI = GUICreate("Drag and Drop Test", 344, 144, 192, 124) ;$Label1 = GUICtrlCreateLabel("", 40, 48, 60, 60, $SS_BLACKFRAME) $Label1 = GUICtrlCreateLabel("", $iTgt_Left, $iTgt_Top, $iTgt_Right - $iTgt_Left, $iTgt_Bot - $iTgt_Top, $SS_BLACKFRAME) $Label2 = GUICtrlCreateLabel("", 247, 47, 60, 60, $SS_BLACKFRAME) ;$Pic1 = GUICtrlCreatePic("C:UsershensoncDesktopEarth-icon.gif", 248, 48, 58, 58) ;GUISetState() #EndRegion ### END Koda GUI section ### ;GUICtrlCreatePic('index.jpeg', 0, 0, 178, 192) $Pic1 = GUICtrlCreatePic('', 248, 48, 58, 58) _SetImage($Pic1, 'C:UsershensoncDesktopEarth-icon.gif') GUISetState() _WinAPI_SetLayeredWindowAttributes($hGUI, 0xFFFF33, 200) ;Test Box Dimentions ;MsgBox(1, "Test", $iTgt_Left & " & " & $iTgt_Top & " & " & $iTgt_Right - $iTgt_Left & " & " & $iTgt_Bot - $iTgt_Top) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_PRIMARYDOWN ; If the mouse button is pressed - get info about where $cInfo = GUIGetCursorInfo($hGUI) ; Is it over a control $iControl = $cInfo[4] Switch $iControl ; If it is a control we want to move Case $Pic1 ; Work out offset of mouse on control $aPos = ControlGetPos($hGUI, "", $iControl) $iSubtractX = $cInfo[0] - $aPos[0] $iSubtractY = $cInfo[1] - $aPos[1] ; And then move the control until the mouse button is released Do $cInfo = GUIGetCursorInfo($hGUI) ControlMove($hGUI, "", $iControl, $cInfo[0] - $iSubtractX, $cInfo[1] - $iSubtractY) Until Not $cInfo[2] ; See if the mouse was released over the target $aMPos = MouseGetPos() If $aMPos[0] > $iTgt_Left And $aMPos[0] < $iTgt_Right and $aMPos[1] > $iTgt_Top And $aMPos[1] < $iTgt_Bot Then Switch $iControl Case $Pic1 ControlMove($hGUI, "", $iControl, $iTgt_Left + 1, $iTgt_Top + 1) $sItem = "label" EndSwitch MsgBox(0, "Info", "Over target with " & $sItem) Else ControlMove($hGUI, "", $iControl, $aPos[0], $aPos[1]) EndIf ;MsgBox(1, "Test", $aPos[0]) EndSwitch EndSwitch WEnd How do I get it to be transparent even when dragging? Edited October 12, 2012 by StaticTank Link to comment Share on other sites More sharing options...
FireFox Posted October 12, 2012 Share Posted October 12, 2012 Hi, Please post the link to the external UDF "Icons" Br, FireFox. Link to comment Share on other sites More sharing options...
StaticTank Posted October 18, 2012 Author Share Posted October 18, 2012 Hi,Please post the link to the external UDF "Icons"Br, FireFox.Sorry, Here it is. 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