Jump to content

Resize a ListView


 Share

Recommended Posts

Hi everybody,

Just a quick question because there's not much to explain,

I'm using GUICtrlSetResizing(-1, $GUI_DOCKAUTO) with a list view but it doesn't seem to be working!

The Listview just stays in the same place and doesn't even resize.

Any Ideas?

Edited by DjATUit
Link to comment
Share on other sites

  • Moderators

DjATUit,

GUICtrlSetResizing only works on controls created with the built-in GUICtrlCreate* commands. Did you create your ListView with the GuiListView UDF by chance? ;)

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

  • Moderators

DjATUit,

A bit flickery, but this works: ;)

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

$hGUI = GUICreate("Test", 500, 500, -1, -1, $WS_SIZEBOX)
GUISetBkColor(0xFF0000, $hGUI)

$hListView = _GUICtrlListView_Create($hGUI, "Header", 10, 10, 300, 300)

GUISetState()

GUIRegisterMsg($WM_SIZE, "MY_WM_SIZE")

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

WEnd

Func MY_WM_SIZE($hWnd, $Msg, $wParam, $lParam)

    $iGUIWidth = BitAND($lParam, 0xFFFF)
    $iGUIHeight = BitShift($lParam, 16)

    ; Use a suitable formula to get it to resize as you wish - here it is a simple fraction of the GUI size
    WinMove($hListView, "", 10, 10, $iGUIWidth * 300 / 500, $iGUIHeight * 300 / 500)

    Return $GUI_RUNDEFMSG

EndFunc   ;==>MY_WM_SIZE

Any good? :)

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

I don't know if this works for everything, but why not just use GUICtrlCreateListview? I haven't run into any problems using the Control ID returned from using it when passing it to the UDF's, at least if they're written correctly, that would require me to create it using the UDF in the first place.

Unless there's a parameter that the UDF created listview control gives you that the standard one doesn't give you access to, you're usually better off using the built in create functions rather than the UDF functions, at least for creating them initially.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Moderators

DjATUit,

can you make it so the position is relative aswell

Flattery will get you most things ;) - what exactly do you mean by "relative"? Same proportion of the GUI area?

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

Well stuff me! Well Kinda

Most Of my Functions work but not all

Unfortunatly, I think I'm still better off with the UDF for some reason

So still havent got around the problem, any more ideas then?

PS I doubt it'll work but will redifing a GUICtrlCreateListview with resizing properties with a UDF work?

Link to comment
Share on other sites

Like I stated, I haven't seen any of the ListView UDFs that won't work with a Listview created using the standard GUICtrlCreateListview function. The control ID that you get back when you create the Listview can be passed as-is to the UDF, every properly written UDF internally converts the control ID into the handle that they usually access. All I can say is, give it a try and see if it work, the worst that happens is you go back to creating it the way you had it before. Just comment out the original line where you create the LV and then rewrite it using the standard function, if it works great, if not uncomment the original line and delete the new line. Simple to test it. ;)

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

BrewManH,

One of the ListView UDF's I'm talking about it to delete all entries! Don't ask me why, all I know is everything works with the creation with the UDF!

When using GUICtrlCreateListview, the UDF deleted all of your entries? What function were you calling that caused that?

And my idea of redifing the LV didn't work at all, just to let you know!

I'm not sure what you mean here, what does redifing mean? Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

When using GUICtrlCreateListview, the UDF deleted all of your entries? What function were you calling that caused that?

I'm not sure what you mean here, what does redifing mean?

Sorry, I'm a bit misleading.

Firstly, the UDF i'm talking about is meant to delete all the entries. Heinz _GUICtrlListView_DeleteAllEntries ;) And when I define the ListView using GUICtrlCreateListview it doesn't delete all the entries!

And by the way, I meant "Redifining" and when I say difine or whatever I mean creating a new object with a varible

Link to comment
Share on other sites

Try using it this way

_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView))

That's how I did it in my media player program.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I found that adding listview items to an array, rather than having them pre-defined, was the best method to work with a listview.

I've found the example code, though I am not going to take the time to go through it and edit it for simplicity. It's probably in pretty awful tidy condition as well, lol.

HOWEVER, if you take the time to look through it, you'll find out how I add listview items as dynamic variables using arrays. This allows me to add, delete, and move them easily and quickly.

