Jump to content

Layout ListView Error when open other window


Recommended Posts

Hello anyone please help, why my listview error when i open new window, for example can see on attachment when i open program paint. ( please see on attchment from pic number 01 - 03 ).

for you informasi when i run that program on window vista not error ( can work fine ), but when i run on window xp that error come out.

sorry for my bad english, hope u all can understand what i mean.

post-58505-12791129638215_thumb.jpg

post-58505-12791129759698_thumb.jpg

post-58505-12791129876431_thumb.jpg

Link to comment
Share on other sites

  • Moderators

thienfu,

Try using _WinAPI_UpdateWindow() with the handle of your ListView in your idle loop and see if that helps. :blink:

M23

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

thienfu,

Try using _WinAPI_UpdateWindow() with the handle of your ListView in your idle loop and see if that helps. :blink:

M23

Hello Melba23, thanks for reply.

Sorry i still newbie i dunno how to use that function, where i should put that _winAPI_updatewindow() ?

for example below my listview script :

$resultendtenant = $dbDatatBase.OpenRecordset("Select * From db where lease <> 'Vacant'")
    if ($resultendtenant.Eof = -1 And $resultendtenant.Bof =-1)  Then  ; Blank Table
    $ResultBox = GUICtrlCreateListView("No|     Block     |  Unit  |Owner|    Lease    |Start Date|End   Date|         Name of Tenant         |",15,300,968,340, $LVS_REPORT, $WS_EX_CLIENTEDGE)
    _GUICtrlListView_SetExtendedListViewStyle($ResultBox, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))  
        Return
    EndIf
    With $resultendtenant   
    if $resultendtenant.EOF <> true then
    $ResultBox = GUICtrlCreateListView("No|     Block     |  Unit  |Owner|    Lease    |Start Date|End   Date|         Name of Tenant         |",15,300,968,340, $LVS_REPORT, $WS_EX_CLIENTEDGE)
    $j=1
    $k=1
    While Not $resultendtenant.EOF
    For $i = $j  To $j  
    Next        
    if $resultendtenant("end_date").value <= $today then
    $h=$k
    For $g = $k To $k   
    Next    
    _GUICtrlListView_SetExtendedListViewStyle($ResultBox, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))  
    _GUICtrlListView_AddItem($ResultBox, $k)
    _GUICtrlListView_AddSubItem($ResultBox, $k - 1, .Fields(1).Value, 1)
    _GUICtrlListView_AddSubItem($ResultBox, $k - 1, .Fields(2).Value, 2)
    _GUICtrlListView_AddSubItem($ResultBox, $k - 1, .Fields(3).Value, 3)
    _GUICtrlListView_AddSubItem($ResultBox, $k - 1, .Fields(4).Value, 4)
    _GUICtrlListView_AddSubItem($ResultBox, $k - 1, Display_Date(StringLeft($resultendtenant("Start_date").value, 8)), 5)
    _GUICtrlListView_AddSubItem($ResultBox, $k - 1, Display_Date(StringLeft($resultendtenant("end_date").value, 8)), 6)
    _GUICtrlListView_AddSubItem($ResultBox, $k - 1, .Fields(7).Value, 7)
    _GUICtrlListView_AddSubItem($ResultBox, $k - 1, .Fields(8).Value, 8)    
    $k=$k+1
    KeysSetup (0)
    EndIf
    $j = $j + 1
    $resultendtenant.Movenext
    WEnd
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
    GUISetState()
    EndIf
    EndWith

Sorry for my bad english. hope u can understand.

Link to comment
Share on other sites

  • Moderators

thienfu,

My suggestion is to keep calling the line to rewrite the ListView when it becomes corrupted. What you have posted is the code to write the ListView in the first place. ;)

At some point in your script you must have either:

; If you use OnEvent mode
While
    Sleep(10) ; or another number
WEnd

; or if you use GetMessage mode
While
    Switch GUIGetMsg()
    ; other code
WEnd

That is where I suggest you put the line I posted. :blink:

M23

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

thienfu,

My suggestion is to keep calling the line to rewrite the ListView when it becomes corrupted. What you have posted is the code to write the ListView in the first place. ;)

At some point in your script you must have either:

; If you use OnEvent mode
While
    Sleep(10) ; or another number
WEnd

; or if you use GetMessage mode
While
    Switch GUIGetMsg()
    ; other code
WEnd

