- This topic has 35 replies, 6 voices, and was last updated 16 years ago by autopilot.
-
AuthorPosts
-
February 14, 2008 at 1:45 pm #187775autopilotMember
my guess is that you are not finding the handle to the syslistview. the way loco does it, you have to update the code every time pal puts out a new release. make sure that the handles are being found before you start trying to fix alot of other stuff. you can (like loco) use PAT or JK’s API Spy 5.1 to find the code… or you can learn how to enum all the windows to find the handle you need. if you use the enum method, then you will not have to update your code with every new paltalk release.
February 14, 2008 at 2:37 pm #187774stevenMember🙂 thankss Chike .. thanx autopilot .. it works now .. yah it works .. really appreciated i realy do .. thankssss autopilot Chike
February 14, 2008 at 4:23 pm #187773stevenMember🙁 one more trouble .. the nicknames listed successfuly in list3 .. but no nickname is selectd from the room when i double click list1 or list2 to bounce .. always notice from paltalk ” This user has not been on recently …..”
February 14, 2008 at 9:08 pm #187772ChikeMemberWhere did you make a change? NickGet?
You probably need to make the same change in EnumWindowsProc which is called from FindListViewFebruary 15, 2008 at 3:26 pm #187771stevenMemberyes Chike .. i changed EnumWindowsProc but still the problem is there .. double clicked in list1 or list2 to bounce but nothing happen only paltalk notification .. even no nickname selected from the room nicknam list..
can you give an example , i mean source code so that be able to know how the nicknam is selected from the form listbox should be selected from the room nicknam list. 🙁February 15, 2008 at 4:01 pm #187770ChikeMemberI am not going to debug it for you, and i have no examples, I don’t use basic.
See that MessageCrossProcess is getting the valid hwnd from FindListView (the same GetListviewItem get from NickGet)
If list3 has names I believe MessageCrossProcess should work too.February 15, 2008 at 5:00 pm #187769autopilotMemberif you step through the bounce process, you will find that loco has to find the syslistview handle. again, the way he finds the handle has to be updated every time you change the version of paltalk that you are using. You will have to do the same thing for the syslistview that you did to get the last line of text. or you can do some learning and figure out how to write your own application and learn how to enum 😮
using someone elses code is nice (if it works) and easy, but you are not learning much. look at the code for ideas on how to do things, and then write your own program. you will be amazed by how much you learn when you start to do things for yourself!
February 15, 2008 at 5:41 pm #187768ChikeMember@autopilot wrote:
or you can do some learning and figure out how to write your own application and learn how to enum
Actually finding the list view handle using EnumChildWindows is very easy because it’s the only sub window of this class. So all the EnumChildProc has to do is get the class name with GetClassName, compare it to “SysListView32” and stop and return it’s handle when it’s found.
Tip: don’t duplicate code, it’s a recipe for bugs. Unify it using functions or sub routines for same code that is used more than once and is longer than 2-3 lines of code. Once something changes and need a fix you need to fix it at one place only.
February 16, 2008 at 12:10 am #187767DepartureMemberPost your vb6 code here to find the handel, and ill fix it for you so you wont need to update it again. As chike said its easy to find that one because its the only sub control of that type…
I would post an example for you but I dont use vb6 anymore, So I dont have it installed to write you an example.
Edit:
here is somewhat of an example, not tested yet…
1.
'In a form, with a ListBox named List1
2.
Option Explicit
3.
4.
Private Sub Form_Load()
5.
Dim hWndForm As Long
6.
'get the form handle
7.
hWndForm = FindWindow(vbNullString, "PaltalkWindowCaption")
8.
'enumerate child windows of the window
9.
If hWndForm 0 Then EnumChildWindows hWndForm, AddressOf EnumChildProc, ByVal 0&
10.
End Sub
11.
12.
'=================
13.
'In a standard module
14.
Option Explicit
15.
16.
Public Declare Function EnumChildWindows Lib "user32" _
17.
(ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
18.
19.
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
20.
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
21.
22.
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" _
23.
(ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
24.
25.
'call back function
26.
Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
27.
'assuming it is a SystemListView32, other wise change the class name
28.
If GetClsName(hwnd) = "SystemListView32" Then
29.
frmTransferData.List1.AddItem hwnd
30.
End If
31.
'continue enumeration
32.
EnumChildProc = 1
33.
End Function
34.
35.
'gets the class name
36.
Public Function GetClsName(ByVal hwnd As Long) As String
37.
Dim lpClassName As String
38.
Dim RetVal As Long
39.
lpClassName = Space(256)
40.
'retrieve the class name
41.
RetVal = GetClassName(hwnd, lpClassName, 256)
42.
'Show the classname
43.
GetClsName = Left$(lpClassName, RetVal)
44.
45.
End Function
I found this example on a vb forum and just changed a few little things to suit your needs, Like i said I have’nt tested it as yet
February 16, 2008 at 1:18 pm #187766stevenMemberthank you Departure .. this is NickGet i changed and it work fine because the nicknames are listed in list3
Function NickGet()
Dim dlggroupchatwindowclass As Long, wtlsplitterwindow As Long, atlfb As Long
Dim syslistview As Long
On Error Resume Next
dlggroupchatwindowclass = FindWindow("dlggroupchat window class", Text1)
wtlsplitterwindow = FindWindowEx(dlggroupchatwindowclass, 0&, "wtl_splitterwindow", vbNullString)
wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "wtl_splitterwindow", vbNullString)
wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "wtl_splitterwindow", vbNullString)
wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "wtl_splitterwindow", vbNullString)
wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "wtl_splitterwindow", vbNullString)
atlfb = FindWindowEx(wtlsplitterwindow, 0&, "atl:006fb328", vbNullString)
syslistview = FindWindowEx(atlfb, 0&, "syslistview32", vbNullString)
Call GetListviewItem(syslistview)
End Function
Private Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As String) As Long
Dim mywindowclass As Long, wtlsplitterwindow As Long, atldd As Long
Dim syslistview As Long
Dim strCaption As String
Dim lLen As Long
Dim dlggroupchatwindowclass As Long
Dim atlfb As Long
hwnd = FindWindow("dlggroupchat window class", Form1.Text1)
wtlsplitterwindow = FindWindowEx(dlggroupchatwindowclass, 0&, "wtl_splitterwindow", vbNullString)
wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "wtl_splitterwindow", vbNullString)
wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "wtl_splitterwindow", vbNullString)
wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "wtl_splitterwindow", vbNullString)
wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "wtl_splitterwindow", vbNullString)
atlfb = FindWindowEx(wtlsplitterwindow, 0&, "atl:006fb328", vbNullString)
hWndlvw = FindWindowEx(atlfb, 0&, "syslistview32", vbNullString)
' If we've found a window with the SysListView32 class
' check to see if parent window caption is the one we are looking for
If hWndlvw 0 Then
lLen = GetWindowTextLength(hwnd)
If lLen > 0 Then
strCaption = Space(lLen)
GetWindowText hwnd, strCaption, lLen + 1
End If
End If
EnumWindowsProc = (hWndlvw = 0 And strCaption lParam)
End Function
Public Function FindListView(strInWindowWithCaption As String) As Long
EnumWindows AddressOf EnumWindowsProc, StrPtr(strInWindowWithCaption)
FindListView = hWndlvw
End Function
Public Function MessageCrossProcess(ByVal hwnd As Long)
Dim lProcID As Long
Dim hProc As Long
Dim lxprocLVITEM As Long
Dim LVITEM As LV_ITEM
Dim lItemPos As Long
GetWindowThreadProcessId hwnd, lProcID ' Get the process ID in which the ListView is running
If lProcID 0 Then
hProc = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, False, lProcID) ' make sure we have read write permissions in the process space
If hProc 0 Then
lxprocLVITEM = VirtualAllocEx(hProc, 0, LenB(LVITEM), MEM_RESERVE Or MEM_COMMIT, PAGE_READWRITE) ' Grab enough memory in the other procedure's space to hold our LV_ITEM
' Set up our local LV_ITEM to change the selected item
LVITEM.mask = LVIF_STATE
LVITEM.state = True
LVITEM.stateMask = LVIS_SELECTED Or LVIS_FOCUSED ' Just enforcing the selection better than in original version by moving the focus as well
' Copy the local LV_ITEM into the space we reserved in the foreign process
WriteProcessMemory hProc, ByVal lxprocLVITEM, ByVal VarPtr(LVITEM), LenB(LVITEM), 0
' Now send the message, but pass the address of the copy of our LV_ITEM that now exists in the foreign process instead of our local version
' Aigh Peeps this wha you need to change in order to higlight the item you want :)
lItemPos = Form1.Text7.Text ' first item
SendMessage hwnd, LVM_SETITEMSTATE, lItemPos, ByVal lxprocLVITEM
' Clean up
VirtualFreeEx hProc, ByVal lxprocLVITEM, LenB(LVITEM), MEM_RELEASE
CloseHandle hProc
End If
End If
End Function
February 16, 2008 at 2:52 pm #187765ChikeMemberIn EnumWindowsProc the code is
hwnd = FindWindow("dlggroupchat window class", Form1.Text1)
wtlsplitterwindow = FindWindowEx(dlggroupchatwindowclass, 0&, "wtl_splitterwindow", vbNullString)
and should be
dlggroupchatwindowclass = FindWindow("dlggroupchat window class", Form1.Text1)
wtlsplitterwindow = FindWindowEx(dlggroupchatwindowclass, 0&, "wtl_splitterwindow", vbNullString)
That’s for using basic and duplicating code 😛
February 16, 2008 at 4:51 pm #187764stevenMemberChike .. i dont know what i have to say more than thank you .. yah it works finaly .. thanks for all professionals and experts in this forum . am just looking for knowledge and skills .. but i was wondering how people doing all these applications .. now i can arrange the code and try to understand it from the begining as autopilot advice me before . thank you again Chike 😳
March 2, 2008 at 10:11 am #187763IMAFriendMemberI’m having problems getting even the basic stuff working. My gui looks great, now I’m trying to get the code to interact with paltalk.
I’m trying to get the list of users in a room to a listbox on my form. Seems basic enough.
When I try use API to count the (dummy data) number of items on my form’s listbox, it’s fine. vb.net gives the handle as an intptr, so I use lstPassages.handle.toint32.
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Dim LCount As Integer
LCount = SendMessage(lstPassages.Handle.ToInt32, LB_GETCOUNT, 0&, 0&)
That gives me a value of 8 in LCount, which is great.
But when I get my handle from the Paltalk syslistview32, and it seems to be the right handle, LCount gives me a value of 0. 🙁 I”m using
Dim dlggroupchatwindowclass As Integer, wtlsplitterwindow As Integer, atlfb As Integer
Dim syslistview As Integer
dlggroupchatwindowclass = FindWindow("dlggroupchat window class", vbNullString)
wtlsplitterwindow = FindWindowEx(dlggroupchatwindowclass, 0&, "wtl_splitterwindow", vbNullString)
wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "wtl_splitterwindow", vbNullString)
wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "wtl_splitterwindow", vbNullString)
wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "wtl_splitterwindow", vbNullString)
wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "wtl_splitterwindow", vbNullString)
atlfb = FindWindowEx(wtlsplitterwindow, 0&, "atl:006fb328", vbNullString)
syslistview = FindWindowEx(atlfb, 0&, "syslistview32", vbNullString)
Dim LCount As Integer
LCount = SendMessage(syslistview, LB_GETCOUNT, 0&, 0&)
All those lines are giving me reasonable numbers, and I get some number for syslistview that seems like it should be the right handle. Why can’t I even get a count? I haven’t gotten as far as getting items from the box yet, but if I can’t get a count, then I’m not on the right track.
Any help?
March 2, 2008 at 11:44 am #187762ChikeMemberIt’s not a list box, it’s a list view, use LVM_ messages codes.
March 3, 2008 at 3:56 am #187761IMAFriendMemberCool, now I’m getting started at least. It’s tough to find good info on this stuff.
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
And the docs seem to say for my four parameters, I need to use the handle, the LVM_GetItemText constant, the ‘selectedIndex’ type of property, and the LVMITEM structure (type) with the sendmessage.
How can I do that, the sendmessage is asking for lParam of int, not struct:LVMItem.
Can I just duplicate the sendmessage function?
-
AuthorPosts
Related
- You must be logged in to reply to this topic.