Sign in to follow this  
Followers 0
CyberSlug

Some GuiSendMsg wrappers

17 posts in this topic

#1 ·  Posted (edited)

Here is a partial list for listbox controls..... more later...

Original Post on 8 Jun2004, 04:39 PM

Updated on 8 Jun 2004, 10:13 PM

Bugfix on 8 Jun 2004, 10:37 PM--_GuiLB_GetSelItemsText For-loop bounds were wrong :D

Updated 9 June 2004, 10:43 PM--some additional functions

Here: http://www.autoitscript.com/fileman/users/public/CyberSlug/GuiMsgWrappers.au3

Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites



http://www.autoitscript.com/fileman/users/jpm/Misc/eusa_clap.gifhttp://www.autoitscript.com/fileman/users/jpm/Misc/eusa_clap.gif

Share this post


Link to post
Share on other sites

:D We can now get all selected items in a multiple-selection list box! Above code contains an example :huh2:

http://msdn.microsoft.com/library/default....stBoxStyles.asp

$LBS_EXTENDEDSEL = 0x0800;

Allows multiple items to be selected by using the SHIFT key and the mouse or special key combinations.

$LBS_MULTIPLESEL = 0x0008;

Turns string selection on or off each time the user clicks or double-clicks a string in the list box. The user can select any number of strings.


Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

Yeah, I tried the last style in your last post earlier.

Here's what I did:

- create a msgbox: MsgBox(0, "Test", GUIRead($list_1))

- create a button

- start script

- Select multiple items

- click on the button

Result:

- Msgbox only shows the value of the last clicked item (whether selected or not)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Since my first post is getting long, I'll probably change it to a link to the code.

Anyway, here's a the list. Is any useful function missing?

Edit: List removed because it appears in jpm's next post :D Reduces the amount of scrollling you need td do.

Disclaimer: I've only done minimal testing with Windows XP, and the Win32 message reference I'm using was written for Windows 95/NT4.

Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

Since my first post is getting long, I'll probably change it to a link to the code.

Anyway, here's a the list.  Is any useful function missing?

AddString

DeleteString

FindString

FindStringExact

GetAnchorIndex

GetCaretIndex

GetCount

GetCurSel

GetSelCount

GetSelItems

GetSelItemsText

GetSelState

GetText

GetTopIndex

InsertString

ResetContent

ReplaceString

SelectString

SelItemRange

SelItemRangeEx

SetSel

SetTopIndex

Sort

SwapString

Disclaimer:  I've only done minimal testing with Windows XP, and the Win32 message reference I'm using was written for Windows 95/NT4.

in case you run out of oil i put the complete list I think of what can be wrapped :D

Share this post


Link to post
Share on other sites

in case you run out of oil i put the  complete list I think of what can be wrapped :D

Thanks--that will help!

By the way, I've purposely skipped messages like LB_GETLOCALE and LB_SETHORIZONTALEXTENT because they don't seem very useful to me :huh2:

I think I'll work on the input/edit messages then tab messages next.


Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

I hate to scroll 6 times to skip one post.

Can you please upload the script somewhere?

Thank you.

Share this post


Link to post
Share on other sites

Thanks--that will help!

By the way, I've purposely skipped messages like LB_GETLOCALE and LB_SETHORIZONTALEXTENT because they don't seem very useful to me :D

I think I'll work on the input/edit messages then tab messages next.

I can agree. I did not conduct an analysis of what is useful but what can be done with the autoIt3 wraper I did :huh2:

Share this post


Link to post
Share on other sites

GUI wrappers are still on my TO-DO list... I hope this unfinished code will encourage me to upload a completed version soon...

EM_Messages (Input and Edit controls)

Dim $GUI_WRAP = 0x50300104, $GUI_NO_WRAP = 0x50200104
Opt("GUINotifyMode", 1)
GuiCreate("MyGUI", 392,273,(@DesktopHeight-392)/2, (@DesktopHeight-273)/2 , 0x04CF0000)
$edit_1 = GUISetControl("edit", "Edit 1" & @CRLF & "line2", 10, 10, 200, 150);, $GUI_NO_WRAP)
$input_1 = GUISetControl("input", "Input 1", 10, 180, 200, 20)
$button_1 = GUISetControl("button", "Button 1", 20, 220, 170, 40)


