Sign in to follow this  
Followers 0
a440hz

Trouble controlling three advanced graphic GUIs [Solved]

4 posts in this topic

#1 ·  Posted (edited)

Hi all!

I sure do love AutoIt and have had a lot of fun learning how to use it. This forum is fantastic and full of very brilliant people who love to code and are more than willing to help others learn. Thank you all for your contributions. I can't count how many times I've had to search though the forum to find out how to do something that stumped me. In most cases I would always try to find the answer on my own or by searching the forum but this time I need a little help.

What I'm trying to do is create a player interface that is completely created of transparent gifs on layered windows. After much reading here, I have created a main gui and two others that slide up and down underneath the main gui. I have rollovers on the transport and top tools and a scrolling text marquee and everything work just like I want it. Except one thing, I cant move the main gui and have the other windows follow it. I've tried making the child windows but they refuse to stay behind the main gui. I'm sure there is an easy answer to my problem. I'm including the images folder as a zipped attachment as well as the working code. Please help and thanks in advance!

Joe

#include <Constants.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>
#include <Marquee.au3>
#include <Misc.au3>
#include <StaticConstants.au3>

Opt("GUIOnEventMode", 1)
Opt("MouseCoordMode", 0)
Opt("WinTitleMatchMode", 4)
Opt('MustDeclareVars', 0)

Global Const $AC_SRC_ALPHA = 1
Global Const $SC_DRAGMOVE = 0xF012
Global $UserDll = DllOpen("user32.dll")

#Region ; GUI Variables
_GDIPlus_Startup()
;Buttons & Sliders
Global $gFile, $Hnd, $CurPos
Global $Dw = @DesktopWidth
Global $Dh = @DesktopHeight
Global $Gw, $Gh, $Gx, $Gy
Global $Ow, $Oh, $Ox, $Oy

$gFile = @ScriptDir & "\images\playlistgui.gif"
Global $PlayListGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
$gFile = @ScriptDir & "\images\mixergui.gif"
Global $MixerGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
$gFile = @ScriptDir & "\images\playergui.gif"
Global $PlayerGUIImage = _GDIPlus_ImageLoadFromFile($gFile)
Global $MW = _GDIPlus_ImageGetWidth($PlayerGUIImage)
Global $MH = _GDIPlus_ImageGetHeight($PlayerGUIImage)
Global $MX = ($Dw/2) - ($MW/2)
Global $MY = ($Dh/2) - ($MH/2)
Global $Ow = 440, $Oh = 350
Global $Ox = ($Dw/2) - ($Ow/2)
Global $Oy = ($Dh/2) - ($Oh/2)

; Close
$gFile = @ScriptDir & "\images\close.gif"
Global $CloseButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
Global $CloseW = _GDIPlus_ImageGetWidth($CloseButtonGuiImage)
Global $CloseH = _GDIPlus_ImageGetHeight($CloseButtonGuiImage)
Global $CloseT = 34
Global $CloseL = 379
;CloseOver
$gFile = @ScriptDir & "\images\close_over.gif"
Global $CloseButtonOverImage = _GDIPlus_ImageLoadFromFile($gFile)

;Minimize
$gFile = @ScriptDir & "\images\minimize.gif"
Global $MinimizeButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
Global $MinimizeW = _GDIPlus_ImageGetWidth($MinimizeButtonGuiImage)
Global $MinimizeH = _GDIPlus_ImageGetHeight($MinimizeButtonGuiImage)
Global $MinimizeT = 34
Global $MinimizeL = 348

;MinimizeOver
$gFile = @ScriptDir & "\images\minimize_over.gif"
Global $MinimizeButtonOverImage = _GDIPlus_ImageLoadFromFile($gFile)

;Playlist
$gFile = @ScriptDir & "\images\playlist.gif"
Global $PlaylistButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
Global $PlaylistW = _GDIPlus_ImageGetWidth($PlaylistButtonGuiImage)
Global $PlaylistH = _GDIPlus_ImageGetHeight($PlaylistButtonGuiImage)
Global $PlaylistT = 34
Global $PlaylistL = 60

;PlaylistOver
$gFile = @ScriptDir & "\images\playlist_over.gif"
Global $PlaylistButtonOverImage = _GDIPlus_ImageLoadFromFile($gFile)

;Options
$gFile = @ScriptDir & "\images\options.gif"
Global $OptionsButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
Global $OptionsW = _GDIPlus_ImageGetWidth($OptionsButtonGuiImage)
Global $OptionsH = _GDIPlus_ImageGetHeight($OptionsButtonGuiImage)
Global $OptionsT = 34
Global $OptionsL = 91

;OptionsOver
$gFile = @ScriptDir & "\images\options_over.gif"
Global $OptionsButtonOverImage = _GDIPlus_ImageLoadFromFile($gFile)

; Play
$gFile = @ScriptDir & "\images\play.gif"
Global $PlayButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
Global $PlayW = _GDIPlus_ImageGetWidth($PlayButtonGuiImage)
Global $PlayH = _GDIPlus_ImageGetHeight($PlayButtonGuiImage)
Global $PlayT = 191
Global $PlayL = 220

; PlayOver
$gFile = @ScriptDir & "\images\play_over.gif"
Global $PlayButtonOverImage = _GDIPlus_ImageLoadFromFile($gFile)

; Stop
Global $gFile = @ScriptDir & "\images\stop.gif"
Global $StopButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
Global $StopW = _GDIPlus_ImageGetWidth($StopButtonGuiImage)
Global $StopH = _GDIPlus_ImageGetHeight($StopButtonGuiImage)
Global $StopT = 191
Global $StopL = 170

; StopOver
Global $gFile = @ScriptDir & "\images\stop_over.gif"
Global $StopButtonOverImage = _GDIPlus_ImageLoadFromFile($gFile)

; Pause
$gFile = @ScriptDir & "\images\pause.gif"
Global $PauseButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
Global $PauseW = _GDIPlus_ImageGetWidth($PauseButtonGuiImage)
Global $PauseH = _GDIPlus_ImageGetHeight($PauseButtonGuiImage)
Global $PauseT = 191
Global $PauseL = 270

; PauseOver
$gFile = @ScriptDir & "\images\pause_over.gif"
Global $PauseButtonOverImage = _GDIPlus_ImageLoadFromFile($gFile)

; Prev
Global $gFile = @ScriptDir & "\images\prev.gif"
Global $PrevButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
Global $PrevW = _GDIPlus_ImageGetWidth($PrevButtonGuiImage)
Global $PrevH = _GDIPlus_ImageGetHeight($PrevButtonGuiImage)
Global $PrevT = 191
Global $PrevL = 120

; PrevOver
Global $gFile = @ScriptDir & "\images\prev_over.gif"
Global $PrevButtonOverImage = _GDIPlus_ImageLoadFromFile($gFile)

; Next
$gFile = @ScriptDir & "\images\next.gif"
Global $NextButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
Global $NextW = _GDIPlus_ImageGetWidth($NextButtonGuiImage)
Global $NextH = _GDIPlus_ImageGetHeight($NextButtonGuiImage)
Global $NextT = 191
Global $NextL = 320

; NextOver
$gFile = @ScriptDir & "\images\next_Over.gif"
Global $NextButtonOverImage = _GDIPlus_ImageLoadFromFile($gFile)
Global $t; for/next counter
Global $i, $d, $v, $c
Global $X, $Y, $X2, $Y2 ;X Y Coordinate Holders
Global $ScrollingTextGUI, $ScrollingTextHnd
Global $TextBG = 0x000000
Global $text = "Please help me move my brothers along with me when I go?"
Global $sTextFG = 0xe4d701
Global $TextBGImage = @ScriptDir & "\images\20pxtextbox.gif"
Global $TextW = 349
Global $TextH = 20
Global $TextT = 0
Global $TextL = 0
Global $TextEdgeL = 59
Global $TextEdgeT = 155

