Solved

Lost / invisible cursor

Posted on 1997-09-08
1
187 Views
Last Modified: 2010-05-18
I have a problem in Delphi 1

When the user enters an editfield i need to show a dialogbox. I activate the dialogbox in the "OnEnter" event on the editfield. It works OK, but when the dialogbox is closed the edit field gives problems. It is possible to edit in the field but the cursor is not visible and you cannot see if the text is marked.

I have tried the methods "SetFocus", "Invalidate", "Refresh", "Repaint" after showing the dialogbox but I still have the problem.

If I manually tab to the next field and back, the field works OK. I have tried to do this from the program with the line "Perform(WM_NextDlgCtl,0,0)" to tab to next field and "Perform(WM_NextDlgCtl,1,0)" to tab back to the first field but that does not help.

Do you have a solution ?

0
Comment
Question by:janm
1 Comment
 
LVL 12

Accepted Solution

by:
andrewjb earned 150 total points
ID: 1344373
This is a bug in Delphi 1. If you display messages in an OnEnter or OnExit event ( or do certain other things that mess around with the cursor & focus ) delphi can lose the cursor completely.

The best, though not very elegant, solution is to use you own messages. In the OnEnter event, send a message to the form. It probably doesn't need any parameters with it.

In the form's message handler for that message, do whatever processing you need ( display the message etc. ) then set the focus back to the edit box.

E.g.

( This code is off the top of my head, so I'll probably get the syntax wrong. Tell me if you need exact details ... }


For the form :

  {Leave some room. Delphi uses some of the user messages itself}
MyMessage = WM_USER_BASE + 400;

TForm1 = class( TForm )
.....
protected
  procedure TrapMyMessage( var M : TMessage ) MESSAGE MyMessage;
...


procedure TrayMyMessage;
begin
  MessageBox( ... )
  Edit1.SetFocus;
end;

procedure Edit1.OnEnter( ... )
begin
  Form1.PostMessage( MyMessage , nil );
end;

( or something roughly like that! )

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi with SQL Natvie Client 15 86
Wininet read php file from internet issue 6 83
LAN or WAN ? 11 82
How to remove Recent Projects from Embarcadero C++ builder XE10. Berlin 2 33
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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 teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

863 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

26 Experts available now in Live!

Get 1:1 Help Now