LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
clu clu is offline
external usenet poster
 
Posts: 4
Default GetText Client Access AS400 window API Help

I am trying to get text from an AS400 session. I have tried many
different approaches from SendMessage to GetDlgItemText. I have
succeeded in using Edit Copy by customizing the keyboard in AS400 and
using API Keyboard events to copy the window to the clipboard and then
get the text using API clipboard calls. While this approach works I am
determined to avoid the windows clipboard and to get the text by some
other means that will avoid having to map the keyboard and use the
windows clipboard.

After searching and testing solutions found in the groups I decided to
ask for help. I have successfully used the code below to get text from
notepad but when trying it with Client Access AS400 window I get a
value of 1 for text length and null for text. I am able to get the
handle for the parent and the child window. I am more interested in
this as an exercise to understand how to use API calls to get the text
that is displayed in this window as my original code works well. This
understanding of how to retrieve text from this window will assist me
in getting text from other child windows that are inaccessible from the
edit copy command.

Thank you in advance.

Option Explicit
Private Declare Function GetDlgItemText Lib "user32" Alias
"GetDlgItemTextA" _
(ByVal hDlg As Long, ByVal nIDDlgItem As Long, ByVal lpString As
String, _
ByVal nMaxCount As Long) As Long
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 Declare Function FindWindowEx _
Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, _
ByVal hWnd2 As Long, _
ByVal lpsz1 As String, _
ByVal lpsz2 As String) As Long
Private Const WM_GETTEXTLENGTH = &HE
Private Const WM_GETTEXT = &HD

Sub GetTextTest()
Dim mlngHandle As Long
Dim mlngRetVal As Long
Dim mstrBuf As String
mlngHandle = FindWindow("PCSWS:Main:00400000", vbNullString)
If mlngHandle < 0 Then
mstrBuf = String(1024, 0)
MsgBox mstrBuf
mlngRetVal = GetDlgItemText(mlngHandle, 2, mstrBuf, 1023)
If mlngRetVal 0 Then
mstrBuf = Left$(mstrBuf, mlngRetVal)
Debug.Print mstrBuf
End If
End If
End Sub

Sub GetTextTest2()
Dim mlngHandle As Long
Dim mlngRetVal As Long
Dim mstrText As String
'
mlngHandle = FindWindowEx(FindWindow("PCSWS:Main:00400000",
vbNullString), 0, "PCSWS:Pres:00400000", vbNullString) 'handle for
text window
mlngRetVal = SendMessage(mlngHandle, WM_GETTEXTLENGTH, 0&, ByVal
0&) + 1
Debug.Print mlngRetVal
'
If mlngRetVal 0 Then 'there is text
mstrText = Space$(mlngRetVal)
Debug.Print mstrText
mlngRetVal = SendMessage(mlngHandle, WM_GETTEXT, mlngRetVal,
ByVal mstrText)
mstrText = Left(mstrText, mlngRetVal)
Debug.Print "-" & mstrText & "-"
MsgBox "-" & mstrText & "-"
End If
End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to GetText() from TextBox under Visual C++ application? Danil Excel Worksheet Functions 0 August 31st 07 11:38 AM
Client Access to iSeries Automation Leslie Excel Programming 10 March 24th 06 03:25 PM
Excel, client access & AS400 Fwed Excel Programming 5 January 30th 06 04:11 PM
Download from Client Access to Excel Archie Excel Discussion (Misc queries) 0 May 5th 05 01:51 PM
Clipboard.GetText Charlie Excel Programming 3 March 28th 05 08:11 PM


All times are GMT +1. The time now is 09:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"