AutoHotkey Community

It is currently May 26th, 2012, 8:56 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: July 3rd, 2008, 9:10 am 
Offline

Joined: December 28th, 2006, 9:46 am
Posts: 440
is showing of row data in a listview possible by just hovering?

I'm trying to get something to do the following, accept without clicking:

Code:
#SingleInstance,Force
OnExit,GuiClose

Gui,Add,Listview,vLV gLV AltSubmit,Name|Size

Gui,Show

Loop, %A_WinDir%\*.*
   LV_Add("",A_LoopFileName,A_LoopFileSizeKB)

Return

LV:
   If A_GuiEvent in Normal
      {
         LV_GetText(name,A_EventInfo,1)
         LV_GetText(size,A_EventInfo,2)
         tooltip, Name: %name%%A_Tab%Size: %size%
      }
Return

GuiClose:
   ExitApp


Thanks!

Adam


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 9th, 2008, 10:07 pm 
Offline

Joined: December 28th, 2006, 9:46 am
Posts: 440
Anyone have any ideas? :o


Report this post
Top
 Profile  
Reply with quote  
PostPosted: July 10th, 2008, 6:18 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
adamrgolf wrote:
accept without clicking:


It not possible, ( I guess ) to get a row text without selecting it first... but a row under mouse can be selected ( without clicking ) if you enable hot-track selection ( LVS_EX_TRACKSELECT LV0x8 ) style for the ListView Control.

This is what I mean:

Code:
#SingleInstance,Force
OnExit,GuiClose

Gui,Add,Listview,vLV r10 gLV LV0x8 AltSubmit,Name|Size
LV_ModifyCol(1,150 )
Gui,Show

Loop, %A_WinDir%\*.*
   LV_Add("",A_LoopFileName,A_LoopFileSizeKB)

Return

LV:
   If ( A_GuiEvent="I" )
      {
         LV_GetText(name,A_EventInfo,1)
         LV_GetText(size,A_EventInfo,2)
         tooltip, Name: %name%%A_Tab%Size: %size%
         SetTimer, ToolTipOff, -2000
      }
Return

GuiClose:
   ExitApp
   
ToolTipOff:
 Tooltip
Return


:)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 11th, 2008, 9:46 am 
Offline

Joined: December 1st, 2006, 9:27 am
Posts: 460
Try this. It calcs the row from the mouse pos and displays the text from the first two columns. No Hot-Tracking!
I tweaked parts of my "Listview In-Cell Editing" script.
Code:
#SingleInstance,Force
OnExit,GuiClose

Gui,Add,Listview, gLV vLV hwndLV_LView AltSubmit,Name|Size

Gui,Show

Loop, %A_WinDir%\*.*
   LV_Add("",A_LoopFileName,A_LoopFileSizeKB)

tipDuration = 4000

ControlGetPos, LV_lx, LV_ly, LV_lw, LV_lh, , ahk_id %LV_LView%   ;get info on listview
SysGet, SM_CXVSCROLL, 2         ;get width of vertical scrollbar
LVIR_LABEL = 0x0002               ;LVM_GETSUBITEMRECT constant - get label info
LVM_GETITEMCOUNT = 4100         ;gets total number of rows
LVM_SCROLL = 4116                  ;scrolls the listview
LVM_GETTOPINDEX = 4135         ;gets the first displayed row
LVM_GETCOUNTPERPAGE = 4136   ;gets number of displayed rows
LVM_GETSUBITEMRECT = 4152      ;gets cell width,height,x,y
OnMessage(0x200, "WM_MOUSEMOVE")   
Return