$ListViewItems[$numitems - 1][0] = GUICtrlCreateListViewItem($itemnum & "|" & $itemqty & "|" & $itemshop & "|Awaiting Last Vendor...", $Items_ListView)

$ListViewItems[$numitems - 1][1] = $itemnum

$ListViewItems[$numitems - 1][2] = $itemqty

$ListViewItems[$numitems - 1][3] = $itemshop

$ListViewItems[$numitems - 1][4] = "Need" ;added because below code was commented, filler

Also, you'll find a way to sort arrays based on multiple variables in the array by concatenating the variables and adding them as a single variable to a re-dimensioned array (ReDim).

;BEGIN SORTING ARRAY

;WE MUST CREATE AN ADDITIONAL DIMENSION TO SORT ON BASED UPON VENDOR AND SHOP

Local $orderarray = $ListViewItems

ReDim $ListViewItems[uBound($ListViewItems)][6]

For $x = 0 To UBound($ListViewItems) - 1

$ListViewItems[$x][5] = $ListViewItems[$x][4] & $ListViewItems[$x][3]

Next

_ArraySort($ListViewItems, 0, 0, 0, 5)

ReDim $ListViewItems[uBound($ListViewItems)][5]

Also, to delete items, look how I handle it with my "Remove" button.

Case $RemoveItem_btn

$delete = GUICtrlRead($Items_ListView)

$count = 0

If IsArray($ListViewItems) Then

For $x = 0 To UBound($ListViewItems) - 1

If $delete = $ListViewItems[$x][0] Then

GUICtrlDelete($ListViewItems[$x][0])

_ArrayDelete($ListViewItems, $x)

$numitems -= 1

ExitLoop

EndIf

$count += 1

Next

EndIf

If Not IsArray($ListViewItems) Then

GUICtrlSetState($RemoveItem_btn, $GUI_DISABLE)

GUICtrlSetState($CreateOrders_btn, $GUI_DISABLE)

EndIf

Hope this helps some peeps.

Func Create_Item_Array()

    Local $ListViewItems
    Local $numitems = 1

    #region ### START Koda GUI section ### Form=C:\Documents and Settings\Cory\Desktop\SAM\OrderEntry.kxf

    $Form1_1_1 = GUICreate("SAM Order Entry", 635, 451, @DesktopWidth/2 - 317, @DesktopHeight/2 - 225)
    $Items_ListView = GUICtrlCreateListView("Part Number|Qty|Loc|Vendor", 16, 16, 305, 417)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 85)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 35)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 130)
    $AddItem_Group = GUICtrlCreateGroup("Add Item", 328, 16, 289, 231)
    $Item_Number_Input = GUICtrlCreateInput("", 432, 40, 169, 21)
    $Quantity_Input = GUICtrlCreateInput("", 432, 72, 169, 21)
    $Shop_Combo = GUICtrlCreateCombo("", 432, 112, 169, 25)
    GUICtrlSetData(-1, "Shop #4|Shop #5|Shop #6")
    $Label1 = GUICtrlCreateLabel("Part Number:", 360, 40, 66, 17)
    $Label2 = GUICtrlCreateLabel("Quantity:", 360, 72, 46, 17)
    $Label3 = GUICtrlCreateLabel("Shop:", 360, 112, 32, 17)
    $AddItem_btn = GUICtrlCreateButton("Add Item", 480, 176, 121, 25, $WS_GROUP)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $RemoveItem_btn = GUICtrlCreateButton("Remove Item", 344, 176, 113, 25, $WS_GROUP)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $GetLastVend_btn = GUICtrlCreateButton("Get Last Vendor", 480, 209, 121, 25, $WS_GROUP)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $CreateOrders_btn = GUICtrlCreateButton("Create Orders", 528, 384, 89, 41, $WS_GROUP)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUISetState(@SW_SHOW)

    #endregion ### END Koda GUI section ###