; Main GUI
Global $PlayerGUI = GUICreate("s2smain", $MW, $MH, $MX, $MY, $WS_POPUP,$WS_EX_LAYERED)
SetBitmap($PlayerGUI, $PlayerGUIImage, 255)
Global $PlayerGUIHnd = WinGetHandle($PlayerGUI)
_GUICtrlMarquee_Create("Default Marquee Parameters",    10,  10, 300, 20)
GUISetOnEvent($GUI_EVENT_MOUSEMOVE,"_CatchWindowEvents",$PlayerGUIHnd)
GUISetIcon("as1trans.ico")
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUISetState()

;MixerGui
Global $MixerGUI = GUICreate("S2SMixer", $MW, $MH, $MX, $MY,$WS_POPUP,BitOR($WS_EX_TOOLWINDOW,$WS_EX_LAYERED))
SetBitmap($MixerGUI, $MixerGuiImage, 255)
Global $MixerGuiHnd = WinGetHandle($MixerGUI)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_MoveMixer",$MixerGuiHnd)
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUISetState()
_WinAPI_SetWindowPos($MixerGuiHnd, $PlayerGUIHnd, $MX, $MY, $MW, $MH, $SWP_SHOWWINDOW)

;PlaylistGui
Global $PlayListGUI = GUICreate("S2SPlaylist", $MW, $MH, $MX, $MY, $WS_POPUP,BitOR($WS_EX_TOOLWINDOW,$WS_EX_LAYERED))
SetBitmap($PlayListGUI, $PlayListGuiImage, 255)
Global $PlayListGuiHnd = WinGetHandle($PlayListGUI)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_MovePlaylist",$PlayListGuiHnd)
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUISetState()
_WinAPI_SetWindowPos($PlayListGuiHnd, $MixerGuiHnd, $MX, $MY, $MW, $MH, $SWP_NOACTIVATE)

; Create CloseButton
Global $CloseButtonGUI = GUICreate("CloseButton", $CloseW, $CloseH, $CloseL, $CloseT,$WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $PlayerGUIHnd)
SetBitmap($CloseButtonGUI, $CloseButtonGuiImage, 255)
Global $CloseButtonHnd = WinGetHandle($CloseButtonGUI)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_CloseProgram",$CloseButtonHnd)
GUISetState()

; Create MinimizeButtonGUI
Global $MinimizeButtonGUI = GUICreate("MinimizeButton", $MinimizeW, $MinimizeH, $MinimizeL, $MinimizeT,$WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $PlayerGUIHnd)
SetBitmap($MinimizeButtonGUI, $MinimizeButtonGuiImage, 255)
Global $MinimizeButtonHnd = WinGetHandle($MinimizeButtonGUI)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_Minimize",$MinimizeButtonHnd)
GUISetState()

; Create PlaylistButtonGUI
Global $PlaylistButtonGUI = GUICreate("PlaylistButton", $PlaylistW, $PlaylistH, $PlaylistL,$PlaylistT,$WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $PlayerGUIHnd)
SetBitmap($PlaylistButtonGUI, $PlaylistButtonGuiImage, 255)
Global $PlaylistButtonHnd = WinGetHandle($PlaylistButtonGUI)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_Playlist",$PlaylistButtonGUI)
GUISetState()

; Create OptionsButtonGUI
Global $OptionsButtonGUI = GUICreate("OptionsButton", $OptionsW, $OptionsH, $OptionsL,$OptionsT,$WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $PlayerGUIHnd)
SetBitmap($OptionsButtonGUI, $OptionsButtonGuiImage, 255)
Global $OptionsButtonHnd = WinGetHandle($OptionsButtonGUI)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_Options",$OptionsButtonHnd)
GUISetState()

; Create PlayButtonGUI
Global $PlayButtonGUI = GUICreate("PlayButton", $PlayW, $PlayH, $PlayL, $PlayT,$WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $PlayerGUIHnd)
SetBitmap($PlayButtonGUI, $PlayButtonGuiImage, 255)
Global $PlayButtonHnd = WinGetHandle($PlayButtonGUI)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_Play",$PlayButtonGUI)
GUISetState()

; Create StopButtonGUI
Global $StopButtonGUI = GUICreate("StopButton", $StopW, $StopH, $StopL, $StopT,$WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $PlayerGUIHnd)
SetBitmap($StopButtonGUI, $StopButtonGuiImage, 255)
Global $StopButtonHnd = WinGetHandle($StopButtonGUI)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_StopPlayback",$StopButtonGUI)
GUISetState()

; Create PauseButtonGUI
Global $PauseButtonGUI = GUICreate("PauseButton", $PauseW, $PauseH, $PauseL, $PauseT,$WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $PlayerGUIHnd)
SetBitmap($PauseButtonGUI, $PauseButtonGuiImage, 255)
Global $PauseButtonHnd = WinGetHandle($PauseButtonGUI)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_PausePlayback",$PauseButtonGUI)
GUISetState()

; Create PrevButtonGUI
Global $PrevButtonGUI = GUICreate("PrevButton", $PrevW, $PrevH, $PrevL, $PrevT,$WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $PlayerGUIHnd)
SetBitmap($PrevButtonGUI, $PrevButtonGuiImage, 255)
Global $PrevButtonHnd = WinGetHandle($PrevButtonGUI)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_PrevPlayback",$PrevButtonGUI)
GUISetState()

; Create NextButtonGUI
Global $NextButtonGUI = GUICreate("NextButton", $NextW, $NextH, $NextL, $NextT,$WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $PlayerGUIHnd)
SetBitmap($NextButtonGUI, $NextButtonGuiImage, 255)
Global $NextButtonHnd = WinGetHandle($NextButtonGUI)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_NextPlayback",$NextButtonGUI)
GUISetState()


_SetScrollText($text)


#Region ; Main Loop
While 1
    _GetCursorPosition($PlayerGUIHnd)
WEnd

Func _MovePlaylist()
    $cursor1 = _WinAPI_GetCursorInfo()
    $X = $cursor1[3]
    $Y = $cursor1[4]
    While _IsPressed("01", $UserDll)
        $npos = WinGetPos($MixerGuiHnd)
        $cursor2 = _WinAPI_GetCursorInfo()
        $Y2 = $cursor2[4] -  10
        If $Y2 < $MY -170 Then $Y2 = $MY -170
        If $Y2 > $MY Then $Y2 = $MY
        _WinAPI_SetWindowPos($PlayListGuiHnd, $MixerGuiHnd, $MX, $Y2, $MW, $MH, $SWP_NOACTIVATE)
    Wend
EndFunc

Func _MoveMixer()
    $cursor1 = _WinAPI_GetCursorInfo()
    $X = $cursor1[3]
    $Y = $cursor1[4]
    While _IsPressed("01", $UserDll)
        $npos = WinGetPos($MixerGuiHnd)
        $cursor2 = _WinAPI_GetCursorInfo()
        $Y2 = $cursor2[4] -  220
        If $Y2 < $MY   Then $Y2 = $MY
        If $Y2 > $MY + 140 Then $Y2 = $MY + 140
        _WinAPI_SetWindowPos($MixerGuiHnd, $PlayerGUIHnd, $MX, $Y2, $MW, $MH, $SWP_NOACTIVATE)
    Wend
EndFunc

Func _CatchWindowEvents()
    While _IsPressed("01", $UserDll)
        $g1pos = WinGetPos($PlayerGUIHnd)
        $g2pos = WinGetPos($MixerGuiHnd)
        $Y2 = $g1pos[1] + $g2pos[1]
        WinMove($MixerGuiHnd,"",$g1pos[0], $Y2)
    Wend
