Jump to content

drag and drop


zxcvbnm
 Share

Recommended Posts

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=timer.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
; == GUI generated with Koda ==
$Form1 = GUICreate("Count Down", 250, 70, 125, 125, BitOR($WS_DLGFRAME, $WS_POPUP),$WS_EX_TOPMOST)
$Label = GUICtrlCreateLabel("", 24,02,200,70,-1,$GUI_WS_EX_PARENTDRAG)
GUICtrlSetFont(-1, 40, 800, 0, "verdana")
GUISetState(@SW_SHOW)
GUISetBkColor(0x66FF00)
AutoItSetOption ( "TrayIconHide" ,1 )
Do
$e = 4
While $e >= 0
$i = 59

    While $i > 0
    $i -=1
     If $e == 2 and $i = 30 Then
         GUISetBkColor(0xFFFF00)
     EndIf
     If $e == 0 and $i = 30 Then
         GUISetBkColor(0xFF0000)
     EndIf
    GUICtrlSetData($Label, StringFormat("%02d:%02d", $e, $i))

    Sleep(50)
    WEnd
    $e -=1

WEnd
For $e = -1 to -59 step -1
    For $i = 0 to 59 step 1
    GUICtrlSetData($Label, StringFormat("%03d:%02d", $e, $i))
    GuiCtrlSetColor($Label, 0xFF0000)
    Sleep(25)
    GuiCtrlSetColor($Label, 0x000000)
    Sleep(25)
    Next
Next
while 1
    GuiCtrlSetColor($Label, 0xFF0000)
    Sleep(25)
    GuiCtrlSetColor($Label, 0x000000)
    Sleep(25)
WEnd

Until GUIGetMsg() = $GUI_EVENT_CLOSE

I'm using $GUI_WS_EX_PARENTDRAG to make pop up draggable, but pressing left button mouse on the pup up is stopping.

Is there other way?

Link to comment
Share on other sites

I just see a green then red countdown, and i can drag it....

I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it.

Link to comment
Share on other sites

  • Moderators

zxcvbnm,

Take a look at the Moving and Resizing PopUp GUIs tutorial in the Wiki. It shows another 3 ways to drag a pop-up GUI. :shifty:

But I am not sure if any of them will keep the timer going - most other things stop when you get into the complexities of Windows messaging. I seem to remember that you need to use a special timer - I will look around and see what I can find. :x

M23

Edit: I was right, you need to use Timers.au3 like this if you want the timer to continue to run: :P

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <Timers.au3>

Global $iMin = 0, $iSec = 32, $iFlash = 0

$Form1 = GUICreate("Count Down", 250, 70, 125, 125, BitOR($WS_DLGFRAME, $WS_POPUP), $WS_EX_TOPMOST)
GUISetBkColor(0x66FF00)

$Label = GUICtrlCreateLabel(StringFormat("%02d:%02d", $iMin, $iSec), 24, 02, 200, 70, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetFont(-1, 40, 800, 0, "verdana")

GUISetState(@SW_SHOW)

;AutoItSetOption ( "TrayIconHide" ,1 )

; Start a timer for the countdown
_Timer_SetTimer($Form1, 1000, "_CountDown") ; Call once a sec

Do
    Sleep(10)
Until $iMin = -1

_Timer_KillAllTimers($Form1)
Exit

Func _CountDown($a, $b, $c, $d) ; You must have 4 parameters here, even though they do nothing!

    ; We call it once a sec, so just reduce by 1 sec each time
    $iSec -= 1
    If $iSec < 0 Then
        $iSec = 59
        $iMin -= 1
        If $iMin = -1 Then Return ; We have reached zero
    EndIf

    If $iMin = 2 And $iSec = 30 Then GUISetBkColor(0xFFFF00)
    If $iMin = 0 And $iSec = 30 Then
        GUISetBkColor(0xFF0000)
        _Timer_SetTimer($Form1, 100, "_Flash") ; Start a second timer to flash
    EndIf
    
    GUICtrlSetData($Label, StringFormat("%02d:%02d", $iMin, $iSec))

EndFunc

Func _Flash($a, $b, $c, $d) ; You must have 4 parameters here, even though they do nothing!

    $iFlash = Not $iFlash
    If $iFlash Then
        GUICtrlSetColor($Label, 0xFF0000)
        Return
    EndIf
    GUICtrlSetColor($Label, 0x000000)

EndFunc
Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...