?
Solved

to turn this code VB to Delphi code

Posted on 2003-02-19
8
Medium Priority
?
711 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month8 days, 3 hours left to enroll

765 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