Edit Listview Subitem In Vb6 Instrb
Hi Jack, Here is the code someone shared with me previously and I am passing along to you. I use it extenstively.you should be able to cut and paste to get it to work. Structure RECT Public left As Integer Public top As Integer Public right As Integer Public bottom As Integer End Structure 'RECT Declare Auto Function SendMessage Lib 'user32.dll' (ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByRef lParam As RECT) As Integer Public Function GetListViewSubItem(ByVal listView1 As ListView, ByVal pt As Point) As Integer Try ' '***** IMPORTANT ***** The ListView must be set for FullRowSelect!! Thank you for the code. I did cut and paste it into a test application and the coordinates for subitems seems to be off a little bit. I'm calling the procedure you provided in the MouseHover event below: Private Sub grdData_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdData.MouseHover Me.ToolTip1.SetToolTip(grdData, GetListViewSubItem(grdData, sender.mouseposition)) End Sub grdData is the listview control.
The subitem index that is shown in the tool tip seems to be off by one column. It seems to be looking at the column to the right of the column where the mouse is hovering over. Am I doing something wrong? Jack 'J L' wrote: Hi Jack, Here is the code someone shared with me previously and I am passing along to you. I use it extenstively.you should be able to cut and paste to get it to work. Structure RECT Public left As Integer Public top As Integer Public right As Integer Public bottom As Integer End Structure 'RECT Declare Auto Function SendMessage Lib 'user32.dll' (ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByRef lParam As RECT) As Integer Public Function GetListViewSubItem(ByVal listView1 As ListView, ByVal pt As Point) As Integer Try ' '***** IMPORTANT ***** The ListView must be set for FullRowSelect!! I dont find a Sender.Mouseposition property in the hover event.
I set the mouse location in the mouse move event and also display the associated tip in that event. Those are the only differences I can see. John So perhaps it is in the hover and sender.mouseposition On Tue, 31 May 2005 05:35:02 -0700, 'Jack' wrote: Thank you for the code.
I did cut and paste it into a test application and the coordinates for subitems seems to be off a little bit. I'm calling the procedure you provided in the MouseHover event below: Private Sub grdData_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdData.MouseHover Me.ToolTip1.SetToolTip(grdData, GetListViewSubItem(grdData, sender.mouseposition)) End Sub grdData is the listview control.
The subitem index that is shown in the tool tip seems to be off by one column. It seems to be looking at the column to the right of the column where the mouse is hovering over. Am I doing something wrong? Jack 'J L' wrote: Hi Jack, Here is the code someone shared with me previously and I am passing along to you. I use it extenstively.you should be able to cut and paste to get it to work.
Structure RECT Public left As Integer Public top As Integer Public right As Integer Public bottom As Integer End Structure 'RECT Declare Auto Function SendMessage Lib 'user32.dll' (ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByRef lParam As RECT) As Integer Public Function GetListViewSubItem(ByVal listView1 As ListView, ByVal pt As Point) As Integer Try ' '***** IMPORTANT ***** The ListView must be set for FullRowSelect!! I was passing in the incorrect Point. I was passing in the mouseposition of the listview control when I should have been sending in the x and y coordinates of the event argument as a new point.
Here is the code for anyone with this same issue (I also moved the code to MouseOver from MouseHover): Private Sub GridData_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles grdData.MouseMove Dim lvSubItem As ListViewItem.ListViewSubItem lvSubItem = GetListViewSubItem(grdData, New Point(e.X, e.Y)) If Not lvSubItem Is Nothing Then Me.ToolTip1.SetToolTip(grdData, lvSubItem. Crack James Bond Quantum Solace PCP. Text) Else Me.ToolTip1.RemoveAll() End If End Sub P.S. I also modified the GetListViewSubItem procedure to pass back the subitem object instead of the index. Thanks for you help!!
Jack 'Jack' wrote: Thank you for the code. I did cut and paste it into a test application and the coordinates for subitems seems to be off a little bit. I'm calling the procedure you provided in the MouseHover event below: Private Sub grdData_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdData.MouseHover Me.ToolTip1.SetToolTip(grdData, GetListViewSubItem(grdData, sender.mouseposition)) End Sub grdData is the listview control. The subitem index that is shown in the tool tip seems to be off by one column. It seems to be looking at the column to the right of the column where the mouse is hovering over. Am I doing something wrong?
I could go through all those books I bought on VB6, but I'll bet you I won't find what I want until next week, or next month.
Jack 'J L' wrote: Hi Jack, Here is the code someone shared with me previously and I am passing along to you. I use it extenstively.you should be able to cut and paste to get it to work. Structure RECT Public left As Integer Public top As Integer Public right As Integer Public bottom As Integer End Structure 'RECT Declare Auto Function SendMessage Lib 'user32.dll' (ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByRef lParam As RECT) As Integer Public Function GetListViewSubItem(ByVal listView1 As ListView, ByVal pt As Point) As Integer Try ' '***** IMPORTANT ***** The ListView must be set for FullRowSelect!! Good news Jack. As to passing back the subitem or the index, I use the index because I want to access both the item and the column title.
So the index is useful in that case. John On Tue, 31 May 2005 16:11:01 -0700, 'Jack' wrote: Nevermind. I was passing in the incorrect Point. I was passing in the mouseposition of the listview control when I should have been sending in the x and y coordinates of the event argument as a new point. Here is the code for anyone with this same issue (I also moved the code to MouseOver from MouseHover): Private Sub GridData_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles grdData.MouseMove Dim lvSubItem As ListViewItem.ListViewSubItem lvSubItem = GetListViewSubItem(grdData, New Point(e.X, e.Y)) If Not lvSubItem Is Nothing Then Me.ToolTip1.SetToolTip(grdData, lvSubItem.Text) Else Me.ToolTip1.RemoveAll() End If End Sub P.S.
I also modified the GetListViewSubItem procedure to pass back the subitem object instead of the index. Thanks for you help!! Jack 'Jack' wrote: Thank you for the code. I did cut and paste it into a test application and the coordinates for subitems seems to be off a little bit. I'm calling the procedure you provided in the MouseHover event below: Private Sub grdData_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdData.MouseHover Me.ToolTip1.SetToolTip(grdData, GetListViewSubItem(grdData, sender.mouseposition)) End Sub grdData is the listview control.
The subitem index that is shown in the tool tip seems to be off by one column. It seems to be looking at the column to the right of the column where the mouse is hovering over. Am I doing something wrong? Jack 'J L' wrote: >Hi Jack, >Here is the code someone shared with me previously and I am passing >along to you. I use it extenstively.you should be able to cut and >paste to get it to work. >>Structure RECT >Public left As Integer >Public top As Integer >Public right As Integer >Public bottom As Integer >End Structure 'RECT >>Declare Auto Function SendMessage Lib 'user32.dll' (ByVal hWnd As >IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByRef lParam >As RECT) As Integer >>Public Function GetListViewSubItem(ByVal listView1 As ListView, >ByVal pt As Point) As Integer >Try >' >'***** IMPORTANT ***** The ListView must be set for FullRowSelect!! John, it's a funny thing.
I got to my desk this morning to work on this project and came across another instance where I need to use the code you provided. As it turns out, I need the index returned and not just the subitem. If forgot that the subitem doesn't provide an index to its position in the item. So, the code is back to where you originally intended it to be. I should have assumed the decision to send back the subitem or index was well thought out.
Thanks again. It's a very useful chunk of code. Jack 'J L' wrote: Good news Jack.
As to passing back the subitem or the index, I use the index because I want to access both the item and the column title. So the index is useful in that case. John On Tue, 31 May 2005 16:11:01 -0700, 'Jack' wrote: Nevermind. I was passing in the incorrect Point. I was passing in the mouseposition of the listview control when I should have been sending in the x and y coordinates of the event argument as a new point. Here is the code for anyone with this same issue (I also moved the code to MouseOver from MouseHover): Private Sub GridData_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles grdData.MouseMove Dim lvSubItem As ListViewItem.ListViewSubItem lvSubItem = GetListViewSubItem(grdData, New Point(e.X, e.Y)) If Not lvSubItem Is Nothing Then Me.ToolTip1.SetToolTip(grdData, lvSubItem.Text) Else Me.ToolTip1.RemoveAll() End If End Sub P.S.
I also modified the GetListViewSubItem procedure to pass back the subitem object instead of the index. Thanks for you help!! Jack 'Jack' wrote: Thank you for the code. I did cut and paste it into a test application and the coordinates for subitems seems to be off a little bit. I'm calling the procedure you provided in the MouseHover event below: Private Sub grdData_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdData.MouseHover Me.ToolTip1.SetToolTip(grdData, GetListViewSubItem(grdData, sender.mouseposition)) End Sub grdData is the listview control. The subitem index that is shown in the tool tip seems to be off by one column. It seems to be looking at the column to the right of the column where the mouse is hovering over.
Am I doing something wrong? Jack 'J L' wrote: >Hi Jack, >Here is the code someone shared with me previously and I am passing >along to you. I use it extenstively.you should be able to cut and >paste to get it to work.
>>Structure RECT >Public left As Integer >Public top As Integer >Public right As Integer >Public bottom As Integer >End Structure 'RECT >>Declare Auto Function SendMessage Lib 'user32.dll' (ByVal hWnd As >IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByRef lParam >As RECT) As Integer >>Public Function GetListViewSubItem(ByVal listView1 As ListView, >ByVal pt As Point) As Integer >Try >' >'***** IMPORTANT ***** The ListView must be set for FullRowSelect!!
I'm having a seniors moment (63 tomorrow, that's in 13 minutes time, btw) I'm trying to open a jpg file, find the position of 'FF C0 00 01 08' and get the next four bytes of info. (width and height of said jpg) That data never stays in one fixed spot, so I have to find it. Seniors moments are a pita, and I can't remember how to do it.
I could go through all those books I bought on VB6, but I'll bet you I won't find what I want until next week, or next month. Anyone interested in giving me a hand with the code?
(63 in 8 minutes, now) Graham Fri, 13 Jul 2012 21:21:19 GMT. Happy Birthday! >>I'm having a seniors moment (63 tomorrow, that's >>in 13 minutes time, btw) >So by now you'll be heading for 64!
Still just a youngster though... >according to DateDiff I turned 63 about 1,805,727 minutes ago:-) >Mike God!! You ARE keeping your mind young, Mike That's about 3 years, some months ahead of me (I used the calculator) Should have done it with a VB program, and found out just how young you really are. That would keep my mind working away as well Graham Sat, 14 Jul 2012 07:41:00 GMT. >I'm having a seniors moment (63 tomorrow, that's in 13 minutes time, btw) >I'm trying to open a jpg file, find the position of 'FF C0 00 01 08' and get the >next four bytes of info.
(width and height of said jpg) >That data never stays in one fixed spot, so I have to find it. >Seniors moments are a pita, and I can't remember how to do it.
>I could go through all those books I bought on VB6, but I'll bet you I won't >find what I want until next week, or next month. >Anyone interested in giving me a hand with the code? A bit late (I've been on vacation) but I thought I would add a second method for those looking to do the same. Quite simply, put the file data in a byte array, and the search bytes in a byte array, then use InStrB to find their location. InStrB will compare byte-for-byte just like InStr compares character-for-character. Also, those functions (InStr & InStrB) accept byte arrays in place of strings for their parameters. LFS Mon, 16 Jul 2012 08:44:13 GMT.
>A bit late (I've been on vacation) but I thought I would >add a second method for those looking to do the same. >Quite simply, put the file data in a byte array, and the >search bytes in a byte array, then use InStrB to find >their location. InStrB will compare byte-for-byte just >like InStr compare character-for-character. Well, well, well! I knew that InstrB picked out individual bytes in a string, but I never actually used it bcause I really couldn't see the value of it, at least for the things I usually do.
But I never knew you could use it to find one set of Byte array data inside another! Very interesting. I've often had the need to do that and I've written byte by byte comparisons to perform the task! I think I'm gonna have to get a timer on it and see how much I've been missing!
Now if only my old brain was still capable of retaining new information I could leave it at that, but of course at my age it isn't so I'll have to put it in my little database of 'things I learned since my brain filled up';-) Thanks Larry. Mike Mon, 16 Jul 2012 09:03:45 GMT. >>I'm having a seniors moment (63 tomorrow, that's in 13 minutes time, btw) >>I'm trying to open a jpg file, find the position of 'FF C0 00 01 08' and get the >>next four bytes of info. (width and height of said jpg) >>That data never stays in one fixed spot, so I have to find it. >>Seniors moments are a pita, and I can't remember how to do it. >>I could go through all those books I bought on VB6, but I'll bet you I won't >>find what I want until next week, or next month. >>Anyone interested in giving me a hand with the code?
>A bit late (I've been on vacation) but I thought I would add a >second method for those looking to do the same. >Quite simply, put the file data in a byte array, and the search >bytes in a byte array, then use InStrB to find their location. >InStrB will compare byte-for-byte just like InStr compares >character-for-character. Also, those functions (InStr & InStrB) >accept byte arrays in place of strings for their parameters. >LFS Thanks, Larry.
That's what I was thinking of, originally. I'll try modifying nobody's 'bludgeon it with a large rock' code (which works fine) to see what happens.
At least I'm now getting the width and height of a jpg file. I just wish these jpg, exif, jfif programs would all do the same thing when they edit a jpg. (well they do, actually - it's that 'FF C0' marker that seems to pop up anywhere from 256 bytes from the SOI, to several hundred later). Graham Mon, 16 Jul 2012 16:22:04 GMT. >Thanks, Larry. That's what I was thinking of, originally.
>I'll try modifying nobody's 'bludgeon it with a large rock' code (which works >fine) to see what happens. At least I'm now getting the width and height of a >jpg file. I just wish these jpg, exif, jfif programs would all do the same thing >when they edit a jpg. (well they do, actually - it's that 'FF C0' marker that >seems to pop up anywhere from 256 bytes from the SOI, to several hundred later). If you're grabbing only the header info, might you limit your buffer to 4K or 8K? I would think that should go quicker than loading up the whole (100K +) file.
LFS Mon, 16 Jul 2012 17:29:20 GMT Page 1 of 2 [ 24 post ] Go to page.