Solved

Lost / invisible cursor

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
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…
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

10 Experts available now in Live!

Get 1:1 Help Now