I have searched the whole forum and found nothing on this, all I could find was how to select an item in an external listview using wm_keydown.
I need to select all the items in an external listview.
Anybody know how to do this?
Thanks in advance.
Printable View
I have searched the whole forum and found nothing on this, all I could find was how to select an item in an external listview using wm_keydown.
I need to select all the items in an external listview.
Anybody know how to do this?
Thanks in advance.
Have a look at this : http://www.vbforums.com/showthread.p...xternal+select
Man i do not see any working example to select external listview item in thatQuote:
Originally Posted by manavo11
thread. Could u show me an working example to select item from external listview?Thanks
What's wrong with the code in the first post? Do you need help? Did you declare everything?
thank u for u reply. Well i realy need help declaring needed things. i be happy if u tell me what controles and things i need to make that code run. This is the informaton i got from my external listview:Quote:
Originally Posted by manavo11
Window Handle == 0x00310520.
Class Name : SysListView32.
RECT.left == 799.
RECT.top == 195.
RECT.right == 995.
RECT.bottom == 462.
and
VB Code:
'************************************************************************************ '***** FindWindow Source [Code] ***** '***** By Sean Gallardy E-Mail [email protected] ***** '************************************************************************************ 'API Calls Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Function GetMyWindow() as long 'Variables Dim lParent as long Dim lChild(1 to 5) as long 'Get Parent Window lParent = FindWindow("My Window Class", "window caption") 'Get Child Window(s) lChild(1) = FindWindowEx(lParent, 0, "WTL_SplitterWindow", "") lChild(2) = FindWindowEx(lChild(1), 0, "WTL_SplitterWindow", "") lChild(3) = FindWindowEx(lChild(2), 0, "WTL_SplitterWindow", "") lChild(4) = FindWindowEx(lChild(3), 0, "ATL:0053D8D0", "") lChild(5) = FindWindowEx(lChild(4), 0, "SysListView32", "") GetMyWindow = lChild(5) End Function
Thanks
VB Code:
Const LVIF_STATE As Long = &H8 Const LVIS_SELECTED As Long = &H2 Const LVIS_FOCUSED As Long = &H1 Const LVM_SETITEMSTATE As Long = (LVM_FIRST + 43) Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _ ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ ByRef lParam As Any) As Long
Quote:
Originally Posted by manavo11
Thank u for u reply . could u tell me how to make the on command event. Where to put them ?I only want select and highlight for example the 2 listview item .The current listview does not allow select all. i tried this and got this error :
compile error:
Constant expression required
and pointing at LVM_FIRST
complete code:
VB Code:
Const LVIF_STATE As Long = &H8 Const LVIS_SELECTED As Long = &H2 Const LVIS_FOCUSED As Long = &H1 Const LVM_SETITEMSTATE As Long = ([B]LVM_FIRST [/B] + 43) Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _ ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ ByRef lParam As Any) As Long Private Sub Command1_Click() With myLVitem .mask = LVIF_STATE .state = &HF .stateMask = LVIS_SELECTED Or LVIS_FOCUSED End With dmWriteProcessData lvItemPointer, VarPtr(myLVitem), Len(myLVitem) apiResult = SendMessage(lvWindow, LVM_SETITEMSTATE, 1, lvItemPointer) End Sub
VB Code:
Const LVM_FIRST As Long = &H1000
You will have to find the number of items in the listview and then select them one by one. If I'm not mistaken you have to change the 3rd parameter of the SendMessage call.
Many thanks for u reply. adding that line did not solve the error. error Pointing at same spot!Quote:
Originally Posted by manavo11
How to get the number of items in external listview ? I just want to highlight say for example item number 4. could u tell me what should i put in 3rd parameter.Thanks
Add the extra line above the line that is causing the error.
If you want to highlight the 4th item, you should put in the 3rd parameter the number 4. I think...
could u tell me what u mean an extra line ? the program does not run at all so i do not get any thing highlited in external window!!Quote:
Originally Posted by manavo11
It keep giving me compile error and pointing at this :
Const LVM_SETITEMSTATE As Long = (LVM_FIRST + 43)
May i know what is that number 43 for ? I have feeling that the code is not complet :confused: :confused:
Do i need to know number of items in that external listview ? How?
Can you post your code?
Here is the complete latest code. I just followed what u suggested in previouse posts:Quote:
Originally Posted by manavo11
VB Code:
Const LVIF_STATE As Long = &H8 Const LVIS_SELECTED As Long = &H2 Const LVIS_FOCUSED As Long = &H1 Const LVM_SETITEMSTATE As Long = (LVM_FIRST + 8) Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _ ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ ByRef lParam As Any) As Long Private Sub Command1_Click() With myLVitem .mask = LVIF_STATE .state = &HF .stateMask = LVIS_SELECTED Or LVIS_FOCUSED End With dmWriteProcessData lvItemPointer, VarPtr(myLVitem), Len(myLVitem) apiResult = SendMessage(lvWindow, LVM_SETITEMSTATE, 1, lvItemPointer) End Sub
VB Code:
Const LVM_FIRST As Long = &H1000 Const LVIF_STATE As Long = &H8 Const LVIS_SELECTED As Long = &H2 Const LVIS_FOCUSED As Long = &H1 Const LVM_SETITEMSTATE As Long = (LVM_FIRST + 8) Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _ ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ ByRef lParam As Any) As Long Private Sub Command1_Click() With myLVitem .mask = LVIF_STATE .state = &HF .stateMask = LVIS_SELECTED Or LVIS_FOCUSED End With dmWriteProcessData lvItemPointer, VarPtr(myLVitem), Len(myLVitem) apiResult = SendMessage(lvWindow, LVM_SETITEMSTATE, 1, lvItemPointer) End Sub
You didn't add the LVM_FIRST declaration that I posted above. The above should work and highlight the first item. For the 2nd item you should use (I'm guessing) :
VB Code:
apiResult = SendMessage(lvWindow, LVM_SETITEMSTATE, 2, lvItemPointer)
For the 3rd item :
VB Code:
apiResult = SendMessage(lvWindow, LVM_SETITEMSTATE, 3, lvItemPointer)
And so on...
Now this errorshowin in pic attached:
pointing at :
HAve u tried this code ? did it work for u?Code:Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByRef lParam As Any) As Long
I think this code will not work for external listview since at no point code is looking for a window that holds the listvidew!! :confused: :confused:
AS u see i provied the classname and listview info beleow so i be happy if u have a look at it.Thanks
This is the informaton i got from my external listview using api spy:
Window Handle == 0x00310520.
Class Name : SysListView32.
RECT.left == 799.
RECT.top == 195.
RECT.right == 995.
RECT.bottom == 462.
and
VB Code:
'************************************************************************************ '***** FindWindow Source [Code] ***** '***** By Sean Gallardy E-Mail [email protected] ***** '************************************************************************************ 'API Calls Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Function GetMyWindow() as long 'Variables Dim lParent as long Dim lChild(1 to 5) as long 'Get Parent Window lParent = FindWindow("My Window Class", "window caption") 'Get Child Window(s) lChild(1) = FindWindowEx(lParent, 0, "WTL_SplitterWindow", "") lChild(2) = FindWindowEx(lChild(1), 0, "WTL_SplitterWindow", "") lChild(3) = FindWindowEx(lChild(2), 0, "WTL_SplitterWindow", "") lChild(4) = FindWindowEx(lChild(3), 0, "ATL:0053D8D0", "") lChild(5) = FindWindowEx(lChild(4), 0, "SysListView32", "") GetMyWindow = lChild(5) End Function
Declare it as Private :
VB Code:
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _ ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ ByRef lParam As Any) As Long
Quote:
Originally Posted by manavo11
I made that change and that error is out but another came when clicking the button:
and point at :Code:Compile error:
Sub or functon not defined
dmWriteProcessData