;~  GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")


    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $Item_Number_Input
                If GUICtrlRead($Quantity_Input) = Not "" And GUICtrlRead($Shop_Combo) = Not "" Then
                    GUICtrlSetState($AddItem_btn, $GUI_ENABLE)
                EndIf
            Case $Quantity_Input
                If GUICtrlRead($Item_Number_Input) = Not "" And GUICtrlRead($Shop_Combo) = Not "" Then
                    GUICtrlSetState($AddItem_btn, $GUI_ENABLE)
                EndIf
            Case $Shop_Combo
                If GUICtrlRead($Quantity_Input) = Not "" And GUICtrlRead($Shop_Combo) = Not "" Then
                    GUICtrlSetState($AddItem_btn, $GUI_ENABLE)
                EndIf
            Case $AddItem_btn
                GUICtrlSetState($AddItem_btn, $GUI_DISABLE)
                GUICtrlSetState($Item_Number_Input, $GUI_DISABLE)
                GUICtrlSetState($Quantity_Input, $GUI_DISABLE)
                GUICtrlSetState($Shop_Combo, $GUI_DISABLE)
                GUICtrlSetState($RemoveItem_btn, $GUI_DISABLE)
                GUICtrlSetState($CreateOrders_btn, $GUI_DISABLE)
                GUICtrlSetState($GetLastVend_btn, $GUI_DISABLE)
                $itemnum = StringUpper(GUICtrlRead($Item_Number_Input))
                $itemqty = GUICtrlRead($Quantity_Input)
                $itemshop = GUICtrlRead($Shop_Combo)

                If Not IsArray($ListViewItems) Then Local $ListViewItems[1][5]

                If $numitems > UBound($ListViewItems) Then ReDim $ListViewItems[$numitems][5]
                $ListViewItems[$numitems - 1][0] = GUICtrlCreateListViewItem($itemnum & "|" & $itemqty & "|" & $itemshop & "|Awaiting Last Vendor...", $Items_ListView)
                $ListViewItems[$numitems - 1][1] = $itemnum
                $ListViewItems[$numitems - 1][2] = $itemqty
                $ListViewItems[$numitems - 1][3] = $itemshop
                $ListViewItems[$numitems - 1][4] = "Need" ;added because below code was commented, filler
;~              $lastvend = Get_Last_Vendor_Ordered($itemnum)
;~              If $lastvend = False Then
;~                  $lastvend = "Unknown"
;~              EndIf
;~              $ListViewItems[$numitems - 1][4] = $lastvend
;~              GUICtrlSetData($ListViewItems[$numitems - 1][0], $itemnum & "|" & $itemqty & "|" & $itemshop & "|" & $ListViewItems[$numitems - 1][4])
;~              If $lastvend = "Unknown" then _GUICtrlListView_SetBkColor($ListViewItems[$numitems - 1][0], (0xDA3838))
                $numitems += 1
                GUICtrlSetState($RemoveItem_btn, $GUI_ENABLE)
                GUICtrlSetState($CreateOrders_btn, $GUI_ENABLE)
                GUICtrlSetData($Item_Number_Input, "")
                GUICtrlSetData($Quantity_Input, "")
                _GUICtrlComboBox_SetCurSel($Shop_Combo, -1)
                GUICtrlSetState($Item_Number_Input, $GUI_ENABLE)
                GUICtrlSetState($Quantity_Input, $GUI_ENABLE)
                GUICtrlSetState($Shop_Combo, $GUI_ENABLE)
                GUICtrlSetState($GetLastVend_btn, $GUI_ENABLE)
            Case $RemoveItem_btn
                $delete = GUICtrlRead($Items_ListView)
                $count = 0
                If IsArray($ListViewItems) Then
                    For $x = 0 To UBound($ListViewItems) - 1
                        If $delete = $ListViewItems[$x][0] Then
                            GUICtrlDelete($ListViewItems[$x][0])
                            _ArrayDelete($ListViewItems, $x)
                            $numitems -= 1
                            ExitLoop
                        EndIf
                        $count += 1
                    Next
                EndIf
                If Not IsArray($ListViewItems) Then
                    GUICtrlSetState($RemoveItem_btn, $GUI_DISABLE)
                    GUICtrlSetState($CreateOrders_btn, $GUI_DISABLE)
                EndIf
            Case $CreateOrders_btn
                GUICtrlSetState($CreateOrders_btn, $GUI_DISABLE)
                GUICtrlSetState($RemoveItem_btn, $GUI_DISABLE)
                GUICtrlSetState($AddItem_btn, $GUI_DISABLE)
                GUICtrlSetState($Item_Number_Input, $GUI_DISABLE)
                GUICtrlSetState($Quantity_Input, $GUI_DISABLE)
                GUICtrlSetState($Shop_Combo, $GUI_DISABLE)
                GUICtrlSetState($GetLastVend_btn, $GUI_DISABLE)
                For $x = 0 To UBound($ListViewItems) - 1
                    If $ListViewItems[$x][4] = "Need" Then
                        GUICtrlSetData($ListViewItems[$x][0], $ListViewItems[$x][1] & "|" & $ListViewItems[$x][2] & "|" & $ListViewItems[$x][3] & "|" & "Getting Last Vendor...")
                        $lastvend = Get_Last_Vendor_Ordered($ListViewItems[$x][1])
                        If $lastvend = False Then
                            $lastvend = "Unknown"
                        EndIf
                        $ListViewItems[$x][4] = $lastvend
                        GUICtrlSetData($ListViewItems[$x][0], $ListViewItems[$x][1] & "|" & $ListViewItems[$x][2] & "|" & $ListViewItems[$x][3] & "|" & $ListViewItems[$x][4])
                        If $lastvend = "Unknown" Then
                            GUICtrlSetBkColor($ListViewItems[$x][0], (0xFF0000))