EndFunc

Func _GetCursorPosition($Hnd)
    $CurPos = GUIGetCursorInfo($Hnd)
    ;Rollover Close Button
    If $CurPos[0] > $CloseL and $CurPos[0] < $CloseL + $CloseW and $CurPos[1] > $CloseT and $CurPos[1] < $CloseT + $CloseH Then
        SetBitmap($CloseButtonGUI, $CloseButtonOverImage, 255)
    Else
        SetBitmap($CloseButtonGUI, $CloseButtonGUIImage, 255)
    EndIf
    ;Rollover Minimize Button
    If $CurPos[0] > $MinimizeL and $CurPos[0] < $MinimizeL + $MinimizeW and $CurPos[1] > $MinimizeT and $CurPos[1] < $MinimizeT + $MinimizeH Then
        SetBitmap($MinimizeButtonGUI, $MinimizeButtonOverImage, 255)
    Else
        SetBitmap($MinimizeButtonGUI, $MinimizeButtonGUIImage, 255)
    EndIf
    ;Rollover Playlist Button
    If $CurPos[0] > $PlaylistL and $CurPos[0] < $PlaylistL + $PlaylistW and $CurPos[1] > $PlaylistT and $CurPos[1] < $PlaylistT + $PlaylistH Then
        SetBitmap($PlaylistButtonGUI, $PlaylistButtonOverImage, 255)
    Else
        SetBitmap($PlaylistButtonGUI, $PlaylistButtonGUIImage, 255)
    EndIf
    ;Rollover Options Button
    If $CurPos[0] > $OptionsL and $CurPos[0] < $OptionsL + $OptionsW and $CurPos[1] > $OptionsT and $CurPos[1] < $OptionsT + $OptionsH Then
        SetBitmap($OptionsButtonGUI, $OptionsButtonOverImage, 255)
    Else
        SetBitmap($OptionsButtonGUI, $OptionsButtonGUIImage, 255)
    EndIf
    ;Rollover Play Button
    If $CurPos[0] > $PlayL and $CurPos[0] < $PlayL + $PlayW and $CurPos[1] > $PlayT and $CurPos[1] < $PlayT + $PlayH Then
        SetBitmap($PlayButtonGUI, $PlayButtonOverImage, 255)
    Else
        SetBitmap($PlayButtonGUI, $PlayButtonGUIImage, 255)
    EndIf
    ;Rollover Stop Button
    If $CurPos[0] > $StopL and $CurPos[0] < $StopL + $StopW and $CurPos[1] > $StopT and $CurPos[1] < $StopT + $StopH Then
        SetBitmap($StopButtonGUI, $StopButtonOverImage, 255)
    Else
        SetBitmap($StopButtonGUI, $StopButtonGUIImage, 255)
    EndIf
    ;Rollover Pause Button
    If $CurPos[0] > $PauseL and $CurPos[0] < $PauseL + $PauseW and $CurPos[1] > $PauseT and $CurPos[1] < $PauseT + $PauseH Then
        SetBitmap($PauseButtonGUI, $PauseButtonOverImage, 255)
    Else
        SetBitmap($PauseButtonGUI, $PauseButtonGUIImage, 255)
    EndIf
    ;Rollover Prev Button
    If $CurPos[0] > $PrevL and $CurPos[0] < $PrevL + $PrevW and $CurPos[1] > $PrevT and $CurPos[1] < $PrevT + $PrevH Then
        SetBitmap($PrevButtonGUI, $PrevButtonOverImage, 255)
    Else
        SetBitmap($PrevButtonGUI, $PrevButtonGUIImage, 255)
    EndIf
    ;Rollover Next Button
    If $CurPos[0] > $NextL and $CurPos[0] < $NextL + $NextW and $CurPos[1] > $NextT and $CurPos[1] < $NextT + $NextH Then
        SetBitmap($NextButtonGUI, $NextButtonOverImage, 255)
    Else
        SetBitmap($NextButtonGUI, $NextButtonGUIImage, 255)
    EndIf
EndFunc

Func _CloseProgram()
    GUIDelete($ScrollingTextHnd)
    GUIDelete($PlayerGUIHnd)
    GUIDelete($CloseButtonHnd)
    GUIDelete($MinimizeButtonHnd)
    GUIDelete($PlaylistButtonHnd)
    GUIDelete($PlayButtonHnd)
    GUIDelete($StopButtonHnd)
    GUIDelete($OptionsButtonHnd)
    GUIDelete($PauseButtonHnd)
    GUIDelete($PlaylistGuiHnd)
    GUIDelete($MixerGuiHnd)
    _GDIPlus_ImageDispose($PlayerGUIImage)
    _GDIPlus_ImageDispose($CloseButtonGuiImage)
    _GDIPlus_ImageDispose($OptionsButtonGuiImage)
    _GDIPlus_ImageDispose($PlaylistButtonGuiImage)
    _GDIPlus_ImageDispose($MinimizeButtonGuiImage)
    _GDIPlus_ImageDispose($PlayButtonGuiImage)
    _GDIPlus_ImageDispose($StopButtonGuiImage)
    _GDIPlus_ImageDispose($PauseButtonGuiImage)
    _GDIPlus_ImageDispose($CloseButtonGuiImage)
    _GDIPlus_ImageDispose($NextButtonGuiImage)
    _GDIPlus_ImageDispose($PrevButtonGuiImage)
    _GDIPlus_ImageDispose($CloseButtonOverImage)
    _GDIPlus_ImageDispose($OptionsButtonOverImage)
    _GDIPlus_ImageDispose($PlaylistButtonOverImage)
    _GDIPlus_ImageDispose($MinimizeButtonOverImage)
    _GDIPlus_ImageDispose($PlayButtonOverImage)
    _GDIPlus_ImageDispose($StopButtonOverImage)
    _GDIPlus_ImageDispose($PauseButtonOverImage)
    _GDIPlus_ImageDispose($NextButtonOverImage)
    _GDIPlus_ImageDispose($PrevButtonOverImage)
    _GDIPlus_Shutdown()
    Exit
EndFunc

Func _Play()
EndFunc
Func _StopPlayback()
EndFunc
Func _PausePlayback()
EndFunc
Func _PrevPlayback()
EndFunc
Func _NextPlayback()
EndFunc
Func _PLayList()
EndFunc
Func _Options()
EndFunc
Func _Minimize()
EndFunc
Func _CloseOptionsGUI()
EndFunc

; Create Scrolling Text GUI
Func _SetScrollText($text)
$ScrollingTextGUI = GUICreate("ScrollText", $TextW, $TextH, $TextEdgeL, $TextEdgeT, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $PlayerGUIHnd)
$ScrollingTextHnd = WinGetHandle($ScrollingTextGUI)
GUICtrlCreatePic($TextBGImage, 0, 0, $TextW, $TextH)
GUICtrlSetState(-1, $GUI_DISABLE)
_GUICtrlMarquee_SetScroll(Default, Default, Default, 4,40)
_GUICtrlMarquee_SetDisplay(Default, $sTextFG, $textBG, 12, "Verdana")
_GUICtrlMarquee_Create($text, 0,  0, $TextW, $TextH)
GUISetState()
EndFunc

;==>SetBitmap
Func SetBitmap($hGUI, $hImage, $iOpacity)
    Local Const $ULW_ALPHA = 2
    Local Const $AC_SRC_ALPHA = 1
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
    $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

; Hnd the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image.
; ====================================================================================================

Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $PlayerGUIHnd) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc   ;==>WM_NCHITTEST

images.zip

Edited by a440hz

Are you experienced?

Share this post


Link to post
Share on other sites

No need to register WM_NCHITTEST more than once.

Couldn't you register WM_MOVE and then move the widows with the one being dragged?


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

#3 ·  Posted (edited)

