problem with wm_gettext

Visual Basic

    Sponsored Links

    Next

  • 1. Working in Hex
    Hi group, I must sum in hex, how can i do that? or just, can i convert dec to hex? Thanks, Rodolfo Fontes
  • 2. Opening a Project in Win XP
    When I open a new VB project in Win XP, it clears what ever I have in the Clipboard. Any body know a fix for this bug ? Thanks
  • 3. Size of EXE
    I'm working on VB6 project which already contains about 200 modules (forms, classes, standard modules). Many of them contain pretty big numbers of controls and lines of code. Compiled EXE has about 5 MB in size. My boss continues to ask for additional features which just increase the size of EXE. Am I going to have any problem if I continue to work with the same approach - add modules, code, controls? Thank you Al
  • 4. Print Picture Box Image
    Dear Group I have created a scrollable picture in my application, ie a picture box as a member of another picture box, a couple of scroll bars and now I have a scrollable bitmap image larger than my screen. I would now like to be able to print it but the only example of how to do this is Q230502 - How To Print a Form That Is Too Large for the Screen or Page. By following this example with my setup picture box within picture box, I can only print the visible area and not the entire picture. When I follow the example in the exercise it works, however the picture boxes are separate and not with one as a member of another. Can I print the entire bitmap image in my setup? The article states that: Because the PictureBox's bitmap is stored in a device context in memory, you have access to the entire bitmap regardless of what is displayed. Is this still true in my current setup? If it is not possible can the group think of a workaround? Thanks again... Kagsy
  • 5. VB6 - Proxy aware - how do I respond to Miicrosoft ISA with client credentials
    I have a VB6 program which runs fine at my more 'simple' clients. However some of my clients run Microsoft ISA Server, and this is blocking my VB program from connecting to my SQL Server database (across the internet). I have been told that the program needs to be more 'proxy aware' and responded to ISA Server with client credentials when requested by the proxy server. Can anyone explain to me how to do this, or better still, is there some sample code which demonstrates how to do this? Any help greatly appreciated. Garry

problem with wm_gettext

Postby Jim Bauer » Sun, 25 Apr 2004 03:57:00 GMT

Hello,
I am trying to get the text of a window by sending that window a
WM_GETTEXT message.
The below code compiles correctly, but the "buffer" string variable
I've declared is blank.

***CODE***
Private Declare Function SendMessage Lib "user32" Alias_
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam_
As Long, ByVal lParam As Long) As Long

Private Const WM_GETTEXT = &HD
Private Const wm_gettextlen = &HE

public function GetText(hwnd as long) as string
Dim buffer As String
SendMessage hwnd, WM_GETTEXT, wm_gettextlen, ByVal buffer
GetText = buffer
End Function

***END of code***
Any pointers as to what I'm doing wrong?
Cheers, Jim


Re: problem with wm_gettext

Postby Tom Esh » Sun, 25 Apr 2004 04:48:57 GMT

On Fri, 23 Apr 2004 18:57:00 GMT, Jim Bauer < XXXX@XXXXX.COM >




1) Your SendMessage declare is wrong for this case. lParam should be
ByVal As String, or simply As Any (specify ByVal in the call).

2) You must pre-allocate buffer to at least the number of chars
expected, iow at least what you tell it the size is in wParam. If
you've really no idea of the required size, you can use the
WM_GETTEXTLENGTH message. Note however this is a separate message and
requires a separate call. (Your wm_gettextlen const declare and usage
indicates you may be confused on this point.)

3) wParam should be the pre-allocated buffer size.

Ex:
Const WM_GETTEXT = &HD
Const WM_GETTEXTLENGTH = &HE
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
	(ByVal hWnd As Long, ByVal wMsg As Long, _
	ByVal wParam As Long, lParam As Any) As Long


Dim Buffer As String
Dim lSize As Long
Dim lRet As Long