;~                          GUICtrlSetData($ListViewItems[$x][0], $ListViewItems[$x][1] & ": Cannot find vendor, enter order manually" & "|" & $ListViewItems[$x][2] & "|" & $ListViewItems[$x][3] & "|" & $ListViewItems[$x][4])
;~                          GUICtrlSetTip($ListViewItems[$x][0], "Cannot find vendor, must enter order manually.")
                        Else
                            GUICtrlSetBkColor($ListViewItems[$x][0], (0x00FF00))
                        EndIf
                    EndIf
                Next
                ;BEGIN SORTING ARRAY
                ;WE MUST CREATE AN ADDITIONAL DIMENSION TO SORT ON BASED UPON VENDOR AND SHOP
                Local $orderarray = $ListViewItems
                ReDim $ListViewItems[UBound($ListViewItems)][6]
                For $x = 0 To UBound($ListViewItems) - 1
                    $ListViewItems[$x][5] = $ListViewItems[$x][4] & $ListViewItems[$x][3]
                Next
                _ArraySort($ListViewItems, 0, 0, 0, 5)
;~              ReDim $ListViewItems[UBound($ListViewItems)][5]
;~              _ArrayDisplay($ListViewItems)
                ;END SORTING OF ARRAY
                For $x = 0 To UBound($ListViewItems) - 1
                    GUICtrlSetData($orderarray[$x][0], $ListViewItems[$x][1] & "|" & $ListViewItems[$x][2] & "|" & $ListViewItems[$x][3] & "|" & $ListViewItems[$x][4])
                    $ListViewItems[$x][0] = $orderarray[$x][0]
                    If $ListViewItems[$x][4] = "Unknown" Then
                        GUICtrlSetBkColor($ListViewItems[$x][0], (0xFF0000))
;~                      GUICtrlSetData($ListViewItems[$x][0], $ListViewItems[$x][1] & ": Cannot find vendor, enter order manually" & "|" & $ListViewItems[$x][2] & "|" & $ListViewItems[$x][3] & "|" & $ListViewItems[$x][4])
;~                          GUICtrlSetTip($ListViewItems[$x][0], "Cannot find vendor, must enter order manually.")
                    Else
                        GUICtrlSetBkColor($ListViewItems[$x][0], (0x00FF00))
                    EndIf
                Next

                Local $createarray
                Local $badarray
                Local $badcount = 0
                $lastshop = $ListViewItems[0][3]
                $lastvend = $ListViewItems[0][4]
                $last = $ListViewItems[0][5]
                $len = UBound($ListViewItems)
                ReDim $ListViewItems[$len + 1][6]
                $ListViewItems[$len][0] = "Done"
                $count = 0


                For $x = 0 To UBound($ListViewItems) - 1
                    If $ListViewItems[$x][4] = "Unknown" Then
                        If Not IsArray($badarray) Then Local $badarray[1][3]
                        If $badcount + 1 > UBound($createarray) Then ReDim $badarray[$badcount + 1][3]
                        $badarray[$badcount][0] = $ListViewItems[$x][1]
                        $badarray[$badcount][1] = $ListViewItems[$x][2]
                        $badarray[$badcount][2] = $ListViewItems[$x][3]
                        $badcount += 1
