Jump to content
Sign in to follow this  
steve8tch

List Box - Horizontal Scroll Bar

Recommended Posts

I would like to enable a horizontal scroll for a list box.

I can't!!

According to the help file I should be able to

GUISetControlEx ( controlref, state [,resizing [,tip [,ext1 [,background]]]])
[ext1] for listboxes it is the extent you can scroll Horz. in pixels. 
for progress/label control color of the control

I have enclosed the code from a previous 'list' box example - with a couple of modifications to highlight the problem.

Global $message = "The following buttons have been clicked - you can't see all this line in the list box"
Global $message_end = "" 
GUICreate("My GUI")

$button1=GUISetControl("button", "Button1", 64,32,75,25)
GUISetControlNotify()
$button2=GUISetControl("button", "Button2", 64,72,75,25)
GUISetControlNotify()
$mylist=GUISetControl("list", "buttons that have been clicked", 176,32,121,97)
GUISetControlEx(-1,-1,-1,"I am trying to generate a horizontal scroll bar in a list box",50)
GUISetControlData(-1,$message)
GUISetControlNotify()
$close=GUISetControl("button", "my closing button", 64,160,175,25)
GUISetControlNotify()

While GUIMsg() > 0 
   If GUIRead() = $button1 Then
      $message = $message & "|" & "You clicked button No1"
      GuiSetControlData($mylist,"")
      GuiSetControlData($mylist,$message)
   EndIf
   If GUIRead() = $button2 Then 
      $message = $message & "|" & "You clicked button No2"
      GuiSetControlData($mylist,"")
      GuiSetControlData($mylist,$message)
   EndIf
   If GUIRead() = $close Then
      extract_data_from_GUIRead()
      MsgBox(0,"data", $message_end)
      Exit
      
   EndIf
   
Wend

Func extract_data_from_GUIRead()
   $x = 1
   $message1 = ""
   Do
      $x = StringInStr($message,"|")
      $message_end = $message_end & @CRLF & StringLeft($message,$x - 1)
      $message = StringTrimLeft($message,$x)
      If $x = 0 Then $message_end = $message_end & $message
   Until $x = 0
EndFunc  ;==>extract_data_from_GUIRead

Can anyone help!!

please :D

ps

Possible bug.

If you add a value eg *.tmp - the list box seems to chop off the first '*' at the beginning and it just display '.tmp'

If you added ***.tmp - you get '**.tmp' displayed.

You can try this in the above code by changing

"You clicked button No1" for "*.tmp"

"You clicked button No2" for "***.tmp"

Thanks in advance for any help

Share this post


Link to post
Share on other sites

I copy the code from AU3GUI I never thought what is the way to use it.

I will have a look to your example

Stay tune

Share this post


Link to post
Share on other sites

JUst 2 line correction to your script.

$mylist=GUISetControl("list", "buttons that have been clicked", 176,32,121,97,$WS_VSCROLL+$WS_HSCROLL )
GUISetControlEx(-1,-1,-1,"I am trying to generate a horizontal scroll bar in a list box",300)

You need to add WS_HSCROLL and to define a number of pixel greater that your list width. :D

Share this post


Link to post
Share on other sites

I will look at this tonight - many thanks

any thoughts about the missing asterix '*' .

Is it there but hiding :D or has it done a runner :huh2:

Thanks again

Share this post


Link to post
Share on other sites

I will look at this tonight - many thanks

any thoughts about the missing asterix '*'  .

Is it there but hiding  :D  or has it done a runner :huh2:

Thanks again

a data starting with * means the value will be the default value. The first * is not part of the value and will be removed. So you need not to start with a * .

Perhaps you can add an extra blank before all your values

Share this post


Link to post
Share on other sites

Thanks - this works - but then another thing cropped up.

The appearance of the text in the list box changed - It seems to be using a different font size. When I change the font - the whole appearance of the text seems to change. Do you know if this behaviour is expected.

The code below shows the problem.

Global $message1 = "The following buttons have been clicked - you can't see all this line in the list box"
Global $message2 = "The following buttons have been clicked - you can't see all this line in the list box"
Global $WS_HSCROLL = 1048576
Global $WS_VSCROLL = 2097152
GUICreate("My GUI")

$button1=GUISetControl("button", "Button1", 64,32,75,25)
GUISetControlNotify()
$button2=GUISetControl("button", "Button2", 64,72,75,25)
GUISetControlNotify()
$mylist=GUISetControl("list", "text style one", 176,32,121,97)
GUISetControlEx(-1,-1,-1,"No horizontal scroll configured",50)
GUISetControlData(-1,$message1)
GUISetControlNotify()
$mylist2=GUISetControl("list", "text style one", 176,160,121,140,$WS_HSCROLL + $WS_VSCROLL)
GUISetControlEx(-1,-1,-1,"horizontal scroll configured - but appearance of text has channged",600)
GUISetControlData(-1,$message2)
GUISetControlNotify()
$close=GUISetControl("button", "Close", 64,160,75,50)
GUISetControlNotify()

While GUIMsg() > 0 
   If GUIRead() = $button1 Then
      $message1 = $message1 & "|" & "text style one"
      GuiSetControlData($mylist,"")
      GuiSetControlData($mylist,$message1)
   EndIf
   If GUIRead() = $button2 Then 
      $message2 = $message2 & "|" & "text style two"
      GuiSetControlData($mylist2,"")
      GuiSetControlData($mylist2,$message2)
   EndIf
   If GUIRead() = $close Then
      MsgBox(0,"data", "Did you see the diffence in text styles" & @CRLF & "Was this expected ?")
      Exit
   EndIf
Wend

Thanks again for all your work.

Edited by steve8tch

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...