Sign in to follow this  
Followers 0
YellowLab

Move Transparent Image Without Flicker

7 posts in this topic

As far as I have seen on these forums, there are two ways to move a control: ControlMove and GUICtrlSetPos. Both work but have drawbacks when moving across non-uniform backgrounds.

GUICtrlSetPos causes flicker. This can be more or less depending on the computer, but it is always present - at least from what I have seen.

ControlMove doesn't have the flicker, but the control doesn't keep the image in tact.

Then I stumbled onto this topic:

http://www.autoitscript.com/forum/index.php?showtopic=102961

and thought what if you used a layered window as a container to move the image. That is what I have done:

#include-once
#include <GUIConstantsEx.au3>
#Include <Misc.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode",1)
Opt("MouseCoordMode", 2)

$sPictureLocation=@ScriptDir&'\start1.png'

Global $hMain=GUICreate("Smooth Move",@DesktopWidth-6,(@DesktopWidth-6)/2,0,0)
GUISetBkColor(0xFFFFFF,$hMain)
GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")

_GDIPlus_Startup()
$hImage1 = _GDIPlus_ImageLoadFromFile($sPictureLocation)
$hPic=GUICtrlCreatePic('',100,25,_GDIPlus_ImageGetWidth($hImage1),_GDIPlus_ImageGetHeight($hImage1))
GUICtrlSetOnEvent(-1,"_PicClick")
GUICtrlSetState(-1,$GUI_ONTOP)
$hBMP1=_GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage1)
_WinAPI_DeleteObject(GUICtrlSendMsg($hPic, 0x0172, 0, $hBMP1))
_GDIPlus_ImageDispose($hImage1)
_GDIPlus_Shutdown()

;Create a checkerboard
$hStart=GUICtrlCreateDummy()
For $i=0 To 5
    For $j=0 To 10
        If $j=0 and Mod($i,2)=0 Then $j+=1
        GUICtrlCreateLabel("",(@DesktopWidth-6)/10*$j,(@DesktopWidth-6)/10*$i,(@DesktopWidth-6)/10,(@DesktopWidth-6)/10)
        GUICtrlSetBkColor(-1,0x000000)
        GUICtrlSetState(-1,$GUI_ONTOP)
        $j+=1
    Next
Next
$hEnd=GUICtrlCreateDummy()

$hGroup=GUICtrlCreateGroup("Move Type",10,10,(@DesktopWidth-6)/10-20,(@DesktopWidth-6)/10-20)
GUICtrlCreateRadio("ControlMove",20,25,80,20)
    GUICtrlSetState(-1,$GUI_CHECKED)
    GUICtrlSetOnEvent(-1,"_Radio")
GUICtrlCreateRadio("GetCtrlPos",20,55,80,20)
    GUICtrlSetOnEvent(-1,"_Radio")
GUICtrlCreateRadio("Move Window",20,85,85,20)
    GUICtrlSetOnEvent(-1,"_Radio")
GUICtrlCreateGroup("",-99,-99,-1,-1)

$hLabel=GUICtrlCreateLabel("Control Move:  Smooth moving but not transparent",300,25,300,50)
GUICtrlSetColor(-1,0xFF0000)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

GUISetState(@SW_SHOW,$hMain)

While 1
    Sleep(10)
WEnd

Func _PicClick()
    Select
        Case BitAND(GUICtrlRead($hGroup+1),$GUI_CHECKED)=$GUI_CHECKED
            _ControlMove(@GUI_CtrlId)
        Case BitAND(GUICtrlRead($hGroup+2),$GUI_CHECKED)=$GUI_CHECKED
            _SetPositionmove(@GUI_CtrlId)
        Case BitAND(GUICtrlRead($hGroup+3),$GUI_CHECKED)=$GUI_CHECKED
            _SmoothMove(@GUI_CtrlId)
    EndSelect
    
    ;If Out of Window put back
    $bChange=False
    $arPos=ControlGetPos($hMain,'',@GUI_CtrlId)
    If $arPos[0]<0 Then 
        $arPos[0]=0
        $bChange=True
    EndIf
    If $arPos[1]<0 Then 
        $arPos[1]=0
        $bChange=True
    EndIf
    If $arPos[0]+$arPos[2]>@DesktopWidth-6 Then
        $arPos[0]=@DesktopWidth-6-$arPos[2]
        $bChange=True
    EndIf
    If $arPos[1]+$arPos[3]>(@DesktopWidth-6)/2 Then
        $arPos[1]=(@DesktopWidth-6)/2-$arPos[3]
        $bChange=True
    EndIf
    If $bChange Then GUICtrlSetPos(@GUI_CtrlId,$arPos[0],$arPos[1])
    
    ;Layering
    GUICtrlSetState(@GUI_CtrlId,$GUI_ONTOP)
    For $i=$hStart to $hEnd
        GUICtrlSetState($i,$GUI_ONTOP)
    Next