Thanks Martin! That did the trick!

Regards,

Joe

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=playerGUI.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Constants.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>
#include <Marquee.au3>
#include <Misc.au3>
#include <StaticConstants.au3>

Opt("GUIOnEventMode", 1)
Opt("MouseCoordMode", 0)
Opt("WinTitleMatchMode", 4)
Opt('MustDeclareVars', 0)

Global Const $AC_SRC_ALPHA = 1
Global Const $SC_DRAGMOVE = 0xF012
Global $UserDll = DllOpen("user32.dll")

#Region ; GUI Variables
_GDIPlus_Startup()
;Buttons & Sliders
Global $gFile, $Hnd, $CurPos
Global $Dw = @DesktopWidth
Global $Dh = @DesktopHeight
Global $Gw, $Gh, $Gx, $Gy
Global $Ow, $Oh, $Ox, $Oy
Global $PlayerGuiPos, $PlayListGuiPos, $MixerGuiPos, $PlayListOffset, $MixerGuiOffset

$gFile = @ScriptDir & "\images\playlistgui.gif"
Global $PlayListGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
$gFile = @ScriptDir & "\images\mixergui.gif"
Global $MixerGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
$gFile = @ScriptDir & "\images\playergui.gif"
Global $PlayerGUIImage = _GDIPlus_ImageLoadFromFile($gFile)
Global $MW = _GDIPlus_ImageGetWidth($PlayerGUIImage)
Global $MH = _GDIPlus_ImageGetHeight($PlayerGUIImage)
Global $MX = ($Dw/2) - ($MW/2)
Global $MY = ($Dh/2) - ($MH/2)
Global $Ow = 440, $Oh = 350
Global $Ox = ($Dw/2) - ($Ow/2)
Global $Oy = ($Dh/2) - ($Oh/2)

; Close
$gFile = @ScriptDir & "\images\close.gif"
Global $CloseButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
Global $CloseW = _GDIPlus_ImageGetWidth($CloseButtonGuiImage)
Global $CloseH = _GDIPlus_ImageGetHeight($CloseButtonGuiImage)
Global $CloseT = 34
Global $CloseL = 379
;CloseOver
$gFile = @ScriptDir & "\images\close_over.gif"
Global $CloseButtonOverImage = _GDIPlus_ImageLoadFromFile($gFile)

;Minimize
$gFile = @ScriptDir & "\images\minimize.gif"
Global $MinimizeButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
Global $MinimizeW = _GDIPlus_ImageGetWidth($MinimizeButtonGuiImage)
Global $MinimizeH = _GDIPlus_ImageGetHeight($MinimizeButtonGuiImage)
Global $MinimizeT = 34
Global $MinimizeL = 348

;MinimizeOver
$gFile = @ScriptDir & "\images\minimize_over.gif"
Global $MinimizeButtonOverImage = _GDIPlus_ImageLoadFromFile($gFile)

;Playlist
$gFile = @ScriptDir & "\images\playlist.gif"
Global $PlaylistButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
Global $PlaylistW = _GDIPlus_ImageGetWidth($PlaylistButtonGuiImage)
Global $PlaylistH = _GDIPlus_ImageGetHeight($PlaylistButtonGuiImage)
Global $PlaylistT = 34
Global $PlaylistL = 60

;PlaylistOver
$gFile = @ScriptDir & "\images\playlist_over.gif"
Global $PlaylistButtonOverImage = _GDIPlus_ImageLoadFromFile($gFile)

;Options
$gFile = @ScriptDir & "\images\options.gif"
Global $OptionsButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
Global $OptionsW = _GDIPlus_ImageGetWidth($OptionsButtonGuiImage)
Global $OptionsH = _GDIPlus_ImageGetHeight($OptionsButtonGuiImage)
Global $OptionsT = 34
Global $OptionsL = 91

;OptionsOver
$gFile = @ScriptDir & "\images\options_over.gif"
Global $OptionsButtonOverImage = _GDIPlus_ImageLoadFromFile($gFile)

; Play
$gFile = @ScriptDir & "\images\play.gif"
Global $PlayButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
Global $PlayW = _GDIPlus_ImageGetWidth($PlayButtonGuiImage)
Global $PlayH = _GDIPlus_ImageGetHeight($PlayButtonGuiImage)
Global $PlayT = 191
Global $PlayL = 220

; PlayOver
$gFile = @ScriptDir & "\images\play_over.gif"
Global $PlayButtonOverImage = _GDIPlus_ImageLoadFromFile($gFile)

; Stop
Global $gFile = @ScriptDir & "\images\stop.gif"
Global $StopButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
Global $StopW = _GDIPlus_ImageGetWidth($StopButtonGuiImage)
Global $StopH = _GDIPlus_ImageGetHeight($StopButtonGuiImage)
Global $StopT = 191
Global $StopL = 170

; StopOver
Global $gFile = @ScriptDir & "\images\stop_over.gif"
Global $StopButtonOverImage = _GDIPlus_ImageLoadFromFile($gFile)

; Pause
$gFile = @ScriptDir & "\images\pause.gif"
Global $PauseButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
Global $PauseW = _GDIPlus_ImageGetWidth($PauseButtonGuiImage)
Global $PauseH = _GDIPlus_ImageGetHeight($PauseButtonGuiImage)
Global $PauseT = 191
Global $PauseL = 270

; PauseOver
$gFile = @ScriptDir & "\images\pause_over.gif"
Global $PauseButtonOverImage = _GDIPlus_ImageLoadFromFile($gFile)

; Prev
Global $gFile = @ScriptDir & "\images\prev.gif"
Global $PrevButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
Global $PrevW = _GDIPlus_ImageGetWidth($PrevButtonGuiImage)
Global $PrevH = _GDIPlus_ImageGetHeight($PrevButtonGuiImage)
Global $PrevT = 191
Global $PrevL = 120

; PrevOver
Global $gFile = @ScriptDir & "\images\prev_over.gif"
Global $PrevButtonOverImage = _GDIPlus_ImageLoadFromFile($gFile)

; Next
$gFile = @ScriptDir & "\images\next.gif"
Global $NextButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
Global $NextW = _GDIPlus_ImageGetWidth($NextButtonGuiImage)
Global $NextH = _GDIPlus_ImageGetHeight($NextButtonGuiImage)
Global $NextT = 191
Global $NextL = 320

; NextOver
$gFile = @ScriptDir & "\images\next_Over.gif"
Global $NextButtonOverImage = _GDIPlus_ImageLoadFromFile($gFile)
Global $t; for/next counter
Global $i, $d, $v, $c
Global $X, $Y, $X2, $Y2 ;X Y Coordinate Holders
Global $ScrollingTextGUI, $ScrollingTextHnd
Global $TextBG = 0x000000
Global $text = "Please help me move my brothers along with me when I go?"
Global $sTextFG = 0xe4d701
Global $TextBGImage = @ScriptDir & "\images\20pxtextbox.gif"
Global $TextW = 349
Global $TextH = 20
Global $TextT = 0
Global $TextL = 0
Global $TextEdgeL = 59
Global $TextEdgeT = 155


; Main GUI
Global $PlayerGUI = GUICreate("s2smain", $MW, $MH, $MX, $MY, BITOR($WS_POPUP,$WS_EX_TOPMOST),$WS_EX_LAYERED)
SetBitmap($PlayerGUI, $PlayerGUIImage, 255)
Global $PlayerGUIHnd = WinGetHandle($PlayerGUI)
GUISetIcon("as1trans.ico")
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUIRegisterMsg($WM_MOVE, "WM_MOVE")
GUISetState()

