Hi all.I want check a checkbox in external window using the following method but i get compile error that LVIF_STATE variable is not defined could an expert show me how LVIF_STATE,LVIS_CHECKED ,LVITEM, LVIS_STATEIMAGEMASK should be defined so they get used by our local LV_ITEM to change the selected item? Looking forward for replies.Thanks
Code:
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Private Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Declare Function SendMessageLong& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam 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
Const WM_COMMAND = &H111
Private Const WM_CLOSE As Long = &H10
Private Const WM_KEYDOWN = &H100
Private Const WM_KEYUP = &H101
Private Const VK_SPACE = &H20
Private Sub Command1_Click()
Dim x As Long, editx As Long
Dim button As Long
'Set up our local LV_ITEM to change the selected item
LVITEM.mask = LVIF_STATE
LVITEM.state = LVIS_CHECKED
LVITEM.stateMask = LVIS_STATEIMAGEMASK
x = FindWindow("#32770", "session")
If x Then
'MsgBox "found"
SendMessage x, LVM_SETITEMSTATE, 1, LVI
End If
End Sub