Solved

API (select text)

Posted on 1998-08-14
5
235 Views
Last Modified: 2010-04-04
How can i disable the API for text selecting (mouse & keyboard)?
0
Comment
Question by:kort77
[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 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

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!

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…

751 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