EndFunc
    
Func _ControlMove($nCID)
    $arPos=MouseGetPos()
    $arPieceInfo=ControlGetPos($hMain,"",$nCID)
    $nXOffset=$arPos[0]-$arPieceInfo[0]
    $nYOffset=$arPos[1]-$arPieceInfo[1]
    
    While _IsPressed("01")
        $arPos=MouseGetPos()
        ControlMove($hMain,'',$nCID,$arPos[0]-$nXOffset,$arPos[1]-$nYOffset)
        Sleep(10)
    WEnd
    GUICtrlSetState($nCID,$GUI_ONTOP)
EndFunc

Func _SetPositionmove($nCID)
    $arPos=MouseGetPos()
    $arPieceInfo=ControlGetPos($hMain,"",$nCID)
    $nXOffset=$arPos[0]-$arPieceInfo[0]
    $nYOffset=$arPos[1]-$arPieceInfo[1]
    While _IsPressed("01")
        $arPos=MouseGetPos()
        GUICtrlSetPos($nCID,$arPos[0]-$nXOffset,$arPos[1]-$nYOffset)
        Sleep(10)
    WEnd
EndFunc

Func _SmoothMove($nCID)
    $arPos=MouseGetPos()

    ;Define Coordinate offset
    Opt("MouseCoordMode",1)
    $Temp=MouseGetPos()
    Opt("MouseCoordMode",2)
    Local $nGlobalYOffset=$Temp[1]-$arPos[1]
    Local $nGlobalXOffset=$Temp[0]-$arPos[0]
    
    $arPieceInfo=ControlGetPos($hMain,"",$nCID)
    $nXOffset=$arPos[0]-$arPieceInfo[0]
    $nYOffset=$arPos[1]-$arPieceInfo[1]
    Local $hTempWin=GUICreate('temp',$arPieceInfo[2],$arPieceInfo[3],$arPieceInfo[0]+$nGlobalXOffset,$arPieceInfo[1]+$nGlobalYOffset, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD,$WS_EX_TOPMOST),$hMain)
    _GDIPlus_Startup()
    $hImage1 = _GDIPlus_ImageLoadFromFile($sPictureLocation)
    _SetBitmap($hTempWin,$hImage1,255)
    _GDIPlus_ImageDispose($hImage1)
    GUISetState(@SW_SHOWNA,$hTempWin)
    GUICtrlSetState($nCID,$GUI_HIDE)
    
    While _IsPressed("01")
        $arPos=MouseGetPos()
        WinMove($hTempWin,'',$arPos[0]-$nXOffset+$nGlobalXOffset,$arPos[1]-$nYOffset+$nGlobalYOffset)
    WEnd
    
    $arPos=WinGetPos($hTempWin)
    GUICtrlSetPos($nCID,$arPos[0]-$nGlobalXOffset,$arPos[1]-$nGlobalYOffset)
    GUICtrlSetState($nCID,$GUI_SHOW)
    GUIDelete($hTempWin)
    GUISwitch($hMain)
EndFunc

;http://www.autoitscript.com/forum/index.php?showtopic=102961
Func _SetBitmap($hGUI, $hImage, $iOpacity)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
    Local $AC_SRC_ALPHA=1
    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
    _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc   ;==>SetBitmap

Func _Radio()
    Local $sText
    Switch @GUI_CTRLID-$hGroup
        Case 1
            $sText="Control Move:  Smooth moving but not transparent"
        Case 2
            $sText="Set Control Position: Transparent but has some flicker which is computer dependent."
        Case 3
            $sText="Move Window:  Best of both worlds - smooth move and transparent."
    EndSwitch
    GUICtrlSetData($hLabel,$sText)
EndFunc

Func _Exit()
    GUIDelete($hMain)
    Exit
EndFunc

It probably isn't the cleanest script and there is some layering issues with the checkerboard - don't put the piece on a black square or you won't be able to move it. Those things can be addressed and customized for your scripts. This is just an example to show you that it can be done.

Attached is the start1.png file used, but it should work with any .png file you have.

I have tried to get this to work with text by recreating the lable on a transparent window but have not been successful.

Any thoughts or improvements would be appreciated.


You can't see a rainbow without first experiencing the rain.

Share this post


Link to post
Share on other sites



Nice! But you forgot to add GUICtrlSetOnEvent(-1,"_PicClick") after GUICtrlSetState(-1,$GUI_ONTOP) in the loop, otherwise the controls does not move :mellow:


Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

