Jump to content
Sign in to follow this  
Tec

Problem with Tab + Listview

Recommended Posts

Tec

Hi

I have some Problem with Tab and Listview. When I lock my Workstation WinXP SP3 and unlock, the Scrollbar not refresh. See Screenshot.

Autoit Version 3.3.6.1

#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)


$Gui = GUICreate("Test", 300, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "Beenden")

Local $menu1 = GUICtrlCreateMenu("&Datei",-1,2)
    Local $menu10 = GUICtrlCreateMenuItem("Aktualisiere Client",$menu1)
    Local $menu11 = GUICtrlCreateMenuItem("Aktualisiere AD",$menu1)
    Local $menu12 = GUICtrlCreateMenuItem("Exit",$menu1)

Local $tab = GUICtrlCreateTab(5, 0, 290, 180)

Local $tab1 = GUICtrlCreateTabItem("Online")

Local $hListView = GUICtrlCreateListView("Client | Status| test", 10, 25, 150, 150)
;GUICtrlSendMsg($hListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
Global $B_DESCENDING[_GUICtrlListView_GetColumnCount($hListView)]
GUISetState()

_test()

While 1
    Sleep(10)
WEnd
Exit

Func Beenden()
    Exit
EndFunc

Func _test()
    _GUICtrlListView_DeleteAllItems($hListView)
    GUICtrlSetState($hListView, $GUI_DISABLE)
    Sleep( 3000 )
    GUISetState(@SW_LOCK)
    For $a = 1 To 60
        If $a = 4 Then
            GUICtrlCreateListViewItem("PC" & $a & "|Offline|" & $a, $hListView)
        Else
            GUICtrlCreateListViewItem("PC" & $a & "|Online|" & $a, $hListView)
        EndIf
        Sleep( 50 )
    Next
    _GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE)
    _GUICtrlListView_SetColumnWidth($hListView, 1, $LVSCW_AUTOSIZE)
    _GUICtrlListView_SetColumnWidth($hListView, 2, $LVSCW_AUTOSIZE)
    GUISetState(@SW_UNLOCK)
    GUICtrlSetState($hListView, $GUI_ENABLE)
    _ReduceMemory(@AutoItPid)
EndFunc


Func _ReduceMemory($i_PID = -1)
    If $i_PID <> -1 Then
        Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID)
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
        DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
    Else
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
    EndIf

    Return $ai_Return[0]
EndFunc;==> _ReduceMemory()


Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
    $hWndListView = $hListView
    If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")

    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $LVN_COLUMNCLICK
                    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
                    _GUICtrlListView_SimpleSort($hWndListView, $B_DESCENDING, DllStructGetData($tInfo, "SubItem"))

                Case $NM_CUSTOMDRAW
                    ; http://msdn.microsoft.com/en-us/library/bb761817(VS.85).aspx
                    Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $ilParam)
                    Local $iDrawStage = DllStructGetData($tCustDraw, "dwDrawStage")

                    Switch $iDrawStage
                        Case $CDDS_PREPAINT
                            Return $CDRF_NOTIFYITEMDRAW ;request custom drawing of items

                        Case $CDDS_ITEMPREPAINT
                            Return $CDRF_NOTIFYSUBITEMDRAW

                        Case Else
                            ;case $CDDS_SUBITEM
                            Local $iItem = DllStructGetData($tCustDraw, "dwItemSpec")

                            Switch DllStructGetData($tCustDraw, "iSubItem")
                                Case 1
                                    If _GUICtrlListView_GetItemText($hWndListView, $iItem, 1) = "Offline" Then
                                        DllStructSetData($tCustDraw, "clrTextBk", 0x0000FF)
                                    Else
                                        DllStructSetData($tCustDraw, "clrTextBk", 0xffffff)
                                    EndIf

                                Case Else
                                    DllStructSetData($tCustDraw, "clrTextBk", 0xffffff)

                            EndSwitch
                            Return $CDRF_NEWFONT

                    EndSwitch
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Did I do something wrong ?

