EM_GETLINE,Win32gui, address of buffer
Mark_Pryor
erlangen72 at hotmail.com
Tue Dec 18 21:23:56 EST 2001
Hi
Using 2.1.1 build 212 from AS
calling Win32gui.SendMessage( hwnd, cMes, wParam, lParam)
When I use the message, EM_GETLINE, the lParam calls for
an address of a string buffer. How do I prepare this buffer in Python?
tia,
Mark Pryor
--
ICQ 64329574
Pgp KeyID: 0x1A966EC5
Here is the script that I'm using. Its a hack to get the text of
the caret line in UltraEdit-32.
# begin WinEnum.py
import os, sys
import win32api as wi
import win32gui as ui
import win32con as wc
import re
myhwnd = 0
myti = ''
mycl = ''
def Callback(hwnd, skip):
global myhwnd
global myti
ti = ui.GetWindowText(hwnd)
if ti.find(skip) >=0:
myhwnd = hwnd
myti = ti
print hwnd, "uedit32 found",skip
return 0
else:
#print hwnd, ti
return 1
try:
ui.EnumWindows(Callback, "UltraEdit-32")
except:
print "error", myhwnd
#[^\[\]]
pat = re.compile('\[([^\[\]]*)\]')
mtch = pat.search(myti)
#os.path.basename(mtch.group(1))
mybase = mtch.group(1)
print "mybase=",mybase
mybase.strip()
# get the starting child window, that has the right edit control
#//////////////////////////////
myhwnd = ui.FindWindowEx(myhwnd,0, "MDICLIENT",'')
print "MDI", myhwnd
myhwnd = ui.FindWindowEx(myhwnd,0,0,mybase)
print "tab found",myhwnd
try:
myhwnd = ui.FindWindowEx(myhwnd,0,0,'')
print "frame found",myhwnd
except:
print "error", myhwnd
try:
myhwnd = ui.FindWindowEx(myhwnd,0,'EditControl','')
print "Edit control found",myhwnd
except:
print "error", myhwnd
# now we have the handle to the EditControl, get the line number
#///////////////////////////////////////////////
print myhwnd
res = ui.SendMessage(myhwnd,wc.EM_LINEINDEX,-1,0)
print "char number=",res
llen = ui.SendMessage(myhwnd,wc.EM_LINELENGTH,res,0)
res = ui.SendMessage(myhwnd,wc.EM_LINEFROMCHAR,res,0)
print wc.EM_LINEINDEX
print "line number=",res
# get the text in the edit line
#////////////// things fall apart here and UE crashes
mytext = ''
obj = ui.PyMakeBuffer( llen, 0)
#res = ui.SendMessage(myhwnd,wc.EM_GETLINE,res, obj )
print res, ui.PyGetString(obj)
--
ICQ 64329574
Pgp KeyID: 0x1A966EC5
More information about the Python-list
mailing list