MrCreatoR - the controls created in the loop aren't supposed to move; those controls are the background. The squares will not experince any problems associtated with control move and should be moved that way in order to prevent flicker.

The picture control, $hPic, is the one that is supposed to move. The radio button toggles the three different methods for moving the controls. It can be defined by any png file, and is determined by $sPictureLocation.

As I stated, there is some issue with layering so don't put the picture control directly ontop of a black square or it won't be able to be selected later. I have attached the "start1.png" file that I used in my script. Download it and put it in the script directory.

post-34148-12664431246911_thumb.png


You can't see a rainbow without first experiencing the rain.

Share this post


Link to post
Share on other sites

I have attached the "start1.png" file that I used in my script

You could (and have should) attach it in the first post, to avoid such confusuions :mellow:

Thanks.


Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

This version fixes a few layering / drawing bugs. Still, gets goofy if you drop the pic over the radio buttons.

#include-once
#include <GUIConstantsEx.au3>
#Include <Misc.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>

Opt("GUIOnEventMode",1)
Opt("MouseCoordMode", 2)

$sPictureLocation=@ScriptDir&'\start1.png'

Global $hMain=GUICreate("Smooth Move",@DesktopWidth-6,(@DesktopWidth-6)/2,0,0)
GUISetBkColor(0xFFFFFF,$hMain)
;Create a checkerboard
$hStart=GUICtrlCreateDummy()
For $i=0 To 5
    For $j=0 To 10
        If $j=0 and Mod($i,2)=0 Then $j+=1
        GUICtrlCreateLabel("",(@DesktopWidth-6)/10*$j,(@DesktopWidth-6)/10*$i,(@DesktopWidth-6)/10,(@DesktopWidth-6)/10, $WS_CLIPSIBLINGS)
        GUICtrlSetBkColor(-1,0x000000)
        GUICtrlSetState(-1, $GUI_DISABLE)
        $j+=1
    Next
Next
$hEnd=GUICtrlCreateDummy()

$hGroup=GUICtrlCreateGroup("Move Type",10,10,(@DesktopWidth-6)/10-20,(@DesktopWidth-6)/10-20)
GUICtrlCreateRadio("ControlMove",20,25,80,20)
    GUICtrlSetState(-1,$GUI_CHECKED)
    GUICtrlSetOnEvent(-1,"_Radio")
GUICtrlCreateRadio("GetCtrlPos",20,55,80,20)
    GUICtrlSetOnEvent(-1,"_Radio")
GUICtrlCreateRadio("Move Window",20,85,85,20)
    GUICtrlSetOnEvent(-1,"_Radio")
GUICtrlCreateGroup("",-99,-99,-1,-1)

$hLabel=GUICtrlCreateLabel("Control Move:  Smooth moving but not transparent",300,25,300,50)
GUICtrlSetColor(-1,0xFF0000)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

; create pic control last
_GDIPlus_Startup()
$hImage1 = _GDIPlus_ImageLoadFromFile($sPictureLocation)
$hPic=GUICtrlCreatePic('',100,25,_GDIPlus_ImageGetWidth($hImage1),_GDIPlus_ImageGetHeight($hImage1))
GUICtrlSetOnEvent(-1,"_PicClick")
$hBMP1=_GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage1)
_WinAPI_DeleteObject(GUICtrlSendMsg($hPic, 0x0172, 0, $hBMP1))
_GDIPlus_ImageDispose($hImage1)
_GDIPlus_Shutdown()

GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
GUISetState(@SW_SHOW,$hMain)

While 1
    Sleep(10)
WEnd

Func _PicClick()
    Select
        Case BitAND(GUICtrlRead($hGroup+1),$GUI_CHECKED)=$GUI_CHECKED
            _ControlMove(@GUI_CtrlId)
        Case BitAND(GUICtrlRead($hGroup+2),$GUI_CHECKED)=$GUI_CHECKED
            _SetPositionmove(@GUI_CtrlId)
        Case BitAND(GUICtrlRead($hGroup+3),$GUI_CHECKED)=$GUI_CHECKED
            _SmoothMove(@GUI_CtrlId)
    EndSelect

    ;If Out of Window put back
    $bChange=False
    $arPos=ControlGetPos($hMain,'',@GUI_CtrlId)
    If $arPos[0]<0 Then
        $arPos[0]=0
        $bChange=True
    EndIf
    If $arPos[1]<0 Then
        $arPos[1]=0
        $bChange=True
    EndIf
    If $arPos[0]+$arPos[2]>@DesktopWidth-6 Then
        $arPos[0]=@DesktopWidth-6-$arPos[2]
        $bChange=True
    EndIf
    If $arPos[1]+$arPos[3]>(@DesktopWidth-6)/2 Then
        $arPos[1]=(@DesktopWidth-6)/2-$arPos[3]
        $bChange=True
    EndIf
    If $bChange Then GUICtrlSetPos(@GUI_CtrlId,$arPos[0],$arPos[1])

    ;Layering
