|
-
Aug 6th, 2004, 03:35 AM
#1
Thread Starter
Addicted Member
How to simulate 'select all' trough API
Hi all,
I want to know if there is an API to use instead of Control_A.
I mean select all the text in a text area (not your own app) without sending the Control+A
Regards;
-
Aug 6th, 2004, 07:17 AM
#2
Lively Member
.
I did not test this, but may be worth a shot. Lookup EM_SETSEL.
VB Code:
'May want to experiment with parameter datatypes of SendMessage. Could make them integers.
Public 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
Public Const EM_SETSEL = &HB1
Dim Res as Long, hWnd as long, SelStart as long=0,SelEnd as Long=6
Res = SendMessage(hWnd,EM_SETSEL,SelStart,SelEnd)
'NOTE - You could use WM_GETTEXTLENGTH to find out how many characters are in the edit control
'// returns LRESULT in
'lResult = SendMessage(
'(HWND) hWndControl, // handle to destination 'control
'(UINT) EM_SETSEL, // message ID
'(WPARAM) wParam, // Start Character Position;
'(LPARAM) lParam // End Character Position );
I can do all things with VB.
-
Aug 6th, 2004, 07:40 AM
#3
Thread Starter
Addicted Member
It would be great if you can help
I'm trying to grab text from a program which apparently is written in Delphi. The control class is a Tpanel.
Could you help please?
Regards;
-
Aug 6th, 2004, 08:42 AM
#4
Lively Member
The first thing you have to do is get the handle of the control you want. This can be done several ways, but the best method depends on how you want your program to run.
If as a rule, the other program will be running and has the focus then using the api ChildWindowFromPoint may be good.
Now, you have to do some preliminary things to get to that point.
Ex:
VB Code:
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function ChildWindowFromPoint Lib "user32" Alias "ChildWindowFromPoint" (ByVal hWndParent As Long, ByVal pt As POINT) As Long
Public 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
Public Const EM_SETSEL = &HB1
Dim Res as Long, SelStart as long=0,SelEnd as Long=6
'Pass in the window titlebar value of the other program.
dim Handle as Long = FindWindow("","Titlebar Text") 'example only
'The window that you want to select text will most likely always be in the same position relative to the parent. So, figure out the relative coordinates of the window.
dim pt as New Point(75,90) 'example
dim TextHandle as long = ChildWindowFromPoint(Handle,pt)
Res = SendMessage(TextHandle,EM_SETSEL,SelStart,SelEnd)
Maybe someone else will have a cleaner way.
I can do all things with VB.
-
Aug 6th, 2004, 03:30 PM
#5
Thread Starter
Addicted Member
Thanks,
I tried the code but it didn't work, any other suggestion?
I must add that the text I'm trying to grab can be selected and copied, the problem is when I send control+A it will have a popup window wich dose not allow me to select all the text
Rehards;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|