dummyvoid Posted October 29, 2018 Posted October 29, 2018 Masters, Good day! The following program can display an animated GIF "C;\Animation.gif" on the center of the screen. The position is fixed, but I want to enable dragging, so I tried WM_NCHITTEST Function but failed. Please help me modify the codes, thank you. include <WindowsConstants.au3> #include <WinAPI.au3> #include "GIFAnimation.au3" Opt("GUICloseOnESC", 1); ESC to exit Opt("MustDeclareVars", 1) Global $sFile = "C:\Animation.gif" ; Get dimension of the GIF Global $aGIFDimension = _GIF_GetDimension($sFile) ; Make GUI Global $hGui = GUICreate("GIF Animation", $aGIFDimension[0], $aGIFDimension[1], -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_WINDOWEDGE, $WS_EX_TOPMOST), WinGetHandle(AutoitWinGetTitle())) ; GIF job Global $hGIF = _GUICtrlCreateGIF($sFile, "", 0, 0) ; Make GUI transparent GUISetBkColor(345) ; some random color _WinAPI_SetLayeredWindowAttributes($hGui, 345, 255) ; making the GUI transparent _WinAPI_SetParent($hGui, 0) ; Show it GUISetState() ; Loop till end While 1 If GUIGetMsg() = - 3 Then Exit WEnd
Bilgus Posted October 30, 2018 Posted October 30, 2018 See: https://www.autoitscript.com/wiki/Moving_and_Resizing_PopUp_GUIs Took me more time to change your example so I could run it than it did to add the dragging code expandcollapse popup#include <WindowsConstants.au3> #include <WinAPI.au3> #include <GuiconstantsEx.au3> #include <SendMessage.au3> ;https://www.autoitscript.com/wiki/Moving_and_Resizing_PopUp_GUIs Global Const $SC_DRAGMOVE = 0xF012 ;#include "GIFAnimation.au3" Opt("GUICloseOnESC", 1); ESC to exit Opt("MustDeclareVars", 1) Global $sFile = "C:\Animation.gif" ; Get dimension of the GIF ;Global $aGIFDimension = _GIF_GetDimension($sFile) Global $aGIFDimension[] = [100, 100] ; Make GUI Global $hGui = GUICreate("GIF Animation", $aGIFDimension[0], $aGIFDimension[1], -1, -1, $WS_POPUP, BitOR(0 , $WS_EX_WINDOWEDGE, $WS_EX_TOPMOST), WinGetHandle(AutoitWinGetTitle())) ;$WS_EX_LAYERED ; GIF job ;Global $hGIF = _GUICtrlCreateGIF($sFile, "", 0, 0) ; Make GUI transparent GUISetBkColor(345) ; some random color ;_WinAPI_SetLayeredWindowAttributes($hGui, 345, 255) ; making the GUI transparent _WinAPI_SetParent($hGui, 0) ; Show it GUISetState() ; Loop till end While 1 Switch GUIGetMsg() Case $GUI_EVENT_PRIMARYDOWN _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) Case -3 Exit EndSwitch WEnd
dummyvoid Posted October 30, 2018 Author Posted October 30, 2018 Many thanks to Bilgus. Now I know how to modify my codes.
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