Using win32gui.SendMessage and SysListView32 control

G

geskerrett

Hope someone can steer me in the right direction.

I am trying to use python to collect the values from a Win32
application's control.
I can successfull query an retreive the values ListBox, Edit and
Buttons, however, the application uses a control called a
'SysListView32' Control. MSDN says that this descends from CListView
control and the msdn website reference for this control is;
http://msdn2.microsoft.com/en-gb/library/ms670560.aspx
(scroll to the message constants)

This page seems to imply that the control can be queried with messages,
however, my problem seems to be that pywin32.win32con does not define a
constant for the LVM series of messages.

Any other suggestions ??

I am looking for something similar to code below which does a fine job
of collecting all of the text values from a "ListBox" control;

count = win32gui.SendMessage(hndl,win32con.LB_GETCOUNT)
vals = []
for i in range(count):
strlen = win32gui.SendMessage(hndl,win32con.LB_GETTEXTLEN)
text = ' '*(strlen+1) #Buffer for returned text -50
characters
lentext =
win32gui.SendMessage(hndl,win32con.LB_GETTEXT,i,text)
txt = text[0:lentext]
print "Hndl: %8s Class: %-10s TxtLen:%3s TxtVal: %s " %
(hndl,clname,lentext,txt)
vals.append(txt.strip())

Thanks in advance.
 
N

Neil Hodgson

(e-mail address removed):
This page seems to imply that the control can be queried with messages,
however, my problem seems to be that pywin32.win32con does not define a
constant for the LVM series of messages.

These are defined in win32/lib/commctrl.py in my installation.

Neil
 
J

jUrner

Hope someone can steer me in the right direction.

I am trying to use python to collect the values from a Win32
application's control.
I can successfull query an retreive the values ListBox, Edit and
Buttons, however, the application uses a control called a
'SysListView32' Control. MSDN says that this descends from CListView
control and the msdn website reference for this control is;
http://msdn2.microsoft.com/en-gb/library/ms670560.aspx
(scroll to the message constants)

This page seems to imply that the control can be queried with messages,
however, my problem seems to be that pywin32.win32con does not define a
constant for the LVM series of messages.

All the relevant message ids are in comCtl.h a 340k file. This might
explain why
win32con does only cover some ids. Best is to download and install the
platform sdk,
wich you may get for free from Microsoft. It comes shipped along with
all the headers
and the complete documentation for all the apis windows offers the
dedicated programmer.

http://www.microsoft.com/downloads/...35-C656-4969-ACE8-E4C0C0716ADB&displaylang=en


And ...just a hint, check the ctypes module, wich will give you full
access to all the
apis windows has to offer and lets you translate C code almost 1:1 to
python.

Regards Jürgen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,044
Latest member
RonaldNen

Latest Threads

Top