problem with wm_gettext

Visual Basic

    Sponsored Links


  • 1. Compiling VB projects
    Hi all, Is there a way to compile vb6 projects through the command line using a batch file? What I require is that the projects are compiled using the default settings of the vbp and that I can change one or more conditional compilation argument values. Any clues? Thanks, Ivan
  • 2. Connecting A DataGrid To SQL Server Result?
    I use the following code to look at my data returned from an Access table in a VB 6 DataGrid. When I switch to SQL Server I get the error "The rowset is not bookmarkable". What the heck does that mean and how do I fix it? ======================================== Set fBrowse = New frmBrowse Load fBrowse Set fBrowse.DataGrid1.DataSource = rs fBrowse.Show vbModal fBrowse.Hide Unload fBrowse ======================================== Thanks for the help.....again.
  • 3. Placing app in the startup lineup
    Hello, Is there some way to place my app to be invoked as the last application on Windows startup?
  • 4. Universal hex to string conversion (DBCS, ASCII, etc!)
    I'm having the most perplexing problem converting hex to a string and getting the same data when using DBCS (Japanese, etc.) versions of Windows. Basically I want to be able to convert hex to a "binary" string (not Byte) that works on both ASCII, DBCS and preferrably all versions of Windows. StrConv and Unicode must play a role here, but after studying this stuff, I cannot for the life of me understand when and where to use it. This is an example of typical hex I want to convert... "36373A789CF34C53A8CC2F55484ECC53284A4D4C5128C9C82CAEC92C51C82C5628CF2FCACECC4BAF714BCC294EAD31343236313533B7B03480024B132820200D9F14A2" I'm using the following function, which works perfect on USA systems. If I run it on Japanese Windows, part of the output is correct, but several characters come back as just spaces, as if there are characters not supported. Private Function changetoasc(strtochange$) On Error Resume Next Dim nextchra As String, inptxt$, lenth%, numspc%, newsent$, nextchr$ Let inptxt$ = strtochange$ Let lenth% = Len(inptxt$) Let numspc% = numspc% + 1 Do While numspc% <= lenth% - 1 Let nextchr$ = Mid$(inptxt$, numspc%, 2) Let numspc% = numspc% + 2 nextchra = "&H" & nextchr$ nextchra = ChrW$(CInt(nextchra)) Let newsent$ = newsent$ + (nextchra) Loop changetoasc = newsent$ End Function Any help would be greatly appreciated!!!
  • 5. Help: VB6 Connecting To SQL Server & Record Count
    I am converting some VB6 code from accessing an Access database to accessing an SQL Table. I have it working except I need to be able to know exactly # the number of record returned in my result set. Here is my code: ==================================================================== Set cn1 = New Connection With cn1 .Provider = "SQLOLEDB.1" .ConnectionString = "User ID=sa;password=sa;Initial Catalog=Mecklenburg;Data Source = (local);Use Procedure for Prepare= 1;Auto Translate=True;Packet Size=4096" .Open End With Set rs = New Recordset ssql = "SELECT * " & _ "FROM Members " & _ "Where (not (LastName is Null)) " & _ "ORDER BY LastName, FirstName, MiddleName" rs.Open ssql, cn1, adOpenStatic, adLockOptimistic Current_Record = 0 rs.MoveFirst Record_Count = 0 Do While Not rs.EOF Record_Count = Record_Count + 1 rs.MoveNext Loop rs.MoveFirst rs.Close ' Close this recordset How should I connect to the SQL table to be able to retrieve the record count OR should I just include the count(*) function in my sql statement? Thanks. Chris

problem with wm_gettext

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

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.

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.

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

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

Similar Threads:


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

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 

Anyone have any thoughts on why this is happening?

Thanx in advance for your help
Steve 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


Hi all,

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


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?


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

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

Return to Visual Basic


Who is online

Users browsing this forum: No registered users and 23 guest