Jump to content

Using AdlibEnable in a specific Tab...


Recommended Posts

Hi! I'm trying to display the amount of free RAM im my GUI using Adlibenable, with a 3 seconds update.

The problem is that i use several TABs and the value must be shown only in first TAB.

If i click the second TAB, the value still appears. :|

Here's my code:

CODE
#include <GUIConstants.au3>

$Gui=GUICreate("GUI",514, 325)

$tab=GUICtrlCreateTab (0,0, 518,310)

$tab0=GUICtrlCreateTabitem ("Diagnostic")

$mem = MemGetStats()

$memT=round($mem[1]/1024+1,0)

$memF=round($mem[2]/1024+1,0)

$memP=round($memF/$memT,2)*100

GUICtrlCreateLabel("Total:", 360, 107, 30, 14,$SS_LEFT)

GUICtrlSetColor(-1,0x0000FF)

GUICtrlCreateLabel("Free:", 360, 126, 30, 14,$SS_LEFT)

GUICtrlSetColor(-1,0x0000FF)

GUICtrlCreateLabel($memT & " MB", 390, 107, 50, 14,$SS_LEFT)

GUICtrlCreateLabel($memF & " MB " & "(" & $memP & "%)", 390, 126, 90, 14,$SS_LEFT)

Adlibenable ("MEM",3000)

$tab1=GUICtrlCreateTabitem ("Test")

GUISetState ()

Do

$msg = GUIGetMsg()

Select

Case $msg= $GUI_EVENT_CLOSE

Exit

EndSelect

Until $msg = $GUI_EVENT_CLOSE

Func MEM()

$mem = MemGetStats()

$memT=round($mem[1]/1024+1,0)

$memF=round($mem[2]/1024+1,0)

$memP=round($memF/$memT,2)*100

GUICtrlCreateLabel($memF & " MB " & "(" & $memP & "%)", 390, 126, 90, 14,$SS_LEFT)

EndFunc

Thanks for your help!

Edited by SoulBlade
Link to comment
Share on other sites

Use GUICtrlSetData() Instead of GUICtrlCreateLabel() in your update function. Otherwise you will just create a new label in the last used tab.

Here is a working version of your code with a bit of clean up.

#include <GUIConstants.au3>

$Gui=GUICreate("GUI",514, 325)
$tab=GUICtrlCreateTab (0,0, 518,310)
$tab0=GUICtrlCreateTabitem ("Diagnostic")

$mem = MemGetStats()
$memT=round($mem[1]/1024+1,0)
$memF=round($mem[2]/1024+1,0)
$memP=round($memF/$memT,2)*100

GUICtrlCreateLabel("Total:", 360, 107, 30, 14,$SS_LEFT)
GUICtrlSetColor(-1,0x0000FF)
GUICtrlCreateLabel("Free:", 360, 126, 30, 14,$SS_LEFT)
GUICtrlSetColor(-1,0x0000FF)
GUICtrlCreateLabel($memT & " MB", 390, 107, 50, 14,$SS_LEFT)
$id = GUICtrlCreateLabel($memF & " MB " & "(" & $memP & "%)", 390, 126, 90, 14,$SS_LEFT)

Adlibenable ("MEM",3000)
$tab1=GUICtrlCreateTabitem ("Test")


GUISetState ()

Do
$msg = GUIGetMsg()


Until $msg = $GUI_EVENT_CLOSE

Func MEM()
$mem = MemGetStats()
$memT=round($mem[1]/1024+1,0)
$memF=round($mem[2]/1024+1,0)
$memP=round($memF/$memT,2)*100
GUICtrlSetData($id,$memF & " MB " & "(" & $memP & "%)")
EndFunc
Edited by monoceres

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Use GUICtrlSetData() Instead of GUICtrlCreateLabel() in your update function. Otherwise you will just create a new label in the last used tab.

Here is a working version of your code with a bit of clean up.

You're right!

It's much cleaner and efective now!

I need to fully clean my code now...

Thank you very much for your help!

:)

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...