- - * - WhiteUnicorn - * - -




* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >


3136:Returning Default Cursor after Running Queries

KEYWORDS: query cursor hourglass AREA: General

Q: Why does the Mouse cursor not change back to an arrow after
 I do a Query?

A:  When performing an open on a query, Delphi will change the
 cursor for you, even in the middle of an event, such as a
 button click.The example below will cause the cursor to show
 as a SQL Hourglass Icon, after you close the showmessage
 dialog box. The Mouse will behave as if its in the arrow
 state.

    // Add to a button click event, the Query used does not
    // matter I used
    // Select * from Customer (on IBLocal)

    with query1 do begin
      close;
      open;
      showmessage(IntToStr(RecordCount));
      end; // with

What appears to be happening is that when Delphi tries to
change the Cursor back to the Arrow, a new form has already
been shown (the showmessage dialog) and so its job is done
as the cursor will automaticly be set to the arrow on the
showmessage dialog form.

To solve this problem, add a Application.ProcessMessages
before showing anew form, this will clear all pending
message commands from the message queue, and the Mouse
Cursor will appear normal again.

    // Add to a button click event, the Query used does
    // not matter I used
    // Select * from Customer (on IBLocal)

    with query1 do begin
      close;
      open;
      application.ProcessMessages;       // Add This Line.
      showmessage(IntToStr(RecordCount));
      end; // with

        TI



* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >



- - * - Anastasija aka WhiteUnicorn - * - - LJLiveJournal
PFPhotoFile