That is where I suggest you put the line I posted. :blink:

M23

Hi Melba23 i've try using while function to reload for some second, but now that layout alway blink, can i make not blink?

Sorry for my bad english. Hope u can understand

Link to comment
Share on other sites

  • Moderators

thienfu,

Sorry if it flashes, I have not used that command much.

Perhaps you coul link it to as control on your GUI so you can refresh when required. Or check if the window is inactive and then run it ehen the window becomes active again. :blink:

M23

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

thienfu,

Sorry if it flashes, I have not used that command much.

Perhaps you coul link it to as control on your GUI so you can refresh when required. Or check if the window is inactive and then run it ehen the window becomes active again. :blink:

M23

Hi Melba23,

can u guide me how to use function for check window inactive and active, cause i dunno how to use that function.

Sorry for my bad english. Hope u can understand.

Link to comment
Share on other sites

@thienfu

I recommend you put up with it but you can do like this.

...

GUIRegisterMsg($WM_PAINT, 'WM_PAINT')

...

Func WM_PAINT($hWnd, $iMsg, $wParam, $lParam)
    Switch $hWnd
        Case $hGUI
            _WinAPI_InvalidateRect($hListView)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_PAINT
Link to comment
Share on other sites

  • Moderators

thienfu,

how to use function for check window inactive and active

Try this - $hGUI is the handle of the GUI, not the ListView: :blink:

; Declare a flag earlier in the script
$fInActive = False

; Then in your idle loop
While

    ; other code

    ; Check if window is inactive
    If BitAND(WinGetState($hGUI), 8) <> 8 Then
        ; If it is - set flag
        $fInActive = True
    Else
        ; Window is now active, was it just inactive?
        If $fInActive = True Then
            ; If it was then clear flag
            $fInActive = False
            ; And redraw the window
            _WinAPI_UpdateWindow($hGUI)
        EndIf
    EndIf

WEnd

M23

P.S. When you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. ;)

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

hello Yashied, below my script after put your _WinAPI_InvalidateRect() function, but still not work, maybe i wrong use on my script, pls advise. and attachment are my database

And hello Melba23, ok i will use add reply button for reply. i've question if we use function for check inactive or active GUI, then when GUI Inactive and become active again the GUI will reload the mainGUI so that data will show like first time we open ? My problem are when i click the view button and i open other window then the error come out like on pic i attach first time. any solution for solve this case?

Sorry for my bad english, hope u all can understand my problem :blink:

#include <GUIConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIComboBox.au3>
#include <GuiListView.au3>
#include <FontConstants.au3>
#include <WinAPI.au3>
#include <Date.au3>

Const $conProgName = "Schedulle Tenancy"
Const $conDbFile = "db.mdb" ; it has to be on script current Dir
Const $conTable = "db"
Const $conOK = 1, $conEdit = 1, $conAdd = 0

Global $oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

Global $objDBSystem, $dbDatatBase, $recRecordSet, $ResultBox

Global $selectblock, $selectunit, $owner, $period, $startdate, $enddate, $tenant, $monthlyrent,$monthlymaint
Global $SecondGUI, $MainGUI

Global $today = Stringmid(_nowdate(), 7, 4) & Stringmid(_nowdate(), 4, 2) & StringLeft(_Nowdate(), 2) 

If Setup() = $conOK Then
    Main()
EndIf

