Jump to content

Recommended Posts

Posted

Hi,

I have the following code

$_StartTimeGlobal = GUICtrlCreateLabel("Start time : 00:00:00", 10, 470)

...

GUICtrlSetData($_StartTimeGlobal,StringFormat ( "Start time : %2d:%2d:%2d", @HOUR, @MIN, @SEC))

The problem I am having is the display is not correct, when I try to update the $_StartTimeGlobal it display the string over the previous one instead of replacing it.

Any idea?

Thanks.

Posted (edited)

Before you enter the new time, reset the value back to nothing, like below

$_StartTimeGlobal = GUICtrlCreateLabel("Start time : 00:00:00", 10, 470)

...
GUICtrlSetData($_StartTimeGlobal, ""); Sets the value to nothing
GUICtrlSetData($_StartTimeGlobal,StringFormat ( "Start time : %2d:%2d:%2d", @HOUR, @MIN, @SEC)

BTW, the line

GUICtrlSetData($_StartTimeGlobal,StringFormat ( "Start time : %2d:%2d:%2d", @HOUR, @MIN, @SEC)
is missing a ")" (Bracket) at the end. Edited by burrup

qq

Posted

Ok Thanks, will try that, btw there is 2 bracket at the end :)

Before you enter the new time, reset the value back to nothing, like below

$_StartTimeGlobal = GUICtrlCreateLabel("Start time : 00:00:00", 10, 470)

...
GUICtrlSetData($_StartTimeGlobal, ""); Sets the value to nothing
GUICtrlSetData($_StartTimeGlobal,StringFormat ( "Start time : %2d:%2d:%2d", @HOUR, @MIN, @SEC)

BTW, the line

GUICtrlSetData($_StartTimeGlobal,StringFormat ( "Start time : %2d:%2d:%2d", @HOUR, @MIN, @SEC)
is missing a ")" (Bracket) at the end.

<{POST_SNAPBACK}>

Posted (edited)

Hi,

It still does not work and I dont know if its because my program is not active, it is set as StayOnTop but when I update the label the program does not have focus.

Is there a way to refresh the window?

Thanks.

Edited by slam666
Posted (edited)

Here's a working version.

Edit:

- Removed: reset label to nothing

- Added: leading zero for 1 digit seconds and minutes.

#include <GUIConstants.au3>
AutoItSetOption("TrayIconDebug", 1)

;Initialize variables
Global $style1
Global $IniFile
Global $GUIWidth
Global $GUIHeight

$GUIWidth = 250
$GUIHeight = 250
$IniFile = StringTrimRight(@ScriptFullPath, 3) & "ini"

$OldSec = @SEC

GUICreate("New GUI", $GUIWidth, $GUIHeight)

$_StartTimeGlobal = GUICtrlCreateLabel("Start time : 00:00:00", 10, 40)

GUISetState(@SW_SHOW)

While 1
   Sleep(25)
   $msg = GUIGetMsg()
   Select
   
      Case $msg = $GUI_EVENT_CLOSE
         GUIDelete()
         Exit

      Case $OldSec <> @SEC
         GUICtrlSetData($_StartTimeGlobal,StringFormat ( "Start time : %2d:%02d:%02d", @HOUR, @MIN, @SEC))
         $OldSec = @SEC

   EndSelect

WEnd
Edited by SlimShady

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
  • Recently Browsing   0 members

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