If 1=1 Then
   Global $EM_GETSEL = 0x00B0;
   Global $EM_SETSEL    = 0x00B1;
   Global $EM_GETFIRSTVISIBLELINE = 0x00CE;
   Global $EM_FMTLINES = 0xC8;
   Global $EM_GETLINE = 0xC4;
   Global $EM_GETLINECOUNT = 0xBA;
   Global $EM_SETPASSWORDCHAR = 0xCC;
   Global $EM_LINEFROMCHAR = 0xC9;
EndIf

#cs
   EM_MODIFY ????
   EM_GETPASSWORDCHAR 
#ce

; Returns a two-element array giving the starting and ending position of selected text.
;  If textbox has never been clicked, both array elements will be -1.
Func _GuiEM_GetSel($ref)
   Local $result = GUIRecvMsg($ref, $EM_GETSEL)
   If IsArray($result) Then
      Return $result
   Else
      Local $array[2]
      $array[0] = -1
      $array[1] = -1
      Return $array
   EndIf
EndFunc

; Selects text in the specfied range
; ONLY WORKS IF YOU SET FOCUS ON THE INPUT/EDIT CONTROL BEFORE CALLING
Func _GuiEM_SetSel($ref, $start, $stop)
   Return GuiSendMsg($ref, $EM_SETSEL, $start, $stop)
EndFunc

; For multi-line controls:  Returns zero-based index of first visible line
; For single-line controls:  Returns zero-based index of first visible character
Func _GuiEM_GetFirstVisibleLine($ref)
   Return GuiSendMsg($ref, $EM_GETFIRSTVISIBLELINE, 0, 0)
EndFunc

; DOES NOT AFFECT THE DISPLAY...
Func _GuiEM_FmtLines($ref, $flag)
   GuiSendMsg($ref, $EM_FMTLINES, $flag, 1)
EndFunc

; Returns text of the specified line (without @CR/@LF); line numbers start at zero
Func _GuiEM_GetLine($ref, $line)
   Return GuiRecvMsg($ref, $EM_GETLINE, $line, 1)
EndFunc

; Returns number of lines; an empty edit control still has one line
Func _GuiEM_GetLineCount($ref)
   Return GuiSendMsg($ref, $EM_GETLINECOUNT, 0, 0)
EndFunc

; Set password character for a single-line edit/input; empty string removes password char
; Control is visually updated when it next has focus
Func _GuiEM_SetPasswordChar($ref, $char)
   Return GuiSendMsg($ref, $EM_SETPASSWORDCHAR, Asc($char), 0)
EndFunc

; Returns line# that contains the specified char.index in a multiline edit control
Func _GuiEM_LineFromChar($ref, $index)
   Return GuiSendMsg($ref, $EM_LINEFROMCHAR, $index, 0)
EndFunc

GuiShow()
While 1
   sleep(100)
   $msg = GuiMsg(0)
   Select
   Case $msg = -3
      Exit
   Case $msg = $button_1
     ;ControlFocus("","","Edit1")
     ;MsgBox(4096,"", $var)
      _GuiFocus($edit_1)
     ;$var = _GuiEM_SetSel($edit_1, 1, 6)

     ;;;MsgBox(4096,"info", $var[0] & ", " & $var[1])
   EndSelect
WEnd
Exit


Func _GuiTextBox_Focus($ref)
   Local $state = GUIGetControlState($ref)
   Local $text = GuiRead($ref)
   GUIWrite($ref, BitOr(256,$state));sets focus, but clears contents....
   GuiWrite($ref, $state, $text);re-set state and focus
EndFunc