Func Setup()
    $objDBSystem = ObjCreate("DAO.DBEngine.36")
    If $conOK <> FileExists(@ScriptDir & "\" & $conDbFile) Then
        MsgBox(16, $conProgName, "Database File is not found " & @LF & @ScriptDir & "\" & $conDbFile)
        ;Return 0
        Exit
    EndIf
    $dbDatatBase = $objDBSystem.OpenDatabase(@ScriptDir & "\" & $conDbFile)
    $recRecordSet = $dbDatatBase.OpenRecordset("Select * From " & $conTable)
    Return $conOK
EndFunc   ;==>Setup

Func Main()
    Opt("GUIOnEventMode", 1)
    $MainGUI = GUICreate("PT. KBI - Schedulle Tenancy", 1000, 700) ; will create a dialog box
    GUISetBkColor(0xFFFBF0) ; will change background color
    $hTab = GUICtrlCreateTab(5, 10, 990, 685)
    $hTab0 = GUICtrlCreateTabItem("Main")
    
    GUISetOnEvent($GUI_EVENT_CLOSE, "End")

    
    GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group
    
    GUICtrlCreateGroup("Notice", 10, 185, 545, 100)
    
    GUICtrlCreateLabel("Date :", 15, 200)
    GUICtrlCreateLabel(_NowDate(), 50, 200)
    
    $a = $dbDatatBase.OpenRecordset("Select * From db where Lease <> 'Vacant'")
    if ($a.Eof = -1 And $a.Bof =-1)  Then
    GUICtrlCreateLabel("There are ", 15, 220)   
    GUICtrlCreateLabel("0", 65, 220)
    GUICtrlCreateLabel("Units Tenant Has Been Due Date the lease, but havent confirm want to Extend or Not", 85, 220)
    $viewenddatetenant = GUICtrlCreateButton("View", 520, 218, 30, 20)
    GUICtrlSetOnEvent($viewenddatetenant, "Viewendtenant")
    Else
    $count = 0
    $countenddate = 0
    While Not $a.EOF
        for $b = $count to $count
        Next
        if $a("end_date").value <= $today then
        $countenddate = $countenddate+1
        EndIf
        $count = $count+1
        $a.movenext 
    WEnd
    GUICtrlCreateLabel("There are ", 15, 220)
    GUICtrlCreateLabel($countenddate, 65, 220)
    GUICtrlCreateLabel("Units Tenant Has Been Due Date the lease, but havent confirm want to Extend or Not", 85, 220)
    $viewenddatetenant = GUICtrlCreateButton("View", 520, 218, 30, 20)
    GUICtrlSetOnEvent($viewenddatetenant, "Viewendtenant")
    EndIf
    
    GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group
    
    GUICtrlCreateGroup("Result", 10, 285, 977, 360)
    
    $result = $dbDatatBase.OpenRecordset("Select * From db")
    if ($result.Eof = -1 And $result.Bof =-1)  Then  ; Blank Table
    GUISetState()   
    $ResultBox = GUICtrlCreateListView("No|     Block     |  Unit  |Owner|    Lease    |Start Date|End   Date|         Name of Tenant         |",15,300,968,340, $LVS_REPORT, $WS_EX_CLIENTEDGE)
    _GUICtrlListView_SetExtendedListViewStyle($ResultBox, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))  
    EndIf
    With $result    
    if $Result.EOF <> true then
    $ResultBox = GUICtrlCreateListView("No|     Block     |  Unit  |Owner|    Lease    |Start Date|End   Date|         Name of Tenant         |",15,300,968,340, $LVS_REPORT, $WS_EX_CLIENTEDGE)
    $j=1
    While Not $Result.EOF
    For $i = $j  To $j
    _GUICtrlListView_SetExtendedListViewStyle($ResultBox, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))  
    _GUICtrlListView_AddItem($ResultBox, $j)
    _GUICtrlListView_AddSubItem($ResultBox, $i - 1, .Fields(1).Value, 1)
    _GUICtrlListView_AddSubItem($ResultBox, $i - 1, .Fields(2).Value, 2)
    _GUICtrlListView_AddSubItem($ResultBox, $i - 1, .Fields(3).Value, 3)
    _GUICtrlListView_AddSubItem($ResultBox, $i - 1, .Fields(4).Value, 4)
    _GUICtrlListView_AddSubItem($ResultBox, $i - 1, Display_Date(StringLeft($result("Start_date").value, 8)), 5)
    _GUICtrlListView_AddSubItem($ResultBox, $i - 1, Display_Date(StringLeft($result("end_date").value, 8)), 6)
    _GUICtrlListView_AddSubItem($ResultBox, $i - 1, .Fields(7).Value, 7)
    _GUICtrlListView_AddSubItem($ResultBox, $i - 1, .Fields(8).Value, 8)
    Next 
    $j = $j+1
    $Result.Movenext
    WEnd
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
    GUISetState()
    EndIf
    EndWith
    
    GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

    GUISetState(@SW_SHOW)
        
    While 1

        $Msg = GUIGetMsg()
        Switch $Msg
            Case $GUI_EVENT_CLOSE
                end()
        EndSwitch
    WEnd

EndFunc   ;==>Main

Func Viewendtenant()
    $resultendtenant = $dbDatatBase.OpenRecordset("Select * From db where lease <> 'Vacant'")
    if ($resultendtenant.Eof = -1 And $resultendtenant.Bof =-1)  Then  ; Blank Table
    $ResultBox = GUICtrlCreateListView("No|     Block     |  Unit  |Owner|    Lease    |Start Date|End   Date|         Name of Tenant         |",15,300,968,340, $LVS_REPORT, $WS_EX_CLIENTEDGE)
    _GUICtrlListView_SetExtendedListViewStyle($ResultBox, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))  
        Return
    EndIf
    With $resultendtenant   
    if $resultendtenant.EOF <> true then
    $ResultBox = GUICtrlCreateListView("No|     Block     |  Unit  |Owner|    Lease    |Start Date|End   Date|         Name of Tenant         |",15,300,968,340, $LVS_REPORT, $WS_EX_CLIENTEDGE)
    $j=1
    $k=1
    While Not $resultendtenant.EOF
    For $i = $j  To $j  
    Next        
    if $resultendtenant("end_date").value <= $today then
    $h=$k
    For $g = $k To $k   
    Next    
    _GUICtrlListView_SetExtendedListViewStyle($ResultBox, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))  
    _GUICtrlListView_AddItem($ResultBox, $k)
    _GUICtrlListView_AddSubItem($ResultBox, $k - 1, .Fields(1).Value, 1)
    _GUICtrlListView_AddSubItem($ResultBox, $k - 1, .Fields(2).Value, 2)
    _GUICtrlListView_AddSubItem($ResultBox, $k - 1, .Fields(3).Value, 3)
    _GUICtrlListView_AddSubItem($ResultBox, $k - 1, .Fields(4).Value, 4)
    _GUICtrlListView_AddSubItem($ResultBox, $k - 1, Display_Date(StringLeft($resultendtenant("Start_date").value, 8)), 5)
    _GUICtrlListView_AddSubItem($ResultBox, $k - 1, Display_Date(StringLeft($resultendtenant("end_date").value, 8)), 6)
    _GUICtrlListView_AddSubItem($ResultBox, $k - 1, .Fields(7).Value, 7)
    _GUICtrlListView_AddSubItem($ResultBox, $k - 1, .Fields(8).Value, 8)    
    $k=$k+1
    EndIf
    $j = $j + 1
    $resultendtenant.Movenext
    WEnd
    GUIRegisterMsg($WM_PAINT, 'WM_PAINT')
    GUISetState()
    EndIf
    EndWith