lSize = SendMessage(hwnd, WM_GETTEXTLENGTH, 0&, ByVal 0&)
Buffer = String(lSize + 1, 0)
lRet = SendMessage(hwnd, WM_GETTEXT, lSize, ByVal Buffer)
If lRet > 0 Then
	Buffer = Left$(Buffer, lRet)
End If

-Tom
MVP - Visual Basic
(please post replies to the newsgroup)

Similar Threads:

1.Problem with WM_STETEXT WM_GETTEXT

I have written two standard apps (not ActiveX) in VB6 SP6.  These apps 
communicate with one another via SendMessage API utilizing hidden text boxes 
and WM_GETTEXT / WM_SETTEXT.

The scenario is the "server" app has a few hidden textboxes (channels) which 
it uses to send various commands to the "client" app.  When the server 
starts the client app (Shell, not ActiveX) it passes the wHnd to those 
textboxes as command line args.  The client app then while running (this app 
runs a never ending loop) at regular frequent intervals issues a SendMessage 
WM_GETXT to the various channels (depending on where in the processing loop 
it is) to get instructions from the server.  The client also issues 
SendMessage WM_SETTEXT messages (to a different window on the server) to 
provide status and progress info back to the server.

The problem is that it appears as though the client app hangs after issuing 
the WM_GETTEXT message until some event occurs on the client.  The event 
that I know will wake the client back up is a mouse_move over its form. 
This is a problem since the client has no reason to have a UI (it is a 
background process).  Any way here is the scenario; App1 (the server) starts 
and shell starts App2 (the client). App2 then goes into a polling loop 
polling the hidden text boxes on App1 for instructions.  For debugging 
purposes I have added a form to App2 that simply displays one text box for 
each hidden text box in App1 and populates those text boxes with the text 
commands received via SendMessage WM_GETTEXT calls.  With both windows 
(App1s and App2s) visible I click a button on App1 which sends a command to 
one of the hidden communication textboxes.  In the App2 window I should see 
the text displayed in the corresponding textbox.  I do not though, and 
infact it appears (from other debug messages which should but are not being 
shown in another textbox on App2) as though App2 is hung, however if I then 
move the mouse over App2's window the app un-hangs receives the command and 
continues.

Anyone have any thoughts on why this is happening?

Thanx in advance for your help
Steve 


2.no result with WM_GETTEXT

3.WM_GETTEXT hangs up

Hi all

I noticed that when I try to get text from one particular window calling 
SendMessage(hWnd, WM_GETTEXT...
the application hangs up until I close it using Task Manager.
For all other windows this call works fine.
The window's class = "Shell Embedding", invisible, RECT=0,0,0,0
Any ideas?
Definitely, I didn't have this problem yesterday, because I tested my 
application sending this message to all windows in the desktop tree (about 
1060 of them).
By the way I've got only one window of this class.

Thank you

4.WM_GETTEXT function

5.WM_GETTEXT

Hi all,

I'm trying to capture the text from a popup window (i.e. a MsgBox). The code
:

Const WM_GETTEXT = &HD
Const WM_GETTEXTLENGTH = &HE

Dim lHandle As Long
Dim length  As Long
Dim result  As Long
Dim strtmp  As String

lHandle = FindWindow(vbNullString, "Some Popup")

 If lHandle <> 0 Then

    length = SendMessage(lHandle, WM_GETTEXTLENGTH, ByVal 0, ByVal 0) + 1

    strtmp = Space(length - 1)
    result = SendMessage(lHandle, WM_GETTEXT, ByVal length, ByVal strtmp)

 End If

gives me the title of the popup window ('Some Popup') but not the msg on the
popup. How kan I get the message?


6. ***** PROBLEM SOLVED ***** PROBLEM SOLVED ***** PROBLEM SOLVED *****

7. Unknown pointer problem between Visual Basic and C (problem solved)

8. problems converting C# code to VB.net (MSMQ formatter problem)



Return to Visual Basic

 

Who is online

Users browsing this forum: No registered users and 44 guest