Sign in to follow this  
Followers 0
xeroTechnologiesLLC

[Resolved] difficulty with guisetstyle and guictrlcreatelist

7 posts in this topic

#1 ·  Posted (edited)

Good weekend everyone,

I am experimenting with the _draglist_UDF (which is awesome, by the way) and found a small problem with using it and $LBS_MULTIPLESEL style.

The fix, in theory, is to turn it off when the user 'toggles' the arrange check box then turn it back on when they toggle that off.

I'm having problems getting the style to change correctly and take so that the item in the list box can be highlighted again after the toggle is off.

Some code borrowed from the draglist_udf example and modified in a rather failed attempt to change styles:

#include <GuiConstantsEx.au3>
#include <Constants.au3>
#include <DragList_UDF.au3>
#include <ListboxConstants.au3>
#include <WinAPI.au3>
Global $mSelOff = BitOR($LBS_NOTIFY,$WS_VSCROLL,$WS_BORDER)
Global $mSelOn = BitOR($LBS_NOTIFY,$LBS_MULTIPLESEL,$WS_VSCROLL,$WS_BORDER)
;~ MsgBox(0, "", VarGetType($mSelOff))
;~ Exit
$hGUI = GUICreate("_DragList_... Demo", 400, 200)
$nList1 = GUICtrlCreateList("", 20, 10, 160, 140, $WS_BORDER+$WS_VSCROLL)
GUICtrlSetData($nList1, "Hi,|How|Are|You?")
$nList2 = GUICtrlCreateList("", 220, 10, 160, 140, $mSelOn)
GUICtrlSetData($nList2, "AutoIt|Is|The|Best!")
$nList2_handle = GUICtrlGetHandle(-1)
$SetList1_CheckBox = GUICtrlCreateCheckBox("Set List 1", 60, 160, 70, 20)
$SetList2_CheckBox = GUICtrlCreateCheckBox("Set List 2", 260, 160, 70, 20)
GUISetState(@SW_SHOW)
$iStyle = _WinAPI_GetWindowLong($nList2_handle, $GWL_STYLE)
MsgBox(0, "starting style with multiselect on", "0x" & Hex($iStyle, 8))
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $SetList1_CheckBox
If GUICtrlRead($SetList1_CheckBox) = $GUI_CHECKED Then
_DragList_SetList($nList1, $hGUI)
Else
_DragList_SetList($nList1)
EndIf
Case $SetList2_CheckBox
If GUICtrlRead($SetList2_CheckBox) = $GUI_CHECKED Then
GUICtrlSetStyle($nList2, BitXOR($iStyle, $LBS_MULTIPLESEL))
$iStyle = _WinAPI_GetWindowLong($nList2_handle, $GWL_STYLE)
     MsgBox(0, "remove multiselect", "0x" & Hex($iStyle, 8))
_DragList_SetList($nList2, $hGUI)
Else
$iStyle = _WinAPI_GetWindowLong($nList2_handle, $GWL_STYLE)
     MsgBox(0, "readd multiselect", "0x" & Hex($iStyle, 8))
GUICtrlSetStyle($nList2, BitOR($iStyle, $LBS_MULTIPLESEL))
_DragList_SetList($nList2)
EndIf
EndSwitch
Wend

I am extremely green when it comes to modifying styles on the fly. The worst I've had to do to date was a simple GUI form style change for a log in credential box and then the form was reset with ease. I have not tried modifying styles on a control before so I'm not sure if what I am attempting here is even the correct path; I was simply trying to follow the wiki example without much further knowledge:

http://www.autoitscript.com/wiki/Setting_Styles

Any advisement on direction on this would be extremely helpful...or if another work around for the draglist_UDF and multisel option is known; that would be helpful as well.

I hope everyone is having a great weekend and thank you in advance for any help advised.

Edited by xeroTechnologiesLLC

Share this post


Link to post
Share on other sites



xeroTechnologiesLLC,

Where is DragList_UDF.au3? :huh:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Hey Melba, :bye:

Are you referencing to its physical hard drive location?

If yes - with the other includes in the main includes directory. (in my case on my work network drive in the autoIT installation directory)

