Solved

API (select text)

Posted on 1998-08-14
5
223 Views
Last Modified: 2010-04-04
How can i disable the API for text selecting (mouse & keyboard)?
0
Comment
Question by:kort77
5 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1362097
disabling an API? which one, by name?
0
 
LVL 2

Expert Comment

by:333
ID: 1362098
Catch the message and set focus to another component.
0
 
LVL 8

Accepted Solution

by:
Answers2000 earned 50 total points
ID: 1362099
If you mean on an Edit control you want to prevent the user selecting text then the way to do it is whenever you get EN_SELCHANGE notification, immediately set the cursor to the beginning of the selection point (by sending EM_SETSEL message to the control).

One thing to watch out for is you're own EM_SETSEL messages may also trigger EN_SELCHANGE notifications (therefore getting you into an infinite loop).  Avoid this by only checking the selection (using EM_GETSEL) and only sending EM_SETSEL whenever something is selected.

0
 

Author Comment

by:kort77
ID: 1362100
I need that the code worrks in all the system, not just in one application
0
 
LVL 2

Expert Comment

by:333
ID: 1362101
The following code deselects all items in ListBox:

procedure TForm1.ListBox1Click(Sender: TObject);
begin
  SendMessage(ListBox1.Handle,lb_SetCurSel,-1,0);
end;

But there will be a gray rectangle around last selected item. To prevent this add to procedure something like

Button1.SetFocus;

to set focus on another control.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to convert wav to mp3 in delphi 9 200
Mobile Keyboard covers the display of the TMemo 3 86
Dev Express grid collapse 2 44
how to change, disabled button color FMX ? 1 32
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

770 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