;PlaylistGui
Global $PlayListGUI = GUICreate("S2SPlaylist", $MW, $MH, $MX, $MY, $WS_POPUP,BitOR($WS_EX_TOOLWINDOW,$WS_EX_LAYERED))
SetBitmap($PlayListGUI, $PlayListGuiImage, 255)
Global $PlayListGuiHnd = WinGetHandle($PlayListGUI)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_MovePlaylist",$PlayListGuiHnd)
GUISetState()

;MixerGui
Global $MixerGUI = GUICreate("S2SMixer", $MW, $MH, $MX, $MY,$WS_POPUP,BitOR($WS_EX_TOOLWINDOW,$WS_EX_LAYERED))
SetBitmap($MixerGUI, $MixerGuiImage, 255)
Global $MixerGuiHnd = WinGetHandle($MixerGUI)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_MoveMixer",$MixerGuiHnd)
GUISetState()

; Create CloseButton
Global $CloseButtonGUI = GUICreate("CloseButton", $CloseW, $CloseH, $CloseL, $CloseT,$WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $PlayerGUIHnd)
SetBitmap($CloseButtonGUI, $CloseButtonGuiImage, 255)
Global $CloseButtonHnd = WinGetHandle($CloseButtonGUI)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_CloseProgram",$CloseButtonHnd)
GUISetState()

; Create MinimizeButtonGUI
Global $MinimizeButtonGUI = GUICreate("MinimizeButton", $MinimizeW, $MinimizeH, $MinimizeL, $MinimizeT,$WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $PlayerGUIHnd)
SetBitmap($MinimizeButtonGUI, $MinimizeButtonGuiImage, 255)
Global $MinimizeButtonHnd = WinGetHandle($MinimizeButtonGUI)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_Minimize",$MinimizeButtonHnd)
GUISetState()

; Create PlaylistButtonGUI
Global $PlaylistButtonGUI = GUICreate("PlaylistButton", $PlaylistW, $PlaylistH, $PlaylistL,$PlaylistT,$WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $PlayerGUIHnd)
SetBitmap($PlaylistButtonGUI, $PlaylistButtonGuiImage, 255)
Global $PlaylistButtonHnd = WinGetHandle($PlaylistButtonGUI)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_Playlist",$PlaylistButtonGUI)
GUISetState()

; Create OptionsButtonGUI
Global $OptionsButtonGUI = GUICreate("OptionsButton", $OptionsW, $OptionsH, $OptionsL,$OptionsT,$WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $PlayerGUIHnd)
SetBitmap($OptionsButtonGUI, $OptionsButtonGuiImage, 255)
Global $OptionsButtonHnd = WinGetHandle($OptionsButtonGUI)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_Options",$OptionsButtonHnd)
GUISetState()

; Create PlayButtonGUI
Global $PlayButtonGUI = GUICreate("PlayButton", $PlayW, $PlayH, $PlayL, $PlayT,$WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $PlayerGUIHnd)
SetBitmap($PlayButtonGUI, $PlayButtonGuiImage, 255)
Global $PlayButtonHnd = WinGetHandle($PlayButtonGUI)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_Play",$PlayButtonGUI)
GUISetState()

; Create StopButtonGUI
Global $StopButtonGUI = GUICreate("StopButton", $StopW, $StopH, $StopL, $StopT,$WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $PlayerGUIHnd)
SetBitmap($StopButtonGUI, $StopButtonGuiImage, 255)
Global $StopButtonHnd = WinGetHandle($StopButtonGUI)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_StopPlayback",$StopButtonGUI)
GUISetState()

; Create PauseButtonGUI
Global $PauseButtonGUI = GUICreate("PauseButton", $PauseW, $PauseH, $PauseL, $PauseT,$WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $PlayerGUIHnd)
SetBitmap($PauseButtonGUI, $PauseButtonGuiImage, 255)
Global $PauseButtonHnd = WinGetHandle($PauseButtonGUI)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_PausePlayback",$PauseButtonGUI)
GUISetState()

; Create PrevButtonGUI
Global $PrevButtonGUI = GUICreate("PrevButton", $PrevW, $PrevH, $PrevL, $PrevT,$WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $PlayerGUIHnd)
SetBitmap($PrevButtonGUI, $PrevButtonGuiImage, 255)
Global $PrevButtonHnd = WinGetHandle($PrevButtonGUI)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_PrevPlayback",$PrevButtonGUI)
GUISetState()

; Create NextButtonGUI
Global $NextButtonGUI = GUICreate("NextButton", $NextW, $NextH, $NextL, $NextT,$WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $PlayerGUIHnd)
SetBitmap($NextButtonGUI, $NextButtonGuiImage, 255)
Global $NextButtonHnd = WinGetHandle($NextButtonGUI)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_NextPlayback",$NextButtonGUI)
GUISetState()


_SetScrollText($text)


#Region ; Main Loop
While 1
    _GetCursorPosition($PlayerGUIHnd)
    $PlayerGuiPos = WinGetPos($PlayerGUIHnd)
    $PlayListGuiPos = WinGetPos($PlayListGuiHnd)
    $MixerGuiPos = WinGetPos($MixerGuiHnd)
    $PlayListOffset = $PlayerGuiPos[1] - $PlayListGuiPos[1]
    $MixerGuiOffset = $MixerGuiPos[1] - $PlayerGuiPos[1]
WEnd

Func _MovePlaylist()
    While _IsPressed("01", $UserDll)
        $PlayerGuiPos = WinGetPos($PlayerGUIHnd)
        $cursor = _WinAPI_GetCursorInfo()
        $Y2 = $cursor[4] - 20
        If $Y2 < $PlayerGuiPos[1] -170 Then $Y2 = $PlayerGuiPos[1] -170
        If $Y2 > $PlayerGuiPos[1] Then $Y2 = $PlayerGuiPos[1]
        _WinAPI_SetWindowPos($PlayListGuiHnd, $MixerGuiHnd, $PlayerGuiPos[0], $Y2, $MW, $MH, $SWP_NOACTIVATE)
    Wend
EndFunc

Func _MoveMixer()
    While _IsPressed("01", $UserDll)
        $PlayerGuiPos = WinGetPos($PlayerGUIHnd)
        $cursor = _WinAPI_GetCursorInfo()
        $Y2 = $cursor[4] -  220
        If $Y2 < $PlayerGuiPos[1]   Then $Y2 = $PlayerGuiPos[1]
        If $Y2 > $PlayerGuiPos[1] + 140 Then $Y2 = $PlayerGuiPos[1] + 140
        _WinAPI_SetWindowPos($MixerGuiHnd, $PlayerGUIHnd, $PlayerGuiPos[0], $Y2, $MW, $MH, $SWP_NOACTIVATE)
    Wend
EndFunc

Func _CatchWindowEvents()
    While _IsPressed("01", $UserDll)
        $g1pos = WinGetPos($PlayerGUIHnd)
        $g2pos = WinGetPos($MixerGuiHnd)
        $Y2 = $g1pos[1] + $g2pos[1]
        WinMove($MixerGuiHnd,"",$g1pos[0], $Y2)
    Wend
EndFunc

