Solved

Lost / invisible cursor

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month9 days, 19 hours left to enroll

623 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