Solved

API (select text)

Posted on 1998-08-14
5
212 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now