Solved

Lost / invisible cursor

Posted on 1997-09-08
1
191 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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