Func _GetCursorPosition($Hnd)
    $CurPos = GUIGetCursorInfo($Hnd)
    ;Rollover Close Button
    If $CurPos[0] > $CloseL and $CurPos[0] < $CloseL + $CloseW and $CurPos[1] > $CloseT and $CurPos[1] < $CloseT + $CloseH Then
        SetBitmap($CloseButtonGUI, $CloseButtonOverImage, 255)
    Else
        SetBitmap($CloseButtonGUI, $CloseButtonGUIImage, 255)
    EndIf
    ;Rollover Minimize Button
    If $CurPos[0] > $MinimizeL and $CurPos[0] < $MinimizeL + $MinimizeW and $CurPos[1] > $MinimizeT and $CurPos[1] < $MinimizeT + $MinimizeH Then
        SetBitmap($MinimizeButtonGUI, $MinimizeButtonOverImage, 255)
    Else
        SetBitmap($MinimizeButtonGUI, $MinimizeButtonGUIImage, 255)
    EndIf
    ;Rollover Playlist Button
    If $CurPos[0] > $PlaylistL and $CurPos[0] < $PlaylistL + $PlaylistW and $CurPos[1] > $PlaylistT and $CurPos[1] < $PlaylistT + $PlaylistH Then
        SetBitmap($PlaylistButtonGUI, $PlaylistButtonOverImage, 255)
    Else
        SetBitmap($PlaylistButtonGUI, $PlaylistButtonGUIImage, 255)
    EndIf
    ;Rollover Options Button
    If $CurPos[0] > $OptionsL and $CurPos[0] < $OptionsL + $OptionsW and $CurPos[1] > $OptionsT and $CurPos[1] < $OptionsT + $OptionsH Then
        SetBitmap($OptionsButtonGUI, $OptionsButtonOverImage, 255)
    Else
        SetBitmap($OptionsButtonGUI, $OptionsButtonGUIImage, 255)
    EndIf
    ;Rollover Play Button
    If $CurPos[0] > $PlayL and $CurPos[0] < $PlayL + $PlayW and $CurPos[1] > $PlayT and $CurPos[1] < $PlayT + $PlayH Then
        SetBitmap($PlayButtonGUI, $PlayButtonOverImage, 255)
    Else
        SetBitmap($PlayButtonGUI, $PlayButtonGUIImage, 255)
    EndIf
    ;Rollover Stop Button
    If $CurPos[0] > $StopL and $CurPos[0] < $StopL + $StopW and $CurPos[1] > $StopT and $CurPos[1] < $StopT + $StopH Then
        SetBitmap($StopButtonGUI, $StopButtonOverImage, 255)
    Else
        SetBitmap($StopButtonGUI, $StopButtonGUIImage, 255)
    EndIf
    ;Rollover Pause Button
    If $CurPos[0] > $PauseL and $CurPos[0] < $PauseL + $PauseW and $CurPos[1] > $PauseT and $CurPos[1] < $PauseT + $PauseH Then
        SetBitmap($PauseButtonGUI, $PauseButtonOverImage, 255)
    Else
        SetBitmap($PauseButtonGUI, $PauseButtonGUIImage, 255)
    EndIf
    ;Rollover Prev Button
    If $CurPos[0] > $PrevL and $CurPos[0] < $PrevL + $PrevW and $CurPos[1] > $PrevT and $CurPos[1] < $PrevT + $PrevH Then
        SetBitmap($PrevButtonGUI, $PrevButtonOverImage, 255)
    Else
        SetBitmap($PrevButtonGUI, $PrevButtonGUIImage, 255)
    EndIf
    ;Rollover Next Button
    If $CurPos[0] > $NextL and $CurPos[0] < $NextL + $NextW and $CurPos[1] > $NextT and $CurPos[1] < $NextT + $NextH Then
        SetBitmap($NextButtonGUI, $NextButtonOverImage, 255)
    Else
        SetBitmap($NextButtonGUI, $NextButtonGUIImage, 255)
    EndIf
EndFunc

Func _CloseProgram()
    GUIDelete($ScrollingTextHnd)
    GUIDelete($PlayerGUIHnd)
    GUIDelete($CloseButtonHnd)
    GUIDelete($MinimizeButtonHnd)
    GUIDelete($PlaylistButtonHnd)
    GUIDelete($PlayButtonHnd)
    GUIDelete($StopButtonHnd)
    GUIDelete($OptionsButtonHnd)
    GUIDelete($PauseButtonHnd)
    GUIDelete($PlaylistGuiHnd)
    GUIDelete($MixerGuiHnd)
    _GDIPlus_ImageDispose($PlayerGUIImage)
    _GDIPlus_ImageDispose($CloseButtonGuiImage)
    _GDIPlus_ImageDispose($OptionsButtonGuiImage)
    _GDIPlus_ImageDispose($PlaylistButtonGuiImage)
    _GDIPlus_ImageDispose($MinimizeButtonGuiImage)
    _GDIPlus_ImageDispose($PlayButtonGuiImage)
    _GDIPlus_ImageDispose($StopButtonGuiImage)
    _GDIPlus_ImageDispose($PauseButtonGuiImage)
    _GDIPlus_ImageDispose($CloseButtonGuiImage)
    _GDIPlus_ImageDispose($NextButtonGuiImage)
    _GDIPlus_ImageDispose($PrevButtonGuiImage)
    _GDIPlus_ImageDispose($CloseButtonOverImage)
    _GDIPlus_ImageDispose($OptionsButtonOverImage)
    _GDIPlus_ImageDispose($PlaylistButtonOverImage)
    _GDIPlus_ImageDispose($MinimizeButtonOverImage)
    _GDIPlus_ImageDispose($PlayButtonOverImage)
    _GDIPlus_ImageDispose($StopButtonOverImage)
    _GDIPlus_ImageDispose($PauseButtonOverImage)
    _GDIPlus_ImageDispose($NextButtonOverImage)
    _GDIPlus_ImageDispose($PrevButtonOverImage)
    _GDIPlus_Shutdown()
    Exit
EndFunc

Func _Play()
EndFunc
Func _StopPlayback()
EndFunc
Func _PausePlayback()
EndFunc
Func _PrevPlayback()
EndFunc
Func _NextPlayback()
EndFunc
Func _PLayList()
EndFunc
Func _Options()
EndFunc
Func _Minimize()
EndFunc
Func _CloseOptionsGUI()
EndFunc

; Create Scrolling Text GUI
Func _SetScrollText($text)
$ScrollingTextGUI = GUICreate("ScrollText", $TextW, $TextH, $TextEdgeL, $TextEdgeT, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $PlayerGUIHnd)
$ScrollingTextHnd = WinGetHandle($ScrollingTextGUI)
GUICtrlCreatePic($TextBGImage, 0, 0, $TextW, $TextH)
GUICtrlSetState(-1, $GUI_DISABLE)
_GUICtrlMarquee_SetScroll(Default, Default, Default, 4,40)
_GUICtrlMarquee_SetDisplay(Default, $sTextFG, $textBG, 12, "Verdana")
_GUICtrlMarquee_Create($text, 0,  0, $TextW, $TextH)
GUISetState()
EndFunc

;==>SetBitmap
Func SetBitmap($hGUI, $hImage, $iOpacity)
    Local Const $ULW_ALPHA = 2
    Local Const $AC_SRC_ALPHA = 1
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
    $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

; Hnd the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image.
; ====================================================================================================

Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $PlayerGUIHnd) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc   ;==>WM_NCHITTEST

Func WM_MOVE($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $PlayerGUIHnd) then
        $PlayerGuiPos = WinGetPos($PlayerGUIHnd)
        _WinAPI_SetWindowPos($MixerGuiHnd, $PlayerGUIHnd , $PlayerGuiPos[0], $PlayerGuiPos[1] + $MixerGuiOffset, $MW, $MH, $SWP_NOACTIVATE)
        _WinAPI_SetWindowPos($PlayListGuiHnd, $MixerGuiHnd, $PlayerGuiPos[0], $PlayerGuiPos[1] - $PlayListOffset, $MW, $MH, $SWP_NOACTIVATE)
    EndIf
EndFunc

images.zip

Edited by a440hz

Are you experienced?

Share this post


Link to post
Share on other sites

Thanks again Martin,

I found that my programming approach was no good when I started moving things around. It makes more sense to create a number of images that replace the Main GUI Bitmap to create highlights as you rollover the buttons. With fewer GUIs to move around things are a lot smoother.

