Solved

Lost / invisible cursor

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

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

752 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