Otherwise, not 100% sure to what level of 'where' you are referencing?

Sorry, mornings aren't my thing still. LOL -_-

Share this post


Link to post
Share on other sites

I think the main issue I am having is simply altering the style of the list more so than anything to do with the draglist.

I'm trying style alteration without anything to do with the drag list and I am still not getting the desired effect...

#include <GuiConstantsEx.au3>
#include <Constants.au3>
#include <DragList_UDF.au3>
#include <ListboxConstants.au3>
#include <WinAPI.au3>
Global $mSelOff = BitOR($LBS_NOTIFY,$WS_VSCROLL,$WS_BORDER)
Global $mSelOn = BitOR($LBS_NOTIFY,$LBS_MULTIPLESEL,$WS_VSCROLL,$WS_BORDER)
;~  MsgBox(0, "", VarGetType($mSelOff))
;~  Exit
$hGUI = GUICreate("_DragList_... Demo", 400, 200)

$nList2 = GUICtrlCreateList("", 220, 10, 160, 140, $mSelOff)
GUICtrlSetData($nList2, "AutoIt|Is|The|Best!")
$nList2_handle = GUICtrlGetHandle(-1)
$SetList2_CheckBox = GUICtrlCreateCheckBox("Set List 2", 260, 160, 70, 20)
GUISetState(@SW_SHOW)
$iStyle   = _WinAPI_GetWindowLong($nList2_handle, $GWL_STYLE)
MsgBox(0, "starting style with multiselect off", "0x" & Hex($iStyle, 8))
While 1
Switch GUIGetMsg()
  Case $GUI_EVENT_CLOSE
   Exit
  Case $SetList2_CheckBox
   If GUICtrlRead($SetList2_CheckBox) = $GUI_CHECKED Then
    $iStyle   = _WinAPI_GetWindowLong($nList2_handle, $GWL_STYLE)
     GUICtrlSetStyle($nList2, BitOR($iStyle, $mSelOn))
    $iStyle   = _WinAPI_GetWindowLong($nList2_handle, $GWL_STYLE)
     MsgBox(0, "readd multiselect", "0x" & Hex($iStyle, 8))
   Else
;~   _DragList_SetList($nList2)
   EndIf
EndSwitch
Wend

The hex appears to change to the correct hex value expected, but I am unable to actually multiselect the items in the list and I believe that to be where my main fault in coding is at.

Thoughts?

Share this post


Link to post
Share on other sites

xeroTechnologiesLLC,

I was asking where you had found the code for the UDF, not where you had put it. ;)

