Funny behaviour of mouse click...


This is a simple scenario but I can't figure why it happens and how to solve it:

There are 2 edit boxes in a form, with their Caption set as the original value, ie Edit1 and Edit2. Now, in the OnEnter event of Edit1 (chosen arbitrarily), this code is written

OK, now if we run this program, and first click on Edit2, so far so good. Now, if we click on Edit1, the message comes out, and if we press OK, the focus returns to Edit1. OK, notice that the text is being selected as the mouse moves...

How do prevent this? I don't want the select thing to occur, but instead want the cursor to remain still in the edit box.

My feeling is i have to trap for the mouse event. Any other ideas?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Change the autoselect to false and the text won't be selected during the onenter event of the Tedit box.

keithcslAuthor Commented:

sorry but it doesn't work. i have got a small exe file and if u r interested to test it out, that's great..

Can u send it to , I will take a look

HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

I think that OnEnter is the wrong event - try others like OnMouseUp, or OnClick, just see what you got there...

Good luck!

PS you can send me this too...
Just place the following after showmessage:
  PostMessage(edit1.handle, WM_LBUTTONUP,0,0);
regards, igor

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
keithcslAuthor Commented:
Thanks for the answer. I have actually tried the PostMessage but placed it before the ShowMessage rather than after. But it is working now...

PJDB, Matvey
I have sent u a copy of the .exe. Sorry I could not have sent it earlier...

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.