why is there an error in the method when getting the hwnd of a listview from other form.
thanks in advance for the reply..Code:calling this from form2.
form1.listview1.hwnd returns method error.
Printable View
why is there an error in the method when getting the hwnd of a listview from other form.
thanks in advance for the reply..Code:calling this from form2.
form1.listview1.hwnd returns method error.
- How do you actually use it?
- What is the actual error message?
- hWnd is not a method - it's a property and its value needs to be assigned to some variable.
i actually want to create a sub or function to get the hwnd of listview from another form.Code:Private Sub gethwnd(frm As Form, lvw As ListView)
MsgBox frm.lvw.hWnd
End Sub
Private Sub btn__Click()
gethwnd Form1, ListView1
End Sub
"byref argument type mismatch is the error that i got.
The gethwnd sub should not have two parameters - it should only have lvw , as that exists in its own right and you should not be specifying a parent object for it.
This line:
is actually asking for an object on Form1 which is called lvw (rather than anything related to your parameter called lvw), which presumably does not exist.Code:MsgBox frm.lvw.hWnd
This will do what you want:Code:MsgBox lvw.hWnd
Add this to your form2:
Code:Option Explicit
Private Sub Command1_Click()
Dim lHwnd As Long
lHwnd = GetHWnd(Form1.ListView1)
MsgBox lHwnd
End Sub
Private Function GetHWnd(ctl As Control)
On Error Resume Next
GetHWnd = ctl.hWnd
End Function
thank you very guys..it worked now..