It seems from my experimentation as if this style is one of those you cannot change dynamically. :(

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

It appears that the list control is one of the few controls that you can't change the style of dynamically perhaps.

I took out all the drag_UDF items and broke it down to basically create the gui then attempt to change the style in various different ways and it isn't working so..

I would theorize my only option is to destroy the control completely, rebuild it with the new style, do what i need to do, then redestroy it and rebuild it again with the other style?

Have to move on from this bug on to others and i'll ponder it through the weekend and keep doing some research, but so far i am not finding a way around this.

#include <GuiConstantsEx.au3>
#include <Constants.au3>
#include <ListboxConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
Global $mSelOff = BitOR($LBS_NOTIFY,$WS_VSCROLL,$WS_BORDER)
Global $mSelOn = BitOR($LBS_NOTIFY,$LBS_MULTIPLESEL,$WS_VSCROLL,$WS_BORDER)
;~ MsgBox(0, "", VarGetType($mSelOff))
;~ Exit
$hGUI = GUICreate("_DragList_... Demo", 400, 200)
$nList2 = GUICtrlCreateList("", 220, 10, 160, 140, $mSelOff)
GUICtrlSetData($nList2, "AutoIt|Is|The|Best!")
$nList2_handle = GUICtrlGetHandle(-1)
$SetList2_CheckBox = GUICtrlCreateCheckBox("Set List 2", 260, 160, 70, 20)
GUISetState(@SW_SHOW)
Sleep(1000)
$iStyle = _WinAPI_GetWindowLong($nList2_handle, $GWL_STYLE)
GUICtrlSetStyle($nList2, BitOR($iStyle, $LBS_MULTIPLESEL))

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
Wend

Melba,

if you happen to find any other documentation on it, feel free to turn me in that direction and boot to ascii me and I'll check further into it, but I could find very little on the topic other than what I linked above, however thank you for whatever time you do allocate on the subject.

Thanks.

edit:

posted same time you did Melba >< lol

looks like we came to the same conclussion

Edited by xeroTechnologiesLLC

Share this post


Link to post
Share on other sites

This is dirty, but works...kind of like my little electric lawn mower...

But anyway, all it does is create the control with the mulstiselect on...delete it and rebuild it with the multiselect off when the toggle is turned on, or check box 'checked', then when they toggle it off, or uncheck it, takes the data out of the box, assigns it to an array, then arranges to a string for the data reentry, rebuilds the control, sets the data, good to go.

Again, very dirty, but probably the best work around i can come up with at the moment unless any other options are noted...

#include <array.au3>
#include <GuiConstantsEx.au3>
#include <DragList_UDF.au3>
Global $tempstr = ""
$hGUI = GUICreate("_DragList_... Demo", 400, 200)
$nList1 = GUICtrlCreateList("", 20, 10, 160, 140, $WS_BORDER+$WS_VSCROLL)
GUICtrlSetData($nList1, "Hi,|How|Are|You?")
$nList2 = GUICtrlCreateList("", 220, 10, 160, 140, BitOR($LBS_NOTIFY,$LBS_MULTIPLESEL,$WS_VSCROLL,$WS_BORDER))
GUICtrlSetData($nList2, "AutoIt|Is|The|Best!")
$SetList1_CheckBox = GUICtrlCreateCheckBox("Set List 1", 60, 160, 70, 20)
$SetList2_CheckBox = GUICtrlCreateCheckBox("Set List 2", 260, 160, 70, 20)
GUISetState(@SW_SHOW)
While 1
Switch GUIGetMsg()
  Case $GUI_EVENT_CLOSE
   Exit
  Case $SetList1_CheckBox
   If GUICtrlRead($SetList1_CheckBox) = $GUI_CHECKED Then
    _DragList_SetList($nList1, $hGUI)
   Else
    _DragList_SetList($nList1)
   EndIf
  Case $SetList2_CheckBox
   If GUICtrlRead($SetList2_CheckBox) = $GUI_CHECKED Then
    _destroy_list2()
    _rebuild_list2_wo_ms()
    _DragList_SetList($nList2, $hGUI)
   Else
    _get_list_data()
    _destroy_list2()
    _rebuild_list2_w_ms()
   EndIf
EndSwitch
Wend
Func _destroy_list2()
GUICtrlDelete($nList2)
EndFunc
Func _rebuild_list2_wo_ms()
$nList2 = GUICtrlCreateList("", 220, 10, 160, 140, BitOR($LBS_NOTIFY,$WS_VSCROLL,$WS_BORDER))
  GUICtrlSetData($nList2, "AutoIt|Is|The|Best!")
EndFunc
Func _rebuild_list2_w_ms()
$nList2 = GUICtrlCreateList("", 220, 10, 160, 140, BitOR($LBS_NOTIFY,$LBS_MULTIPLESEL,$WS_VSCROLL,$WS_BORDER))
  GUICtrlSetData($nList2, $tempstr)
EndFunc
Func _get_list_data()
$l2_count = _GUICtrlListBox_GetCount($nList2)
;~   MsgBox(0, "", $l2_count)
Dim $temp_array[$l2_count] = [$l2_count - 1]
For $a = 0 To $l2_count - 1
  $temp_array[$a] = _GUICtrlListBox_GetText($nList2, $a)
Next
;~   _ArrayDisplay($temp_array)
$tempstr = ""
For $a = 0 To $l2_count - 1
  If $a <> $l2_count - 1 Then
   $tempstr &= $temp_array[$a] & "|"
  Else
   $tempstr &= $temp_array[$a]
  EndIf
Next
;~   MsgBox(0, "", $tempstr)
EndFunc

Hopefully this will help others who are trying to dynamically alter list styles.

Melba, as always, thank you for your valuable time!

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  
Followers 0