post-17456-12816119482786_thumb.jpg

post-17456-12816122150076_thumb.jpg

Share this post


Link to post
Share on other sites
jaberwacky

So the first picture is before or after you lock your computer?

I don't have a problem with the scrollbar not showing. It shows both before and after I lock my computer. If I scroll about halfway down the list, lock my computer, unlock my computer, then the scrollbar is where I left it. Is that the problem?

Share this post


Link to post
Share on other sites
Tec

The first picture is after I lock/unlock my Computer.

If I minimize and maximize the Gui or after first start it is ok (pic2).

I have the Problem only with Tabs. Without Tabs I have no problem with Listview and lock/unlock.

After lock/unlock an click on Scrollbar you can see the Scrollbar. See Screenshot.

post-17456-12816818999277_thumb.jpg

Edited by Tec

Share this post


Link to post
Share on other sites
jaberwacky

Well, I don't have a problem with the scrollbar on either my Windows 7 x64 machine or my Windows XP x86 virtual machine. So, I dunno what to tell you. Maybe someone else can help you because it's possible that I still don't understand the problem?

Share this post


Link to post
Share on other sites
Tec

Hmm I test it on 2 WinXP SP3 Clients and a virtual Vista maschine. Always the same problem. If I start the test code above it looks good. If I press Ctrl+Alt+Del and go back the Scrollbar and some empty area from the listview are gray.

If I minimize the Gui or scroll or change a Tab it is Ok... strange :-/

If I test the same code without GUICtrlCreateTab no problem with Ctrl+Alt+Del.

But thx for testing jaberwocky6669

Share this post


Link to post
Share on other sites
Tec

#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Local $Gui = GUICreate("Test", 300, 200)
Local $tab = GUICtrlCreateTab(5, 5, 290, 190)
Local $tab1 = GUICtrlCreateTabItem("Tab1")
Local $hListView = GUICtrlCreateListView("Test1 | Test2| Test3", 10, 30, 280 , 160)
Local $tab2 = GUICtrlCreateTabItem("Tab2")
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
    Sleep(10)
WEnd
Exit

With this small code I have the same problem with one difference. I need to lock (Ctrl+Alt+Del) my system two times befor the Listview is gray. ;)

Share this post


Link to post
Share on other sites
Tec

Hi

I found mein problem.... $LVS_EX_FULLROWSELECT

Without $LVS_EX_FULLROWSELECT I have no Problem with the Gui. With $LVS_EX_FULLROWSELECT I have a greyed Listview after lock System (Ctrl+Alt+Del) but only if I use Listview with Tabs. Without Tabs it works fine.

post-17456-1283422117758_thumb.jpg <- Without FULLROWSELECT after lock System (Ctrl+Alt+Del)

post-17456-12834221285213_thumb.jpg <- With FULLROWSELECT after lock System (Ctrl+Alt+Del)

#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>

Local $Gui = GUICreate("Test", 300, 200)
Local $tab = GUICtrlCreateTab(5, 5, 290, 190)
Local $tab1 = GUICtrlCreateTabItem("Tab1")
Local $hListView = GUICtrlCreateListView("Test1 | Test2| Test3|", 10, 30, 280 , 160, -1, BitOR( $WS_EX_CLIENTEDGE, $LVS_EX_FULLROWSELECT,  $LVS_EX_GRIDLINES)) ;Problem
;Local $hListView = GUICtrlCreateListView("Test1 | Test2| Test3|", 10, 30, 280 , 160, -1, BitOR( $WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES)) ; no Problem 
Local $tab2 = GUICtrlCreateTabItem("Tab2")
GUISetState(@SW_SHOW)

;GUICtrlCreateListViewItem("a|b|c", $hListView)


While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
    Sleep(10)
WEnd
Exit

Have someone a solution for me or can test the code ? I need $LVS_EX_FULLROWSELECT...

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.