;~                          _ArrayDisplay($badarray)
                    ElseIf $ListViewItems[$x][5] = $last Then
                        If Not IsArray($createarray) Then Local $createarray[1][2]
                        If $count + 1 > UBound($createarray) Then ReDim $createarray[$count + 1][2]
                        $createarray[$count][0] = $ListViewItems[$x][1]
                        $createarray[$count][1] = $ListViewItems[$x][2]
                        $count += 1
;~                      _ArrayDisplay($createarray)
                    ElseIf $ListViewItems[$x][0] = "Done" Then
                        Create_Purchase_Order($lastshop, $lastvend, "SHIP ASAP.  THANKS!", $createarray)
                        $ttlqty = 0
                        For $v = 0 To UBound($createarray) - 1
                            $ttlqty += Int($createarray[$v][1])
                        Next
                        $verify = Verify_Order($lastvend, $ttlqty)
;~                      If $verify = False Then
;~                          MsgBox(0, "ORDER ERROR", "The purchase order for " & $lastvend & " could not be verified")
;~                          Exit
;~                      EndIf
                        ;ADDING IN VERIFY CHANGE HERE
                        If $verify = False Then
                            $oPO_Form = _IEFormGetObjByName($Location_Frame, "purchaseOrderForm")

                            $elements = _IEFormElementGetCollection($oPO_Form)
                            For $element In $elements
                                If StringInStr($element.value, "Add") > 0 Then
                                    $button = $element
                                EndIf
                            Next

                            _IEAction($button, "click")
                            _IELoadWait($Location_Frame)

                            $neworderForm = _IEFormGetObjByName($Location_Frame, "receiptForm")
                            $elements = _IEFormElementGetCollection($neworderForm)

                            For $element In $elements
                                If StringInStr($element.name, "arPartNumber[" & $x & "]") > 0 Then
                                    $partform = $element
                                    $focuselement1 = $element
                                ElseIf StringInStr($element.name, "arDescription[" & $x & "]") > 0 Then
                                    $focuselement2 = $element
                                ElseIf StringInStr($element.name, "arPartLocationID[" & $x & "]") > 0 Then
                                    $partlocationform = $element
                                ElseIf StringInStr($element.name, "arQuantity[" & $x & "]") > 0 Then
                                    $qtyform = $element
                                ElseIf StringInStr($element.name, "arPromiseDate[" & $x & "]") > 0 Then
                                    $dateform = $element
                                EndIf
                            Next

                            For $x = 1 To UBound($createarray)
                                _IEFormElementOptionselect($partlocationform, StringRight($lastshop, 1), 1, "byText", 1)
                            Next

                            For $element In $elements
                                If StringInStr($element.value, "Submit") > 0 Then
                                    $button = $element
                                EndIf
                            Next
                            _IEAction($button, "click")
                            _IELoadWait($Location_Frame)

                            $verify = Verify_Order($lastvend, $ttlqty)
                            If $verify = False Then
                                MsgBox(0, "ORDER ERROR", "The purchase order for " & $lastvend & " could not be verified")
                                Exit

                            EndIf
                        EndIf
                        ;ABOVE IS VERIFY CHANGE
                        Email_Order($verify, $lastvend)
                        For $v = 0 To UBound($createarray) - 1
                            _ArrayDelete($createarray, $v)
                        Next
                        ReDim $ListViewItems[$len][6]
                        If IsArray($badarray) Then
                            MsgBox(48, "WARNING: Not Ordered", "The items on the next chart could not be " & @CRLF & "ordered because no last vendor was available.")
                            _ArrayDisplay($badarray, "No Vendor/Bad Part Number")
                            For $v = 0 To UBound($badarray) - 1
                                _ArrayDelete($badarray, $v)
                            Next
                        EndIf
                    Else;If $ListViewItems[$x][5] = Not $last Then
                        Create_Purchase_Order($lastshop, $lastvend, "SHIP ASAP.  THANKS!", $createarray)
                        $ttlqty = 0
                        For $v = 0 To UBound($createarray) - 1
                            $ttlqty += Int($createarray[$v][1])
                        Next
                        $verify = Verify_Order($lastvend, $ttlqty)