EndFunc

Func WM_PAINT($hWnd, $iMsg, $wParam, $lParam)
    Switch $hWnd
    Case $MainGUI
            _WinAPI_InvalidateRect($ResultBox)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_PAINT

Func Display_Date($date)
   Return StringRight($date, 2) & "/" & StringMid($date, 5, 2) & "/" & StringLeft($date, 4) ; DD/MM/YYYY
;  Return StringMid($date, 5, 2) & "/" & StringRight($date, 2) & "/" & StringLeft($date, 4) ; MM/DD/YYYY
EndFunc

Func End()
    Switch @GUI_WINHANDLE
        Case $MainGUI
            GUIDelete($MainGUI)
            Exit
        Case $SecondGUI
            GUIDelete($SecondGUI)
    EndSwitch
EndFunc

db.rar

Link to comment
Share on other sites

GUIRegisterMsg() is enough to write once at the beginning of code, and following

_WinAPI_InvalidateRect(GUICtrlGetHandle($ResultBox))

#include <GUIConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIComboBox.au3>
#include <GuiListView.au3>
#include <FontConstants.au3>
#include <WinAPI.au3>
#include <Date.au3>

Const $conProgName = "Schedulle Tenancy"
Const $conDbFile = "db.mdb" ; it has to be on script current Dir
Const $conTable = "db"
Const $conOK = 1, $conEdit = 1, $conAdd = 0

Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")

Global $objDBSystem, $dbDatatBase, $recRecordSet, $ResultBox

Global $selectblock, $selectunit, $owner, $period, $startdate, $enddate, $tenant, $monthlyrent, $monthlymaint
Global $SecondGUI, $MainGUI

Global $today = StringMid(_NowDate(), 7, 4) & StringMid(_NowDate(), 4, 2) & StringLeft(_NowDate(), 2)

GUIRegisterMsg($WM_PAINT, 'WM_PAINT')
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

If Setup() = $conOK Then
    Main()
EndIf