; Gives the control focus...but selects all text for edit/input controls :mad:
Func _GuiFocus($ref)
  ;GUISetControlEx($ref, BitOr(GUIGetControlState($ref),256))
   $text = GuiRead($ref)
   GuiWrite($ref, 256, '')
   GuiWrite($ref, 0, $text) 
EndFunc

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

A question about this (listbox):

Is there any way for initialize the control with some items selected?

For example: two, four and five items (selected)

Share this post


Link to post
Share on other sites

Do you mean something like this?

Opt("GUINotifyMode", 1)
GuiCreate("MyGUI")

$LBS_EXTENDEDSEL = 0x0800;
$LBS_MULTIPLESEL = 0x0008;
Global $LB_GETCOUNT = 0x018B;
Global $LB_GETSEL = 0x0187;
Global $LB_SETSEL = 0x185;

$list_1 = GUISetControl("list", "List 1", 30, 30, 110, 160, $LBS_MULTIPLESEL)
GuiSetControlData($list_1, "zero|one|two|three|four|five|six|seven")

_GuiLB_SetSel($list_1, 1, 1)
_GuiLB_SetSel($list_1, 1, 2)
_GuiLB_SetSel($list_1, 1, 4)
_GuiLB_SetSel($list_1, 1, 5)

GuiShow()
While GuiMsg(0) <> -3
    sleep(100)
WEnd
Exit


; Set's the selection set of the specified index; $flag == 0 means unselect, $flag == 1 means select
; Perhaps I could also have $flag == 2 to mean toggle.....
; An index of -1 means to apply $flag to all items.
Func _GuiLB_SetSel($ref, $flag, $index)
  If $flag == 2 Then
     If $index == -1 Then
        For $index = 0 To _GuiLB_GetCount($ref)
           If _GuiLB_GetSelState($ref, $index) Then
              GuiSendMsg($ref, $LB_SETSEL, 0, $index)
           Else
              GuiSendMsg($ref, $LB_SETSEL, 1, $index)
           EndIf
        Next
     Else
        If _GuiLB_GetSelState($ref, $index) Then
           Return GuiSendMsg($ref, $LB_SETSEL, 0, $index)
        Else
           Return GuiSendMsg($ref, $LB_SETSEL, 1, $index)
        EndIf
     EndIf
  Else
     Return GuiSendMsg($ref, $LB_SETSEL, $flag, $index)
  EndIf
EndFunc

; Returns number of items in the listbox
Func _GuiLB_GetCount($ref)
 Return GuiSendMsg($ref, $LB_GETCOUNT, 0, 0)
EndFunc

; Returns the selection state of an item at the specified index; 1 == selected, 0 == not , -1 == invalid index
Func _GuiLB_GetSelState($ref, $index)
  Return GuiSendMsg($ref, $LB_GETSEL, $index, 0)
EndFunc

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

Hmm, given my rather lengthy post (due to functions depending on other functions and needing to include the right constants), I think I might develop two sets of libraries:

1) The current implementation where code is designed to re-use other functions and all contstants are declared in one group

2) A new design where each function is entirely self-contained an contains any contants it needs (so you only need to copy the functions you need).


Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

Here's a not-fully-tested-yet http://www.autoitscript.com/fileman/users/public/CyberSlug/lb_wrappers_self-contained.au3 :ph34r:

I've also decided to add wrappers for LB_SETLOCALE and other functions that "don't seem very useful to me"

And I've figured out some uses for LB_SETITEMDATA which I hope to post in an example soon....


Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

I uploaded a list http://www.autoitscript.com/fileman/users/public/CyberSlug/guiDefaultStyles.txt. (Disclaimer: might contain bugs)

It's not exactly related to GuiMsg Wrappers, but I wanted to post this info without starting a new thread. I hope to incorporate this information into AutoBuilder.....

I've also found WinSpy++ and CopyText to be quite useful for style stuff


Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Some GuiSendMsg wrappers for Slider controls (not finished yet): http://www.autoitscript.com/fileman/users/public/CyberSlug/slidermessages.au3

Also, http://www.autoitscript.com/fileman/users/public/CyberSlug/guistyleconstants.au3.

Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

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