Here's my revised code if anyone is interested. Only one problem though, GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_CatchClick") is not responsive enough to respond to the mouse clicks. I need to find abetter way to catch clicks.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=playerGUI.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Constants.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>
#include <Marquee.au3>
#include <Misc.au3>
#include <StaticConstants.au3>

Opt("GUIOnEventMode", 1)
Opt("MouseCoordMode", 0)
Opt("WinTitleMatchMode", 4)
Opt('MustDeclareVars', 0)

Global Const $AC_SRC_ALPHA = 1
Global Const $SC_DRAGMOVE = 0xF012
Global $UserDll = DllOpen("user32.dll")

_GDIPlus_Startup()
;Buttons & Sliders
Global $gFile, $handle, $CurPos
Global $Dw = @DesktopWidth
Global $Dh = @DesktopHeight
Global $Gw, $Gh, $Gx, $Gy
Global $Ow, $Oh, $Ox, $Oy
Global $MainGuiPos
Global $PlayListGuiPos
Global $MixerGuiPos
$gFile = @ScriptDir & "\images\S2SGUI.gif"
Global $PlayerGUIImage = _GDIPlus_ImageLoadFromFile($gFile)
Global $MW = _GDIPlus_ImageGetWidth($PlayerGUIImage)
Global $MH = _GDIPlus_ImageGetHeight($PlayerGUIImage)
Global $MX = ($Dw/2) - ($MW/2)
Global $MY = ($Dh/2) - ($MH/2)
Global $Ow = 440, $Oh = 350
Global $Ox = ($Dw/2) - ($Ow/2)
Global $Oy = ($Dh/2) - ($Oh/2)

Global $CloseT = 34
Global $CloseL = 379
Global $MinimizeT = 34
Global $MinimizeL = 348
Global $PlaylistT = 34
Global $PlaylistL = 60
Global $OptionsT = 34
Global $OptionsL = 91
Global $PlayT = 191
Global $PlayL = 220
Global $StopT = $PlayT
Global $StopL = 170
Global $PauseT = $PlayT
Global $PauseL = 270
Global $PrevT = $PlayT
Global $PrevL = 120
Global $NextT = $PlayT
Global $NextL = 320

Global $TopButnW = 28
Global $TopButnH = 30
Global $TransButnW = 24
Global $TransButnH = $TransButnW

$gFile = @ScriptDir & "\images\playlistgui.gif"
Global $PlayListGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
$gFile = @ScriptDir & "\images\mixergui.gif"
Global $MixerGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
; Sys Buttons
; Close
$gFile = @ScriptDir & "\images\close.gif"
Global $CloseButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
;Minimize
$gFile = @ScriptDir & "\images\minimize.gif"
Global $MinimizeButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
;Playlist
$gFile = @ScriptDir & "\images\playlist.gif"
Global $PlaylistButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
;Options
$gFile = @ScriptDir & "\images\options.gif"
Global $OptionsButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
;Transport Buttons
; Play
$gFile = @ScriptDir & "\images\play.gif"
Global $PlayButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
; Stop
Global $gFile = @ScriptDir & "\images\stop.gif"
Global $StopButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
; Pause
$gFile = @ScriptDir & "\images\pause.gif"
Global $PauseButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
; Prev
Global $gFile = @ScriptDir & "\images\prev.gif"
Global $PrevButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)
; Next
$gFile = @ScriptDir & "\images\next.gif"
Global $NextButtonGuiImage = _GDIPlus_ImageLoadFromFile($gFile)


Global $t; for/next counter
Global $i, $d, $v, $c
Global $X, $Y, $X2, $Y2 ;X Y Coordinate Holders
Global $ScrollingTextGUI, $ScrollingTextHnd
Global $TextBG = 0x000000
Global $text = "We all stay together wherever we go!!"
Global $sTextFG = 0xe4d701
Global $TextBGImage = @ScriptDir & "\images\20pxtextbox.gif"
Global $TextW = 349
Global $TextH = 20
Global $TextT = 0
Global $TextL = 0
Global $TextEdgeL = 59
Global $TextEdgeT = 155


; Main GUI
Global $PlayerGUI = GUICreate("s2smain", $MW, $MH, $MX, $MY, BITOR($WS_POPUP,$WS_EX_TOPMOST),$WS_EX_LAYERED)
SetBitmap($PlayerGUI, $PlayerGUIImage, 255)
Global $PlayerGUIHnd = WinGetHandle($PlayerGUI)
GUISetIcon("as1trans.ico")
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_CatchClick")
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUIRegisterMsg($WM_MOVE, "WM_MOVE")
GUISetState()

;PlaylistGui
Global $PlayListGUI = GUICreate("S2SPlaylist", $MW, $MH, $MX, $MY, $WS_POPUP,BitOR($WS_EX_TOOLWINDOW,$WS_EX_LAYERED))
SetBitmap($PlayListGUI, $PlayListGuiImage, 255)
Global $PlayListGuiHnd = WinGetHandle($PlayListGUI)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_MovePlaylist",$PlayListGuiHnd)
GUISetState()

;MixerGui
Global $MixerGUI = GUICreate("S2SMixer", $MW, $MH, $MX, $MY,$WS_POPUP,BitOR($WS_EX_TOOLWINDOW,$WS_EX_LAYERED))
SetBitmap($MixerGUI, $MixerGuiImage, 255)
Global $MixerGuiHnd = WinGetHandle($MixerGUI)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_MoveMixer",$MixerGuiHnd)
GUISetState()


_SetScrollText($text)


#Region ; Main Loop
While 1
    _GetCursorPosition($PlayerGUIHnd)
    $PlayerGuiPos = WinGetPos($PlayerGUIHnd)
    $PlayListGuiPos = WinGetPos($PlayListGuiHnd)
    $MixerGuiPos = WinGetPos($MixerGuiHnd)
    $PlayListOffset = $PlayerGuiPos[1] - $PlayListGuiPos[1]
    $MixerGuiOffset = $MixerGuiPos[1] - $PlayerGuiPos[1]
WEnd

Func _MovePlaylist()
    While _IsPressed("01", $UserDll)
        $PlayerGuiPos = WinGetPos($PlayerGUIHnd)
        $cursor = _WinAPI_GetCursorInfo()
        $Y2 = $cursor[4] - 20
        If $Y2 < $PlayerGuiPos[1] -170 Then $Y2 = $PlayerGuiPos[1] -170
        If $Y2 > $PlayerGuiPos[1] Then $Y2 = $PlayerGuiPos[1]
        _WinAPI_SetWindowPos($PlayListGuiHnd, $MixerGuiHnd, $PlayerGuiPos[0], $Y2, $MW, $MH, $SWP_NOACTIVATE)
    Wend
EndFunc

Func _MoveMixer()
    While _IsPressed("01", $UserDll)
        $PlayerGuiPos = WinGetPos($PlayerGUIHnd)
        $cursor = _WinAPI_GetCursorInfo()
        $Y2 = $cursor[4] -  220
        If $Y2 < $PlayerGuiPos[1]   Then $Y2 = $PlayerGuiPos[1]
        If $Y2 > $PlayerGuiPos[1] + 140 Then $Y2 = $PlayerGuiPos[1] + 140
        _WinAPI_SetWindowPos($MixerGuiHnd, $PlayerGUIHnd, $PlayerGuiPos[0], $Y2, $MW, $MH, $SWP_NOACTIVATE)
    Wend
EndFunc