WM_MOUSEMOVE(wParam, lParam, msg, hwnd)
{
   global
   If(hwnd = LV_LView)   ;only if the mouse moved over the listview
   {   SendMessage, LVM_GETITEMCOUNT, 0, 0, , ahk_id %LV_LView%
      LV_TotalNumOfRows := ErrorLevel   ;get total number of rows
      SendMessage, LVM_GETCOUNTPERPAGE, 0, 0, , ahk_id %LV_LView%
      LV_NumOfRows := ErrorLevel   ;get number of displayed rows
      SendMessage, LVM_GETTOPINDEX, 0, 0, , ahk_id %LV_LView%
      LV_topIndex := ErrorLevel   ;get first displayed row
      
      LV_mx := lParam & 0xFFFF   ;get mouse x,y
      LV_my := lParam >> 16
      
      VarSetCapacity(LV_XYstruct, 16, 0)   ;create struct
      Loop,% LV_NumOfRows + 1   ;gets the current row and cell Y,H
      {   LV_which := LV_topIndex + A_Index - 1   ;loop through each displayed row
         NumPut(LVIR_LABEL, LV_XYstruct, 0)   ;get label info constant
         NumPut(A_Index - 1, LV_XYstruct, 4)   ;subitem index
         SendMessage, LVM_GETSUBITEMRECT, %LV_which%, &LV_XYstruct, , ahk_id %LV_LView%   ;get cell coords
         LV_RowY := NumGet(LV_XYstruct,4)   ;row upperleft y
         LV_RowY2 := NumGet(LV_XYstruct,12)   ;row bottomright y2
         LV_currColHeight := LV_RowY2 - LV_RowY ;get cell height
         If(LV_my <= LV_RowY + LV_currColHeight)   ;if mouse Y pos less than row pos + height
         {   If(oldLV_which != LV_which)
            {   LV_currRow  := LV_which + 1   ;1-based current row
               LV_currRow0 := LV_which      ;0-based current row, if needed
               LV_GetText(txt1, LV_currRow, 1)
               LV_GetText(txt2, LV_currRow, 2)
               ToolTip,Name: %txt1%%A_Tab%Size: %txt2%,,,19
               SetTimer, killTip, %tipDuration%
            }
            oldLV_which := LV_which
            Break
            killTip:
               tooltip,,,, 19
               SetTimer, killTip, Off
            Return
         }
      }
   }
   Else
   {   oldLV_which=
      tooltip,,,, 19
   }
}

LV:
;~    If A_GuiEvent in Normal
;~       {
;~          LV_GetText(name,A_EventInfo,1)
;~          LV_GetText(size,A_EventInfo,2)
;~          tooltip, Name: %name%%A_Tab%Size: %size%
;~       }
Return

GuiClose:
   ExitApp

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 11th, 2008, 9:49 am 
Offline

Joined: December 28th, 2006, 9:46 am
Posts: 440
Holy crap Micahs, that is great!

Edit: This is perfect, exactly what I needed. Great work!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 11th, 2008, 9:55 am 
Offline

Joined: December 1st, 2006, 9:27 am
Posts: 460
Glad you like it! Hope it helps.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 16th, 2009, 3:54 pm 
Offline

Joined: September 28th, 2007, 3:56 am
Posts: 279
Location: New York
I have been using Micahs' code for quite some time now and it is a great tool. The only thing I would like to change is the ability to have a delay.

I'm not sure how to implement this but an example would be like in a lot of forums, the tooltip is not immediate, there is a three or four second delay.

What I did was I just added a mouse coordinate check after two seconds and if the mouse hadn't moved, it would display the tip but it doesn't always work. I still get some tips that come up from rows I didn't hover over for a full two seconds. I believe it's because, by sleeping for two seconds and then checking again I'm causing a large queue of WM_MOUSEMOVE calls if it moves during those two seconds. If that made any sense.

So, I guess it may be as simple as telling it to kill the other WM_MOUSEMOVE threads each time a new one is started if that's possible.

Well, let me know what you think.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 17th, 2009, 10:28 am 
Offline

Joined: December 1st, 2006, 9:27 am
Posts: 460
Here is an updated version and example:
Code:
#SingleInstance,Force
OnExit,GuiClose

Gui,Add,Listview, vLV hwndLV_LView AltSubmit,Name|Size
Gui,Show

Loop, %A_WinDir%\*.*   ;just fill listview
   LV_Add("",A_LoopFileName,A_LoopFileSizeKB)

OnMessage(0x200, "WM_MOUSEMOVE")   
Return

