AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Detecting last field in listbox

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Phoenix



Joined: 23 Sep 2005
Posts: 39

PostPosted: Sun Nov 04, 2007 2:25 am    Post subject: Detecting last field in listbox Reply with quote

Code:

;----------------------------------------------------------------------
;
; Closes selected window
;
CloseWindow:
guicontrolget, listval,,index
msgbox, %listval%
stringtrimleft, window_id, idarray%listval%, 0
WinClose, ahk_id %window_id%
GoSub, RefreshWindowList
GuiControl, Choose, ListBox1, %listval%
return


I am modifying the incremental task handler to be able to close applications aswell. The behaviour I want is

1. Goto to an entry in the listbox.
2. Press Delete.

This should close the application and move the entries below the closed entry up one level so that the same position in the listbox is stil selected. My code above does exactly this except if I try to close the last application entry in the list. When I try to close the the last application entry the first entry is selected again. This is ofcourse because i removed the last entry and then try to set the current position of the list to the unexisting entry. So My question is: Is there a way to find out if an in an listbox is the last entry (so that I can handle that separatly).

to be able to go to an entry in the list and press delete. This
Back to top
View user's profile Send private message
Gast w/o Nick
Guest





PostPosted: Tue Nov 06, 2007 11:47 am    Post subject: Reply with quote

Quote:
Is there a way to find out if an in an listbox is the last entry (so that I can handle that separatly).


Beeing lazy, I'd just check if the string removed was at the end.
If so, the left part of the string stays the same.
Like this


Code:
;----------------------------------------------------------------------
;
; Closes selected window
;
CloseWindow:
guicontrolget, listval,,index
msgbox, %listval%
x_listval := listval
stringtrimleft, window_id, idarray%listval%, 0
WinClose, ahk_id %window_id%
GoSub, RefreshWindowList

if (listval = substr(x_listval,1,StrLen(listval)))
{
  msgbox, You deleted the last entry. (Put your code in here!)
}
GuiControl, Choose, ListBox1, %listval%
return

Back to top
RGF
Guest





PostPosted: Tue Nov 06, 2007 3:08 pm    Post subject: Reply with quote

Did you try the ListView control?It has many usefull built in functions.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group