?
Solved

to turn this code VB to Delphi code

Posted on 2003-02-19
8
Medium Priority
?
730 Views
Last Modified: 2010-04-16
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
0
Comment
Question by:Megaing
  • 5
  • 3
8 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 90 total points
ID: 7982132
your consts em_ ... are already defined in delphi
your declarations are already defined in delphi

so you can easy use


procedure tform1.button1click(sender : tobject);
begin
  sendmessage(edit1.handle,em_stesel,0,-1);
  //or
  //edit1.perform(em_stesel,0,-1);
end;
 etc

meikl ;-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7982134
oops,
stesel should be setsel

:-))
0
 
LVL 21

Expert Comment

by:ziolko
ID: 7982147
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.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 21

Expert Comment

by:ziolko
ID: 7982167
as kretzschmar pointed out functions are in Windows.pas and consts are in Messages.pas
ziolko.
p.s. meikl U R faster again :-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7982471
at least, you are more complete, ziolko :-))
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7982949
but what will be textx for a object?
0
 
LVL 21

Expert Comment

by:ziolko
ID: 7990232
VB's Text is Delphi's TEdit.
ziolko.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7992737
i guessed that :-))
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This is an update to some code that someone else posted on Experts Exchange. It is an alternate approach, I think a little easier to use, & makes sure that things like the Task Bar will update.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Loops Section Overview
Suggested Courses
Course of the Month9 days, 19 hours left to enroll

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question