;~     GUICtrlSetState(@GUI_CtrlId,$GUI_ONTOP)
;~     For $i=$hStart to $hEnd
;~         GUICtrlSetState($i,$GUI_ONTOP)
;~     Next
EndFunc

Func _ControlMove($nCID)
    $arPos=MouseGetPos()
    $arPieceInfo=ControlGetPos($hMain,"",$nCID)
    $nXOffset=$arPos[0]-$arPieceInfo[0]
    $nYOffset=$arPos[1]-$arPieceInfo[1]

    While _IsPressed("01")
        $arPos=MouseGetPos()
        ControlMove($hMain,'',$nCID,$arPos[0]-$nXOffset,$arPos[1]-$nYOffset)
        Sleep(10)
    WEnd
EndFunc

Func _SetPositionmove($nCID)
    $arPos=MouseGetPos()
    $arPieceInfo=ControlGetPos($hMain,"",$nCID)
    $nXOffset=$arPos[0]-$arPieceInfo[0]
    $nYOffset=$arPos[1]-$arPieceInfo[1]
    While _IsPressed("01")
        $arPos=MouseGetPos()
        GUICtrlSetPos($nCID,$arPos[0]-$nXOffset,$arPos[1]-$nYOffset)
        Sleep(10)
    WEnd
EndFunc

Func _SmoothMove($nCID)
    $arPos=MouseGetPos()

    ;Define Coordinate offset
    Opt("MouseCoordMode",1)
    $Temp=MouseGetPos()
    Opt("MouseCoordMode",2)
    Local $nGlobalYOffset=$Temp[1]-$arPos[1]
    Local $nGlobalXOffset=$Temp[0]-$arPos[0]

    $arPieceInfo=ControlGetPos($hMain,"",$nCID)
    $nXOffset=$arPos[0]-$arPieceInfo[0]
    $nYOffset=$arPos[1]-$arPieceInfo[1]
    Local $hTempWin=GUICreate('temp',$arPieceInfo[2],$arPieceInfo[3],$arPieceInfo[0]+$nGlobalXOffset,$arPieceInfo[1]+$nGlobalYOffset, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD,$WS_EX_TOPMOST),$hMain)
    _GDIPlus_Startup()
    $hImage1 = _GDIPlus_ImageLoadFromFile($sPictureLocation)
    _SetBitmap($hTempWin,$hImage1,255)
    _GDIPlus_ImageDispose($hImage1)
    GUISetState(@SW_SHOWNA,$hTempWin)
    GUICtrlSetState($nCID,$GUI_HIDE)

    While _IsPressed("01")
        $arPos=MouseGetPos()
        WinMove($hTempWin,'',$arPos[0]-$nXOffset+$nGlobalXOffset,$arPos[1]-$nYOffset+$nGlobalYOffset)
    WEnd

    $arPos=WinGetPos($hTempWin)
    GUICtrlSetPos($nCID,$arPos[0]-$nGlobalXOffset,$arPos[1]-$nGlobalYOffset)
    GUICtrlSetState($nCID,$GUI_SHOW)
    GUIDelete($hTempWin)
    GUISwitch($hMain)
EndFunc

;http://www.autoitscript.com/forum/index.php?showtopic=102961
Func _SetBitmap($hGUI, $hImage, $iOpacity)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
    Local $AC_SRC_ALPHA=1
    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
    _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc   ;==>SetBitmap

Func _Radio()
    Local $sText
    Switch @GUI_CTRLID-$hGroup
        Case 1
            $sText="Control Move:  Smooth moving but not transparent"
        Case 2
            $sText="Set Control Position: Transparent but has some flicker which is computer dependent."
        Case 3
            $sText="Move Window:  Best of both worlds - smooth move and transparent."
    EndSwitch
    GUICtrlSetData($hLabel,$sText)
EndFunc

Func _Exit()
    GUIDelete($hMain)
    Exit
EndFunc

Share this post


Link to post
Share on other sites

@wraithdu

If you select the Move Window option and drag the image, and while you are dragging you press the right mouse button it tries to draw the image in 2 places. Press the right button a second time and the effect stops.

I assume that you need to handle the event, or handle $WM_CONTEXTMENU.


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.

Share this post


Link to post
Share on other sites

Yeah, I have no idea what that is about. If the OP cares, he can try to fix it.

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  
Followers 0