;~                      If $verify = False Then
;~                          MsgBox(0, "ORDER ERROR", "The purchase order for " & $lastvend & " could not be verified")
;~                          Exit
;~                      EndIf
                        ;ADDING IN VERIFY CHANGE HERE
                        If $verify = False Then
                            $oPO_Form = _IEFormGetObjByName($Location_Frame, "purchaseOrderForm")

                            $elements = _IEFormElementGetCollection($oPO_Form)
                            For $element In $elements
                                If StringInStr($element.value, "Add") > 0 Then
                                    $button = $element
                                EndIf
                            Next

                            _IEAction($button, "click")
                            _IELoadWait($Location_Frame)

                            $neworderForm = _IEFormGetObjByName($Location_Frame, "receiptForm")
                            $elements = _IEFormElementGetCollection($neworderForm)

                            For $element In $elements
                                If StringInStr($element.name, "arPartNumber[" & $x & "]") > 0 Then
                                    $partform = $element
                                    $focuselement1 = $element
                                ElseIf StringInStr($element.name, "arDescription[" & $x & "]") > 0 Then
                                    $focuselement2 = $element
                                ElseIf StringInStr($element.name, "arPartLocationID[" & $x & "]") > 0 Then
                                    $partlocationform = $element
                                ElseIf StringInStr($element.name, "arQuantity[" & $x & "]") > 0 Then
                                    $qtyform = $element
                                ElseIf StringInStr($element.name, "arPromiseDate[" & $x & "]") > 0 Then
                                    $dateform = $element
                                EndIf
                            Next

                            For $x = 1 To UBound($createarray)
                                _IEFormElementOptionselect($partlocationform, StringRight($lastshop, 1), 1, "byText", 1)
                            Next

                            For $element In $elements
                                If StringInStr($element.value, "Submit") > 0 Then
                                    $button = $element
                                EndIf
                            Next
                            _IEAction($button, "click")
                            _IELoadWait($Location_Frame)

                            $verify = Verify_Order($lastvend, $ttlqty)
                            If $verify = False Then
                                MsgBox(0, "ORDER ERROR", "The purchase order for " & $lastvend & " could not be verified")
                                Exit

                            EndIf
                        EndIf
                        ;ABOVE IS VERIFY CHANGE
                        Email_Order($verify, $lastvend)
                        $count = 0
                        For $v = 0 To UBound($createarray) - 1
                            _ArrayDelete($createarray, $v)
                        Next
                        $lastshop = $ListViewItems[$x][3]
                        $lastvend = $ListViewItems[$x][4]
                        $last = $ListViewItems[$x][5]
                        If Not IsArray($createarray) Then Local $createarray[1][2]
                        If $count + 1 > UBound($createarray) Then ReDim $createarray[$count + 1][2]
                        $createarray[$count][0] = $ListViewItems[$x][1]
                        $createarray[$count][1] = $ListViewItems[$x][2]
                        $count += 1
;~                      _ArrayDisplay($createarray)
                    EndIf
                Next
                If $fax_array[0] > 0 Then
                    _ArrayDisplay($fax_array, "These orders could not be emailed")
                EndIf
                WinActivate("SAM Order Entry")
;~              GUICtrlSetState($CreateOrders_btn, $GUI_ENABLE)
;~              GUICtrlSetState($RemoveItem_btn, $GUI_ENABLE)
                GUICtrlSetState($Item_Number_Input, $GUI_ENABLE)
                GUICtrlSetState($Quantity_Input, $GUI_ENABLE)
                GUICtrlSetState($Shop_Combo, $GUI_ENABLE)
