?
Solved

Getting text from another program SendMessage? WM_GETTEXT

Posted on 2004-08-01
5
Medium Priority
?
813 Views
Last Modified: 2008-02-01
I am trying to get a large amount of text into my program, from a different program.   I have tried using:

SendMessage progHWND, WM_GETTEXT, 8192, sText

The problem I am having, is the limit to the size of the text buffer.  it's only letting me get a small portion of the text that I need.  Is there a different method that will allow me to get much more?  Or is there a way I can get portions of it at a time?

Thanks in advance.


0
Comment
Question by:TAF2000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11690302
Hi TAF2000,

Notice that there is a OS limitation in Edit Boxes. 0x7FFF for Win95/98/Me and 0x7FFFFFFF for WinNT/2000/XP
Read at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/editcontrols/editcontrolreference/editcontrolmessages/em_setlimittext.asp 

Good luck,
Jaime.
0
 
LVL 17

Accepted Solution

by:
zzzzzooc earned 1200 total points
ID: 11690329
>>The problem I am having, is the limit to the size of the text buffer.
Why don't you just increase the size of the buffer?

Form1:
-------------
Option Explicit

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Private Const WM_GETTEXT = &HD
Private Const WM_GETTEXTLENGTH = &HE
Private Sub Form_Load()
    Dim lngHandle As Long, strBuffer As String, lngLen As Long
    'fill our textbox with a lot of text...
    Text1.Text = String(10000, "a")
    'get the amount of text within it..
    lngHandle = Text1.hwnd
    lngLen = SendMessage(lngHandle, WM_GETTEXTLENGTH, 0, 0)
    'increase our buffer to accommodate the text we're about to get...
    strBuffer = Space(lngLen)
    'get text...
    Call SendMessage(lngHandle, WM_GETTEXT, lngLen, ByVal strBuffer)
    'print to debug...
    Debug.Print strBuffer
End Sub



Mind you, controls may have their own limitations. TextBox limits are around 65k.
0
 

Author Comment

by:TAF2000
ID: 11690339
yes, the limt im having problems with is not max int (2147483647) that you refered too..
it is a much lower limitation caused by the string buffer:

Dim sText As String * 8192

it will not let you create a very large string..

so.. is there a way to get around this?  using something else in the sendmessage command?

Thanks
0
 

Author Comment

by:TAF2000
ID: 11690346
zzzzzooc,
just saw your message after replying to jaime's comment.  Will give it a shot.
0
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 11692593
Oh, one more comment. lngLen may need to be lngLen + 1:

If lngLen > 0 Then
    lngLen = lngLen + 1
    'etc...
End If
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month12 days, 9 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question