Tilted Forum Project Discussion Community  

Go Back   Tilted Forum Project Discussion Community > Interests > Tilted Technology


 
 
LinkBack Thread Tools
Old 09-17-2004, 10:09 PM   #1 (permalink)
Banned from being Banned
 
Location: Donkey
Win32 API Question about SendMessage & GETTEXT

I'm doing this from .NET, but I'm sure this problem is in standard C/C++ as well.

I'm having a hard time pulling text back from an object that contains more than 65k of text. I believe the magic # is 65535.

Here's the code I'm using (even if you don't know C#, it's still the same logic as in C/C++):

Code:
IntPtr txtLen = SendMessage(childCtrl, Vortex.WM_GETTEXTLENGTH, zeroval, zeroval);

					
StringBuilder text = new StringBuilder(txtLen.ToInt32() + 1);

SendMessage(childCtrl, Vortex.WM_GETTEXT, txtLen.ToInt32(), text);
System.Diagnostics.Debug.WriteLine(txtLen.ToString() + " - " + text.Length.ToString());
SendMessage is declared just fine, and it works until a certain point.

Say I'm pulling 65k of text back, once it gets past that, the "text" buffer seems to reset itself back to 0 and go from there. Once the thing is, say, 120k, the buffer, again, resets.

When it resets, it will only pull the first x chars from the window instead of the whole thing..

How do I snag ALL of the text in the window, or is that text size a limitation in the API?

I can watch the Debug.WriteLine section as the window's data gets bigger and bigger. The left number represents the size of data in the window while the right side is the size of the text after the API call. After the 65k, they no longer match and the right side resets.
__________________
I love lamp.

Last edited by Stompy; 09-17-2004 at 10:11 PM..
Stompy is offline  
Old 09-18-2004, 07:32 AM   #2 (permalink)
Banned from being Banned
 
Location: Donkey
What's even more strange is... I'm trying it in vb to see if it's just a limitation of .net or something, and the VB return value of WM_GETTEXTLENGTH is different (about 5k less) than what the .net SendMessage returns.

I'm completely baffled. How is this possible? How can one window return 66235 in .net but return 60123 in VB? It's the SAME handle, same function call, and same constant declarations.
__________________
I love lamp.
Stompy is offline  
Old 09-18-2004, 07:00 PM   #3 (permalink)
Tilted
 
Just a guess: the difference in length is probably from VB forcing it to Unicode; so it's adding buffer space in case there are double-byte characters in the text.

As for getting > 64k from WM_GETTEXT, I don't think it's possible. Isn't wparam defined as a uint (the actual API, I mean; not whatever it is in your declaration...)? 65535 should be the highest value you can give it. MSDN mentions getting > 64k back from Rich Edit Control using the EM_STREAMOUT message, but I don't think there's anything you can do for a TextBox.
magua is offline  
 

Tags
api, gettext, question, sendmessage, win32


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 08:35 AM.

Tilted Forum Project

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54