Func _CatchClick()
    If $CurPos[0] > $CloseL and $CurPos[0] < $CloseL + $TopButnW and $CurPos[1] > $CloseT and $CurPos[1] < $CloseT + $TopButnH Then
        _Close()
    ElseIf $CurPos[0] > $MinimizeL and $CurPos[0] < $MinimizeL + $TopButnW and $CurPos[1] > $MinimizeT and $CurPos[1] < $MinimizeT + $TopButnH Then
        _Minimize()
    ElseIf $CurPos[0] > $PlaylistL and $CurPos[0] < $PlaylistL + $TopButnW and $CurPos[1] > $PlaylistT and $CurPos[1] < $PlaylistT + $TopButnH Then
        _PlayList()
    ElseIf $CurPos[0] > $OptionsL and $CurPos[0] < $OptionsL + $TopButnW and $CurPos[1] > $OptionsT and $CurPos[1] < $OptionsT + $TopButnH Then
        _Options()
    ElseIf $CurPos[0] > $PlayL and $CurPos[0] < $PlayL + $TransButnW and $CurPos[1] > $PlayT and $CurPos[1] < $PlayT + $TransButnH Then
        _Play()
    ElseIf $CurPos[0] > $StopL and $CurPos[0] < $StopL + $TransButnW and $CurPos[1] > $StopT and $CurPos[1] < $StopT + $TransButnH Then
        _Stop()
    ElseIf $CurPos[0] > $PauseL and $CurPos[0] < $PauseL + $TransButnW and $CurPos[1] > $PauseT and $CurPos[1] < $PauseT + $TransButnH Then
        _Pause()
    ElseIf $CurPos[0] > $PrevL and $CurPos[0] < $PrevL + $TransButnW and $CurPos[1] > $PrevT and $CurPos[1] < $PrevT + $TransButnH Then
        _Prev()
    ElseIf $CurPos[0] > $NextL and $CurPos[0] < $NextL + $TransButnW and $CurPos[1] > $NextT and $CurPos[1] < $NextT + $TransButnH Then
        _Next()
    EndIf
EndFunc

Func _GetCursorPosition($handle)
    $CurPos = GUIGetCursorInfo($handle)

    ;Rollover Close Button
    If $CurPos[0] > $CloseL and $CurPos[0] < $CloseL + $TopButnW and $CurPos[1] > $CloseT and $CurPos[1] < $CloseT + $TopButnH Then
        SetBitmap($PlayerGUIHnd, $CloseButtonGUIImage, 255)
    ElseIf $CurPos[0] > $MinimizeL and $CurPos[0] < $MinimizeL + $TopButnW and $CurPos[1] > $MinimizeT and $CurPos[1] < $MinimizeT + $TopButnH Then
        SetBitmap($PlayerGUIHnd, $MinimizeButtonGUIImage, 255)
    ElseIf $CurPos[0] > $PlaylistL and $CurPos[0] < $PlaylistL + $TopButnW and $CurPos[1] > $PlaylistT and $CurPos[1] < $PlaylistT + $TopButnH Then
        SetBitmap($PlayerGUIHnd, $PlaylistButtonGUIImage, 255)
    ElseIf $CurPos[0] > $OptionsL and $CurPos[0] < $OptionsL + $TopButnW and $CurPos[1] > $OptionsT and $CurPos[1] < $OptionsT + $TopButnH Then
        SetBitmap($PlayerGUIHnd, $OptionsButtonGUIImage, 255)
    ElseIf $CurPos[0] > $PlayL and $CurPos[0] < $PlayL + $TransButnW and $CurPos[1] > $PlayT and $CurPos[1] < $PlayT + $TransButnH Then
        SetBitmap($PlayerGUIHnd, $PlayButtonGUIImage, 255)
    ElseIf $CurPos[0] > $StopL and $CurPos[0] < $StopL + $TransButnW and $CurPos[1] > $StopT and $CurPos[1] < $StopT + $TransButnH Then
        SetBitmap($PlayerGUIHnd, $StopButtonGUIImage, 255)
    ElseIf $CurPos[0] > $PauseL and $CurPos[0] < $PauseL + $TransButnW and $CurPos[1] > $PauseT and $CurPos[1] < $PauseT + $TransButnH Then
        SetBitmap($PlayerGUIHnd, $PauseButtonGUIImage, 255)
    ElseIf $CurPos[0] > $PrevL and $CurPos[0] < $PrevL + $TransButnW and $CurPos[1] > $PrevT and $CurPos[1] < $PrevT + $TransButnH Then
        SetBitmap($PlayerGUIHnd, $PrevButtonGUIImage, 255)
    ElseIf $CurPos[0] > $NextL and $CurPos[0] < $NextL + $TransButnW and $CurPos[1] > $NextT and $CurPos[1] < $NextT + $TransButnH Then
        SetBitmap($PlayerGUIHnd, $NextButtonGUIImage, 255)
    Else
        SetBitmap($PlayerGUIHnd, $PlayerGUIImage, 255)
    EndIf

EndFunc

Func _Close()
    GUIDelete($ScrollingTextHnd)
    GUIDelete($PlayerGUIHnd)
    GUIDelete($PlaylistGuiHnd)
    GUIDelete($MixerGuiHnd)
    _GDIPlus_ImageDispose($PlayerGUIImage)
    _GDIPlus_ImageDispose($CloseButtonGuiImage)
    _GDIPlus_ImageDispose($OptionsButtonGuiImage)
    _GDIPlus_ImageDispose($PlaylistButtonGuiImage)
    _GDIPlus_ImageDispose($MinimizeButtonGuiImage)
    _GDIPlus_ImageDispose($PlayButtonGuiImage)
    _GDIPlus_ImageDispose($StopButtonGuiImage)
    _GDIPlus_ImageDispose($PauseButtonGuiImage)
    _GDIPlus_ImageDispose($CloseButtonGuiImage)
    _GDIPlus_ImageDispose($NextButtonGuiImage)
    _GDIPlus_ImageDispose($PrevButtonGuiImage)

    _GDIPlus_Shutdown()
    Exit
EndFunc
Func _Play()
EndFunc
Func _Stop()
EndFunc
Func _Pause()
EndFunc
Func _Prev()
EndFunc
Func _Next()
EndFunc
Func _PLayList()
EndFunc
Func _Options()
EndFunc
Func _Minimize()
EndFunc
Func _CloseOptionsGUI()
EndFunc

; Create Scrolling Text GUI
Func _SetScrollText($text)
$ScrollingTextGUI = GUICreate("ScrollText", $TextW, $TextH, $TextEdgeL, $TextEdgeT, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $PlayerGUIHnd)
$ScrollingTextHnd = WinGetHandle($ScrollingTextGUI)
GUICtrlCreatePic($TextBGImage, 0, 0, $TextW, $TextH)
GUICtrlSetState(-1, $GUI_DISABLE)
_GUICtrlMarquee_SetScroll(Default, Default, Default, 4,40)
_GUICtrlMarquee_SetDisplay(Default, $sTextFG, $textBG, 12, "Verdana")
_GUICtrlMarquee_Create($text, 0,  0, $TextW, $TextH)
GUISetState()
EndFunc

;==>SetBitmap
Func SetBitmap($hGUI, $hImage, $iOpacity)
    Local Const $ULW_ALPHA = 2
    Local Const $AC_SRC_ALPHA = 1
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
    $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

; Hnd the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image.
; ====================================================================================================

Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $PlayerGUIHnd) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc   ;==>WM_NCHITTEST

Func WM_MOVE($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $PlayerGUIHnd) then
        $PlayerGuiPos = WinGetPos($PlayerGUIHnd)
        _WinAPI_SetWindowPos($MixerGuiHnd, $PlayerGUIHnd , $PlayerGuiPos[0], $PlayerGuiPos[1] + $MixerGuiOffset, $MW, $MH, $SWP_NOACTIVATE)
        _WinAPI_SetWindowPos($PlayListGuiHnd, $MixerGuiHnd, $PlayerGuiPos[0], $PlayerGuiPos[1] - $PlayListOffset, $MW, $MH, $SWP_NOACTIVATE)
    EndIf
EndFunc

images.zip


Are you experienced?

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