Jump to content
Sign in to follow this  
StaticTank

Drag and Drop Transparency

Recommended Posts

StaticTank

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:

#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 by StaticTank

Share this post


Link to post
Share on other sites
FireFox

Hi,

Please post the link to the external UDF "Icons"

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
StaticTank

Hi,

Please post the link to the external UDF "Icons"

Br, FireFox.

Sorry, Here it is.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×