Jump to content

StatusBar + listview


dannydy
 Share

Recommended Posts

Hi guys,

need some helps here. This is my coding, i created a listview which let users select from the list. Once they click on the list item i would like the list item to be displayed in the status bar.

_GUICtrlStatusBar_SetText($hStatusBar,guictrlread(GUICtrlRead($listview))) i coded in under the Do loop, but it keeps flickering.

#include <WindowsConstants.au3>

#include <GUIConstantsEx.au3>

#include <Timers.au3>

#include <GuiStatusBar.au3>

#include <ProgressConstants.au3>

Global $hStatusBar

Local $hGUI, $iTimerProgress

Local $aParts[3] = [100,25,-1]

dim $Selection,$statuselect

Example()

Func Example()

Local $listview, $button,$Cancel, $item1, $item2, $item3,$item4, $msg

$hGUI = GUICreate("Test Summary Generation", 300, 250, 600, 500, -1, $WS_EX_ACCEPTFILES)

GUISetBkColor(0x00E0FFFF) ; will change background color

$listview = GUICtrlCreateListView("Test Summary Update ", 50,10, 200, 150);,$LVS_SORTDESCENDING)

$button = GUICtrlCreateButton("OK", 75, 170, 70, 20)

$Cancel = GUICtrlCreateButton("Cancel", 150, 170, 70, 20)

$item1 = GUICtrlCreateListViewItem("item1", $listview)

$item2 = GUICtrlCreateListViewItem("item2", $listview)

$hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aParts)

_GUICtrlStatusBar_SetText($hStatusBar,@TAB & @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2)

_GUICtrlStatusBar_SetText($hStatusBar,"No Selection")

_Timer_SetTimer($hGUI, 1000, "_UpdateStatusBarClock")

GUICtrlSetData($item1, "Exchange Online")

GUICtrlSetData($item2, "OCS Wave 14")

GUISetState()

Do

_GUICtrlStatusBar_SetText($hStatusBar,guictrlread(GUICtrlRead($listview)))

$msg = GUIGetMsg()

Select

Case $msg = $button

;MsgBox(0, "Selection Made", GUICtrlRead(GUICtrlRead($listview)))

$Selection= guictrlread($listview)

if $selection = 6 or $selection=7 Then

local $answer=MsgBox(1, "Selection Made", GUICtrlRead(GUICtrlRead($listview))& @LF & "Note* You can Press {ECS} key to terminate program when generating the summary*")

if $answer = 1 Then

ExitLoop

EndIf

if $answer = 2 Then

$rreturn = 00123

endif

EndIf

if $selection = 0 Then

msgbox (16,"Please Select","No Selection")

Elseif $rreturn = 00123 then

else

ExitLoop

endif

Case $msg = $listview

MsgBox(0, "listview", "clicked=" & GUICtrlGetState($listview), 2)

Case $msg = $GUI_EVENT_CLOSE Or $msg = $Cancel

;ExitLoop

_Exit()

EndSelect

Until $msg = $GUI_EVENT_CLOSE

EndFunc ;==>Example

Func _UpdateStatusBarClock($hWnd, $Msg, $iIDTimer, $dwTime)

#forceref $hWnd, $Msg, $iIDTimer, $dwTime

_GUICtrlStatusBar_SetText($hStatusBar, @TAB & @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2)

EndFunc ;==>_UpdateStatusBarClock

Link to comment
Share on other sites

Hello dannydy,

you can use the [autoit] and [ /autoit] tags to have a better view of your code in the forum.

To your question, I'd ceck whether the value has changed before I'd update the statusbar on every turn.

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Link to comment
Share on other sites

That is because you are updating the control too often.

Here fixed code:

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <Timers.au3>
#include <GuiStatusBar.au3>
#include <ProgressConstants.au3>
#include <GuiListView.au3>
Global $hStatusBar, $LWSelectedICurrent = -1
Local $hGUI, $iTimerProgress
Local $aParts[3] = [100,25,-1]
dim $Selection,$statuselect
Example()
Func Example()
Local $listview, $button,$Cancel, $item1, $item2, $item3,$item4, $msg
$hGUI = GUICreate("Test Summary Generation", 300, 250, 600, 500, -1, $WS_EX_ACCEPTFILES)
GUISetBkColor(0x00E0FFFF) ; will change background color
$listview = GUICtrlCreateListView("Test Summary Update  ", 50,10, 200, 150);,$LVS_SORTDESCENDING)
$button = GUICtrlCreateButton("OK", 75, 170, 70, 20)
$Cancel = GUICtrlCreateButton("Cancel", 150, 170, 70, 20)
$item1 = GUICtrlCreateListViewItem("item1", $listview)
$item2 = GUICtrlCreateListViewItem("item2", $listview)
$hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aParts)
_GUICtrlStatusBar_SetText($hStatusBar,@TAB & @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2)
_GUICtrlStatusBar_SetText($hStatusBar,"No Selection")
_Timer_SetTimer($hGUI, 1000, "_UpdateStatusBarClock")
GUICtrlSetData($item1, "Exchange Online")
GUICtrlSetData($item2, "OCS Wave 14")
GUISetState()
Do
   $LWSelectedI = _GUICtrlListView_GetSelectedIndices($listview, True)
   If $LWSelectedI[0] <> 0 Then
   If $LWSelectedI[1] <> $LWSelectedICurrent Then
   _GUICtrlStatusBar_SetText($hStatusBar,_GUICtrlListView_GetItemTextString($listview ,$LWSelectedI[1]))
   $LWSelectedICurrent = $LWSelectedI[1]
   EndIf
   EndIf
$msg = GUIGetMsg()
Select
Case $msg = $button
;MsgBox(0, "Selection Made", GUICtrlRead(GUICtrlRead($listview)))
$Selection= guictrlread($listview)
if $selection = 6 or $selection=7 Then
local $answer=MsgBox(1, "Selection Made", _GUICtrlListView_GetItemTextString($listview ,$LWSelectedICurrent) & @LF & "Note* You can Press {ECS} key to terminate program when generating the summary*")
if $answer = 1 Then
ExitLoop
EndIf
if $answer = 2 Then
$rreturn = 00123
endif
EndIf
if $selection = 0 Then
msgbox (16,"Please Select","No Selection")
Elseif $rreturn = 00123 then
else
ExitLoop
endif
Case $msg = $listview
MsgBox(0, "listview", "clicked=" & GUICtrlGetState($listview), 2)
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Cancel
;ExitLoop
_Exit()
EndSelect
Until $msg = $GUI_EVENT_CLOSE
EndFunc ;==>Example
Func _UpdateStatusBarClock($hWnd, $Msg, $iIDTimer, $dwTime)
#forceref $hWnd, $Msg, $iIDTimer, $dwTime
_GUICtrlStatusBar_SetText($hStatusBar, @TAB & @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2)
EndFunc ;==>_UpdateStatusBarClock
Edited by Guest
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...