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 

LVX: Row highlighting and cell editing for ListView controls
Goto page 1, 2, 3, 4  Next
 
Post new topic   This topic is locked: you cannot edit posts or make replies.    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Titan



Joined: 11 Aug 2004
Posts: 4975
Location: /b/

PostPosted: Wed Dec 12, 2007 9:11 pm    Post subject: LVX: Row highlighting and cell editing for ListView controls Reply with quote

This wraps Micas code for cell editing and evls code for row colouring in an easy to use set of functions.

Example (sorry for lack of imagination -_-'):
Code:
Gui, Add, ListView, w250 r8 vLV_Sample gEditLV Grid, Day|Activity
LV_Add("", "Monday")
LV_Add("", "Tuesday")
LV_Add("", "Wednesday", "pre-set value")
LV_Add("", "Thursday")
LV_Add("", "Friday")
LV_Add("", "Saturday")
LV_Add("", "Sunday")
Loop, 3
   LV_ModifyCol(A_Index, "AutoHdr")

LVX_Setup("LV_Sample")
LVX_SetColour(3, 0xce0000, 0xffffff)

LVX_SetColour(2, 0x008000)
LVX_SetColour(5, 0xff8000, 0xffff00)
LVX_SetColour(6, 0xffffff, 0x0000bb)
LVX_SetColour(7, 0xffffff, 0x0000ff)

Gui, Show, , Test
Return

EditLV:
If A_GuiEvent = DoubleClick
   LVX_CellEdit()
Return

GuiClose:
ExitApp


Produces:


Download with instructions
_________________
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ahklerner



Joined: 26 Jun 2006
Posts: 1317
Location: USA

PostPosted: Wed Dec 12, 2007 9:44 pm    Post subject: Reply with quote

Very cool....

It is hard to read what is being typed on my pc though:

_________________

ʞɔпɟ əɥʇ ʇɐɥʍ
Back to top
View user's profile Send private message
Titan



Joined: 11 Aug 2004
Posts: 4975
Location: /b/

PostPosted: Wed Dec 12, 2007 9:51 pm    Post subject: Reply with quote

Have you customized your font settings? The edit control is set to match the same dimensions of the cell so you could try increasing font size in your script.
_________________
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ahklerner



Joined: 26 Jun 2006
Posts: 1317
Location: USA

PostPosted: Wed Dec 12, 2007 10:02 pm    Post subject: Reply with quote

no font setting changes that i know of. IBM Thinkpad laptop. I made the following changes to my copy of your script:
Code:
...
If i
   {
      Gui, %A_Gui%:Add, Edit, Hwndh ve Hide r1
      h += i := 0
   }
...
Code:

...
   GuiControl, , e, %t%
   GuiControl, Move, e, x%bx% y%by% w%bw% ; h%bh%
   GuiControl, Show, e
...


Last edited by ahklerner on Wed Dec 12, 2007 10:05 pm; edited 1 time in total
Back to top
View user's profile Send private message
ahklerner



Joined: 26 Jun 2006
Posts: 1317
Location: USA

PostPosted: Wed Dec 12, 2007 10:04 pm    Post subject: Reply with quote

Font changes mess it up, though.

Code:
Gui, Font, s12
Gui, Add, ListView, w250 r8 vLV_Sample gEditLV Grid, Day|Activity
LV_Add("", "Monday")
LV_Add("", "Tuesday")
LV_Add("", "Wednesday", "pre-set value")
LV_Add("", "Thursday")
LV_Add("", "Friday")
LV_Add("", "Saturday")
LV_Add("", "Sunday")
Loop, 3
   LV_ModifyCol(A_Index, "AutoHdr")
Gui, Font, s20
Gui, add, Text, , Blah
LVX_Setup("LV_Sample")
...
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 4055
Location: Belgrade

PostPosted: Wed Dec 12, 2007 10:27 pm    Post subject: Reply with quote

If i remember correctly about the original code, it may be hard to get it working with RETURN instead clicking.

also, edit appers on wrong place here - 2 rows bellow.
_________________
Back to top
View user's profile Send private message
Titan



Joined: 11 Aug 2004
Posts: 4975
Location: /b/

PostPosted: Wed Dec 12, 2007 10:47 pm    Post subject: Reply with quote

majkinetor wrote:
If i remember correctly about the original code, it may be hard to get it working with RETURN instead clicking.
You just need a way to break the loop from a different thread when using a hotkey or have the loop check with GetKeyState() and iterate at high frequency. I'll decide on something for next vers.

ahklerner wrote:
Font changes mess it up
majkinetor wrote:
also, edit appers on wrong place here - 2 rows bellow.
Calculating these offsets can be difficult as there are numerous factors that affect the spacing. I'll try fix this too for next time.
_________________
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ahklerner



Joined: 26 Jun 2006
Posts: 1317
Location: USA

PostPosted: Wed Dec 12, 2007 10:49 pm    Post subject: Reply with quote

thx Smile
_________________

ʞɔпɟ əɥʇ ʇɐɥʍ
Back to top
View user's profile Send private message
Guest






PostPosted: Thu Dec 13, 2007 6:48 am    Post subject: Re: LVX: Row highlighting and cell editing for ListView cont Reply with quote

Titan!: s/colour/color/
Back to top
Titan



Joined: 11 Aug 2004
Posts: 4975
Location: /b/

PostPosted: Thu Dec 13, 2007 8:06 am    Post subject: Reply with quote

I'll add the archaic spelling as an overload lol..
_________________
Back to top
View user's profile Send private message Send e-mail Visit poster's website
majkinetor



Joined: 24 May 2006
Posts: 4055
Location: Belgrade

PostPosted: Thu Dec 13, 2007 8:24 am    Post subject: Reply with quote

Quote:
You just need a way to break the loop from a different thread when using a hotkey or have the loop check with GetKeyState() and iterate at high frequency.

I beleive subclasing is the only real solution. AHK doesn't send return key as event. I recently posted Subclass function and using it u can make it work with Return in few lines of code.


Quote:
Calculating these offsets can be difficult as there are numerous factors that affect the spacing.

Acctually, you can get rectangle of selected item using API, and you can get column width using AHK.
_________________
Back to top
View user's profile Send private message
Titan



Joined: 11 Aug 2004
Posts: 4975
Location: /b/

PostPosted: Thu Dec 13, 2007 2:30 pm    Post subject: Reply with quote

majkinetor wrote:
Acctually, you can get rectangle of selected item using API, and you can get column width using AHK.
I get both with API, just for consistency. You said the edit control is positioned wrongly on your comp, could you please give a screenshot?

Uploaded 1.03b which introduces hotkeys. When cell editing press Esc to cancel current input or Enter to save it. You can change these hotkeys with the new function of course. I will try to improve on this so edit mode can be invoked via keyboard navigation on the cells (like Excel). Another improvement I want to add is bounding colouring information to rows, so you can enable sorting on the ListView and still retain highlighting for the corresponding cells.
_________________
Back to top
View user's profile Send private message Send e-mail Visit poster's website
majkinetor



Joined: 24 May 2006
Posts: 4055
Location: Belgrade

PostPosted: Thu Dec 13, 2007 2:47 pm    Post subject: Reply with quote

On 2 totaly different computers:


About ENTER it was not the problem to make it work when edit is active, but to enter edit state with it.
_________________
Back to top
View user's profile Send private message
garry



Joined: 19 Apr 2005
Posts: 1498
Location: switzerland

PostPosted: Thu Dec 13, 2007 2:56 pm    Post subject: Reply with quote

thank you Titan
here a complet example with 1.03b , change functions when Titan changed
example with add and delete button
http://www.autohotkey.net/~garry/LVX_EX_103b.ahk



Last edited by garry on Thu Dec 13, 2007 3:24 pm; edited 1 time in total
Back to top
View user's profile Send private message
Titan



Joined: 11 Aug 2004
Posts: 4975
Location: /b/

PostPosted: Thu Dec 13, 2007 3:02 pm    Post subject: Reply with quote

Nice work garry Smile

majkinetor could you please try 1.045b and tell me whether the y-alignment has been corrected or not?
_________________
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page 1, 2, 3, 4  Next
Page 1 of 4

 
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