;~              GUICtrlSetState($GetLastVend_btn, $GUI_ENABLE)
            Case $GetLastVend_btn
                GUICtrlSetState($CreateOrders_btn, $GUI_DISABLE)
                GUICtrlSetState($RemoveItem_btn, $GUI_DISABLE)
                GUICtrlSetState($AddItem_btn, $GUI_DISABLE)
                GUICtrlSetState($Item_Number_Input, $GUI_DISABLE)
                GUICtrlSetState($Quantity_Input, $GUI_DISABLE)
                GUICtrlSetState($Shop_Combo, $GUI_DISABLE)
                GUICtrlSetState($GetLastVend_btn, $GUI_DISABLE)
                For $x = 0 To UBound($ListViewItems) - 1
                    If $ListViewItems[$x][4] = "Need" Then
                        GUICtrlSetData($ListViewItems[$x][0], $ListViewItems[$x][1] & "|" & $ListViewItems[$x][2] & "|" & $ListViewItems[$x][3] & "|" & "Getting Last Vendor...")
                        $lastvend = Get_Last_Vendor_Ordered($ListViewItems[$x][1])
                        If $lastvend = False Then
                            $lastvend = "Unknown"
                        EndIf
                        $ListViewItems[$x][4] = $lastvend
                        GUICtrlSetData($ListViewItems[$x][0], $ListViewItems[$x][1] & "|" & $ListViewItems[$x][2] & "|" & $ListViewItems[$x][3] & "|" & $ListViewItems[$x][4])
                        If $lastvend = "Unknown" Then
                            GUICtrlSetBkColor($ListViewItems[$x][0], (0xFF0000))
;~                          GUICtrlSetData($ListViewItems[$x][0], $ListViewItems[$x][1] & ": Cannot find vendor, enter order manually" & "|" & $ListViewItems[$x][2] & "|" & $ListViewItems[$x][3] & "|" & $ListViewItems[$x][4])
;~                          GUICtrlSetTip($ListViewItems[$x][0], "Cannot find vendor, must enter order manually.")
                        Else
                            GUICtrlSetBkColor($ListViewItems[$x][0], (0x00FF00))
                        EndIf
                    EndIf
                Next
                GUICtrlSetState($CreateOrders_btn, $GUI_ENABLE)
                GUICtrlSetState($RemoveItem_btn, $GUI_ENABLE)
                GUICtrlSetState($Item_Number_Input, $GUI_ENABLE)
                GUICtrlSetState($Quantity_Input, $GUI_ENABLE)
                GUICtrlSetState($Shop_Combo, $GUI_ENABLE)
                GUICtrlSetState($GetLastVend_btn, $GUI_ENABLE)
            Case $GUI_EVENT_CLOSE
                GUIDelete($Form1_1_1)
                Return
        EndSwitch
    WEnd


EndFunc   ;==>Create_Item_Array
Edited by Affe

[center][/center]

Link to comment
Share on other sites

  • Moderators

DjATUit,

OK, ignore me! ;)

I think this is a "relative" as I can get tonight! :)

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

Global $iGUI_InitWidth = 500, $iGUI_InitHeight = 500
Global $iLV_InitX = 50, $iLV_InitY = 20, $iLV_InitW = 300, $iLV_InitH = 300

$hGUI = GUICreate("Test", $iGUI_InitWidth, $iGUI_InitHeight, -1, -1, $WS_SIZEBOX)
GUISetBkColor(0xFF0000, $hGUI)

$hListView = _GUICtrlListView_Create($hGUI, "Header", $iLV_InitX, $iLV_InitY, $iLV_InitW, $iLV_InitH)

GUISetState()

GUIRegisterMsg($WM_SIZE, "MY_WM_SIZE")

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

WEnd

Func MY_WM_SIZE($hWnd, $Msg, $wParam, $lParam)

    Local $nCoeffW = BitAND($lParam, 0xFFFF) / $iGUI_InitWidth
    Local $nCoeffH = BitShift($lParam, 16) / $iGUI_InitHeight

    Local $iX = Int($iLV_InitX * $nCoeffW)
    Local $iY = Int($iLV_InitY * $nCoeffH)
    Local $iW = Int($iLV_InitW * $nCoeffW)
    Local $iH = Int($iLV_InitH * $nCoeffH)

    WinMove($hListView, "", $iX, $iY, $iW, $iH)

    Return $GUI_RUNDEFMSG

EndFunc   ;==>MY_WM_SIZE

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

Melba,

Ace that works!

It's alright, i know what you mean. I've got to go know, before I get like that! ;)

But Thanks, I've got a solution now!

The rest of you,

Thank you for your reply, they were helpful and I will review them when I get another chance!

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