WM_MOUSEMOVE(wParam, lParam, msg, hwnd)
{
   global
   If(hwnd = LV_LView)   ;only if the mouse moved over the listview
   {   LV_MouseGetCellPos(LV_CurrRow, LV_CurrCol, LV_LView)
      If(oldLV_CurrRow != LV_CurrRow)   ;if it has changed
      {   oldLV_CurrRow := LV_CurrRow
         ToolTip,,,, 20
         counter := A_TickCount + 500
         Loop   ;loop for 500 ms and cancel tip if row changed
         {   LV_MouseGetCellPos(LV_CurrRow, LV_CurrCol, LV_LView)
            IfNotEqual, oldLV_CurrRow, %LV_CurrRow%
            {   SetTimer, KillNow, -1
               Return
            }
            looper := A_TickCount
            IfGreater, looper, %counter%, Break
            sleep, 150
         }
         LV_GetText(txt1, LV_currRow, 1)
         LV_GetText(txt2, LV_currRow, 2)
         SetTimer, killTip, 500
         ToolTip,Name: %txt1%%A_Tab%Size: %txt2%,,,20
      }
      Return
      killTip:
         killTipCounter++
         MouseGetPos, , , outWm, outK, 2
         If(outK != LV_LView) or (killTipCounter >= 8)   ;500ms*8 = ~4 secs
         {   ;this lets us kill the tooltip immediately
            KillNow:
               SetTimer, killTip, Off
               ToolTip,,,, 20
               killTipCounter=0
            Return
         }
      Return
   }
   Else   ;if not over lv, destroy tip
   {   SetTimer, killTip, -1   ;go now once
   }
}

GuiClose:
   ExitApp
Return


LV_MouseGetCellPos(ByRef LV_CurrRow, ByRef LV_CurrCol, LV_LView)
{   
   LVIR_LABEL = 0x0002               ;LVM_GETSUBITEMRECT constant - get label info
   LVM_GETITEMCOUNT = 4100         ;gets total number of rows
   LVM_SCROLL = 4116                  ;scrolls the listview
   LVM_GETTOPINDEX = 4135         ;gets the first displayed row
   LVM_GETCOUNTPERPAGE = 4136   ;gets number of displayed rows
   LVM_GETSUBITEMRECT = 4152      ;gets cell width,height,x,y
   ControlGetPos, LV_lx, LV_ly, LV_lw, LV_lh, , ahk_id %LV_LView%   ;get info on listview

   SendMessage, LVM_GETITEMCOUNT, 0, 0, , ahk_id %LV_LView%
   LV_TotalNumOfRows := ErrorLevel   ;get total number of rows
   SendMessage, LVM_GETCOUNTPERPAGE, 0, 0, , ahk_id %LV_LView%
   LV_NumOfRows := ErrorLevel   ;get number of displayed rows
   SendMessage, LVM_GETTOPINDEX, 0, 0, , ahk_id %LV_LView%
   LV_topIndex := ErrorLevel   ;get first displayed row
   
   CoordMode, MOUSE, RELATIVE
   MouseGetPos, LV_mx, LV_my
   LV_mx -= LV_lx, LV_my -= LV_ly
   
   VarSetCapacity(LV_XYstruct, 16, 0)   ;create struct
   Loop,% LV_NumOfRows + 1   ;gets the current row and cell Y,H
   {   LV_which := LV_topIndex + A_Index - 1   ;loop through each displayed row
      NumPut(LVIR_LABEL, LV_XYstruct, 0)   ;get label info constant
      NumPut(A_Index - 1, LV_XYstruct, 4)   ;subitem index
      SendMessage, LVM_GETSUBITEMRECT, %LV_which%, &LV_XYstruct, , ahk_id %LV_LView%   ;get cell coords
      LV_RowY := NumGet(LV_XYstruct,4)   ;row upperleft y
      LV_RowY2 := NumGet(LV_XYstruct,12)   ;row bottomright y2
      LV_currColHeight := LV_RowY2 - LV_RowY ;get cell height
      If(LV_my <= LV_RowY + LV_currColHeight)   ;if mouse Y pos less than row pos + height
      {   LV_currRow  := LV_which + 1   ;1-based current row
         LV_currRow0 := LV_which      ;0-based current row, if needed
         ;LV_currCol is not needed here, so I didn't do it! It will always be 0. See my ListviewInCellEditing function for details on finding LV_currCol if needed.
         LV_currCol=0
         Break
      }
   }
}

It now uses parts of my tooltipV2 function. This one originally used version one of the tooltip stuff. I had improved it but hadn't updated this accordingly. This more closely mimics normal tooltip behavior. There is a 500ms lag before the tip appears. It will stay for about 4 seconds. I also broke the LV row detection out into a function called "LV_MouseGetCellPos". Hope this helps.

Micahs

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot], kkkddd1, poserpro and 69 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group