Megaing
asked on
to turn this code VB to Delphi code
help me!
to turn this code VB to Delphi code......
Const EM_SETSEL As Long = &HB1
Const EM_UNDO As Long = &HC7
Const EM_CANUNDO As Long = &HC6
Const WM_COPY As Long = &H301
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) 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 Declare Function IsWindow Lib "user32" (ByVal hwnd 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 Sub Command1_Click()
SendMessage Text1.hwnd, EM_SETSEL, 0&, -1&
End Sub
Private Sub Command2_Click()
If SendMessage(Text1.hwnd, EM_CANUNDO, 0&, 0&) Then
SendMessage Text1.hwnd, EM_UNDO, 0&, 0&
End If
End Sub
Private Sub Command3_Click()
If Text1.SelLength = 0 Then
SendMessage Text1.hwnd, EM_SETSEL, 0&, -1&
End If
SendMessage Text1.hwnd, WM_COPY, 0&, 0&
End Sub
to turn this code VB to Delphi code......
Const EM_SETSEL As Long = &HB1
Const EM_UNDO As Long = &HC7
Const EM_CANUNDO As Long = &HC6
Const WM_COPY As Long = &H301
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) 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 Declare Function IsWindow Lib "user32" (ByVal hwnd 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 Sub Command1_Click()
SendMessage Text1.hwnd, EM_SETSEL, 0&, -1&
End Sub
Private Sub Command2_Click()
If SendMessage(Text1.hwnd, EM_CANUNDO, 0&, 0&) Then
SendMessage Text1.hwnd, EM_UNDO, 0&, 0&
End If
End Sub
Private Sub Command3_Click()
If Text1.SelLength = 0 Then
SendMessage Text1.hwnd, EM_SETSEL, 0&, -1&
End If
SendMessage Text1.hwnd, WM_COPY, 0&, 0&
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
const EM_SETSEL = $HB1;
EM_UNDO = $HC7
EM_CANUNDO = $HC6
WM_COPY = $H301
function FindWindowA(lpClassName, lpWindowName: PAnsiChar): HWND; stdcall;
function FindWindowEx(Parent, Child: HWND; ClassName, WindowName: PChar): HWND; stdcall;
function IsWindow(hWnd: HWND): BOOL; stdcall;
function SendMessage(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
procedure TForm1.Button1(Sender: Tobject);
begin
SendMessage(Text1.hwnd, EM_SETSEL,0,-1);
end;
procedure TForm1.Button2Click(Sender : TObject);
begin
if SendMessage(Text1.hwnd, EM_CANUNDO, 0, 0) then
SendMessage(Text1.hwnd, EM_UNDO, 0, 0);
end;
procedure TForm1.Button3Click(Sender : TObject);
begin
if Text1.SelLength = 0 then
SendMessage(Text1.hwnd, EM_SETSEL, 0, -1);
SendMessage(Text1.hwnd, WM_COPY, 0, 0);
end;
ziolko.
EM_UNDO = $HC7
EM_CANUNDO = $HC6
WM_COPY = $H301
function FindWindowA(lpClassName, lpWindowName: PAnsiChar): HWND; stdcall;
function FindWindowEx(Parent, Child: HWND; ClassName, WindowName: PChar): HWND; stdcall;
function IsWindow(hWnd: HWND): BOOL; stdcall;
function SendMessage(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
procedure TForm1.Button1(Sender: Tobject);
begin
SendMessage(Text1.hwnd, EM_SETSEL,0,-1);
end;
procedure TForm1.Button2Click(Sender
begin
if SendMessage(Text1.hwnd, EM_CANUNDO, 0, 0) then
SendMessage(Text1.hwnd, EM_UNDO, 0, 0);
end;
procedure TForm1.Button3Click(Sender
begin
if Text1.SelLength = 0 then
SendMessage(Text1.hwnd, EM_SETSEL, 0, -1);
SendMessage(Text1.hwnd, WM_COPY, 0, 0);
end;
ziolko.
as kretzschmar pointed out functions are in Windows.pas and consts are in Messages.pas
ziolko.
p.s. meikl U R faster again :-)
ziolko.
p.s. meikl U R faster again :-)
at least, you are more complete, ziolko :-))
but what will be textx for a object?
VB's Text is Delphi's TEdit.
ziolko.
ziolko.
i guessed that :-))
stesel should be setsel
:-))