Func Setup()
    $objDBSystem = ObjCreate("DAO.DBEngine.36")
    If $conOK <> FileExists(@ScriptDir & "\" & $conDbFile) Then
        MsgBox(16, $conProgName, "Database File is not found " & @LF & @ScriptDir & "\" & $conDbFile)
        ;Return 0
        Exit
    EndIf
    $dbDatatBase = $objDBSystem.OpenDatabase(@ScriptDir & "\" & $conDbFile)
    $recRecordSet = $dbDatatBase.OpenRecordset("Select * From " & $conTable)
    Return $conOK
EndFunc   ;==>Setup

Func Main()
    Opt("GUIOnEventMode", 1)
    $MainGUI = GUICreate("PT. KBI - Schedulle Tenancy", 1000, 700) ; will create a dialog box
    GUISetBkColor(0xFFFBF0) ; will change background color
    $hTab = GUICtrlCreateTab(5, 10, 990, 685)
    $hTab0 = GUICtrlCreateTabItem("Main")

    GUISetOnEvent($GUI_EVENT_CLOSE, "End")


    GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

    GUICtrlCreateGroup("Notice", 10, 185, 545, 100)

    GUICtrlCreateLabel("Date :", 15, 200)
    GUICtrlCreateLabel(_NowDate(), 50, 200)

    $a = $dbDatatBase.OpenRecordset("Select * From db where Lease <> 'Vacant'")
    if ($a.Eof = -1 And $a.Bof = -1) Then
        GUICtrlCreateLabel("There are ", 15, 220)
        GUICtrlCreateLabel("0", 65, 220)
        GUICtrlCreateLabel("Units Tenant Has Been Due Date the lease, but havent confirm want to Extend or Not", 85, 220)
        $viewenddatetenant = GUICtrlCreateButton("View", 520, 218, 30, 20)
        GUICtrlSetOnEvent($viewenddatetenant, "Viewendtenant")
    Else
        $count = 0
        $countenddate = 0
        While Not $a.EOF
            For $b = $count To $count
            Next
            If $a("end_date" ).value <= $today Then
                $countenddate = $countenddate + 1
            EndIf
            $count = $count + 1
            $a.movenext
        WEnd
        GUICtrlCreateLabel("There are ", 15, 220)
        GUICtrlCreateLabel($countenddate, 65, 220)
        GUICtrlCreateLabel("Units Tenant Has Been Due Date the lease, but havent confirm want to Extend or Not", 85, 220)
        $viewenddatetenant = GUICtrlCreateButton("View", 520, 218, 30, 20)
        GUICtrlSetOnEvent($viewenddatetenant, "Viewendtenant")
    EndIf

    GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

    GUICtrlCreateGroup("Result", 10, 285, 977, 360)

    $result = $dbDatatBase.OpenRecordset("Select * From db")
    if ($result.Eof = -1 And $result.Bof = -1) Then ; Blank Table
        GUISetState()
        $ResultBox = GUICtrlCreateListView("No|     Block     |  Unit  |Owner|    Lease    |Start Date|End   Date|         Name of Tenant         |", 15, 300, 968, 340, $LVS_REPORT, $WS_EX_CLIENTEDGE)
        _GUICtrlListView_SetExtendedListViewStyle($ResultBox, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
    EndIf
    With $result
        If $result.EOF <> True Then
            $ResultBox = GUICtrlCreateListView("No|     Block     |  Unit  |Owner|    Lease    |Start Date|End   Date|         Name of Tenant         |", 15, 300, 968, 340, $LVS_REPORT, $WS_EX_CLIENTEDGE)
            $j = 1
            While Not $result.EOF
                For $i = $j To $j
                    _GUICtrlListView_SetExtendedListViewStyle($ResultBox, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
                    _GUICtrlListView_AddItem($ResultBox, $j)
                    _GUICtrlListView_AddSubItem($ResultBox, $i - 1, .Fields(1).Value, 1)
                    _GUICtrlListView_AddSubItem($ResultBox, $i - 1, .Fields(2).Value, 2)
                    _GUICtrlListView_AddSubItem($ResultBox, $i - 1, .Fields(3).Value, 3)
                    _GUICtrlListView_AddSubItem($ResultBox, $i - 1, .Fields(4).Value, 4)
                    _GUICtrlListView_AddSubItem($ResultBox, $i - 1, Display_Date(StringLeft($result("Start_date" ).value, 8)), 5)
                    _GUICtrlListView_AddSubItem($ResultBox, $i - 1, Display_Date(StringLeft($result("end_date" ).value, 8)), 6)
                    _GUICtrlListView_AddSubItem($ResultBox, $i - 1, .Fields(7).Value, 7)
                    _GUICtrlListView_AddSubItem($ResultBox, $i - 1, .Fields(8).Value, 8)
                Next
                $j = $j + 1
                $result.Movenext
            WEnd
            GUISetState()
        EndIf
    EndWith

    GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

    GUISetState(@SW_SHOW)

    While 1

        $Msg = GUIGetMsg()
        Switch $Msg
            Case $GUI_EVENT_CLOSE
                end()
        EndSwitch
    WEnd

EndFunc   ;==>Main

Func Viewendtenant()
    $resultendtenant = $dbDatatBase.OpenRecordset("Select * From db where lease <> 'Vacant'")
    if ($resultendtenant.Eof = -1 And $resultendtenant.Bof = -1) Then ; Blank Table
        $ResultBox = GUICtrlCreateListView("No|     Block     |  Unit  |Owner|    Lease    |Start Date|End   Date|         Name of Tenant         |", 15, 300, 968, 340, $LVS_REPORT, $WS_EX_CLIENTEDGE)
        _GUICtrlListView_SetExtendedListViewStyle($ResultBox, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
        Return
    EndIf
    With $resultendtenant
        If $resultendtenant.EOF <> True Then
            $ResultBox = GUICtrlCreateListView("No|     Block     |  Unit  |Owner|    Lease    |Start Date|End   Date|         Name of Tenant         |", 15, 300, 968, 340, $LVS_REPORT, $WS_EX_CLIENTEDGE)
            $j = 1
            $k = 1
            While Not $resultendtenant.EOF
                For $i = $j To $j
                Next
                If $resultendtenant("end_date" ).value <= $today Then
                    $h = $k
                    For $g = $k To $k
                    Next
                    _GUICtrlListView_SetExtendedListViewStyle($ResultBox, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
                    _GUICtrlListView_AddItem($ResultBox, $k)
                    _GUICtrlListView_AddSubItem($ResultBox, $k - 1, .Fields(1).Value, 1)
                    _GUICtrlListView_AddSubItem($ResultBox, $k - 1, .Fields(2).Value, 2)
                    _GUICtrlListView_AddSubItem($ResultBox, $k - 1, .Fields(3).Value, 3)
                    _GUICtrlListView_AddSubItem($ResultBox, $k - 1, .Fields(4).Value, 4)
                    _GUICtrlListView_AddSubItem($ResultBox, $k - 1, Display_Date(StringLeft($resultendtenant("Start_date" ).value, 8)), 5)
                    _GUICtrlListView_AddSubItem($ResultBox, $k - 1, Display_Date(StringLeft($resultendtenant("end_date" ).value, 8)), 6)
                    _GUICtrlListView_AddSubItem($ResultBox, $k - 1, .Fields(7).Value, 7)
                    _GUICtrlListView_AddSubItem($ResultBox, $k - 1, .Fields(8).Value, 8)
                    $k = $k + 1
                EndIf
                $j = $j + 1
                $resultendtenant.Movenext
            WEnd
            GUISetState()
        EndIf
    EndWith
EndFunc   ;==>Viewendtenant

Func WM_PAINT($hWnd, $iMsg, $wParam, $lParam)
    Switch $hWnd
        Case $MainGUI
            _WinAPI_InvalidateRect(GUICtrlGetHandle($ResultBox))
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_PAINT

Func Display_Date($date)
    Return StringRight($date, 2) & "/" & StringMid($date, 5, 2) & "/" & StringLeft($date, 4) ; DD/MM/YYYY
    ;  Return StringMid($date, 5, 2) & "/" & StringRight($date, 2) & "/" & StringLeft($date, 4) ; MM/DD/YYYY
EndFunc   ;==>Display_Date

Func End()
    Switch @GUI_WinHandle
        Case $MainGUI
            GUIDelete($MainGUI)
            Exit
        Case $SecondGUI
            GUIDelete($SecondGUI)
    EndSwitch
EndFunc   ;==>End
Edited by Yashied
Link to comment
Share on other sites

There are more direct functions for that (work on the control, not the whole window). See _GUICtrlListView_BeginUpdate() and _GUICtrlListView_EndUpdate() in the help file.

:blink:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...