Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 8 of 8 total |
Hourglass Cursor |
Thu, Jun 8 2006 12:20 PM | Permanent Link |
Nathan | Is there a way to display an hourglass cursor while performing an SQL query? I have a database with 5 linked tables and am making a search form for the user. The matching
results are displayed in a wwDBGrid, but since the search is not instant, I want an hourglass cursor to display so the user knows the system is not hung up. I have the following code: //show hourglass cursor when querying the search form procedure TdtmMain.qrySearchResultsQueryProgress(Sender: TObject; PercentDone: Word; var Abort: Boolean); begin frmSearch.Cursor := -11; end; ////show the normal cursor when querying is done procedure TdtmMain.dsSearchResultsDataChange(Sender: TObject; Field: TField); begin frmSearch.Cursor := 1; end; However, the hourglass cursor does not display all the time. Only when the search button is clicked and the mouse moved quickly to the side afterwards, will the hourglass cursor show. When the search button is clicked and the mouse is not moved, or not move much, the basic cursor is only shown. Anyone know what is wrong, or a better way to do this? Thanks! |
Thu, Jun 8 2006 12:51 PM | Permanent Link |
"B Miller" | Here's what I do:
procedure TsomeForm.DoQuery; var Save_Cursor : TCursor; begin Save_Cursor := Screen.Cursor; Screen.Cursor := crHourGlass; try // set query info here someQuery.Active := true; finally Screen.Cursor := Save_Cursor; end; end; I don't make it part of the progress. I just save before and restore after. Regards, Bill "Nathan" <nathanm@canada.com> wrote in message news:62DC59CC-D54B-4D5D-8CFC-4EC276254EF9@news.elevatesoft.com... > Is there a way to display an hourglass cursor while performing an SQL > query? I have a database with 5 linked tables and am making a search form > for the user. The matching > results are displayed in a wwDBGrid, but since the search is not instant, > I want an hourglass cursor to display so the user knows the system is not > hung up. > > I have the following code: > //show hourglass cursor when querying the search form > procedure TdtmMain.qrySearchResultsQueryProgress(Sender: TObject; > PercentDone: Word; var Abort: Boolean); > begin > frmSearch.Cursor := -11; > end; > > ////show the normal cursor when querying is done > procedure TdtmMain.dsSearchResultsDataChange(Sender: TObject; > Field: TField); > begin > frmSearch.Cursor := 1; > end; > > However, the hourglass cursor does not display all the time. Only when > the search button is clicked and the mouse moved quickly to the side > afterwards, will the hourglass > cursor show. When the search button is clicked and the mouse is not > moved, or not move much, the basic cursor is only shown. > > Anyone know what is wrong, or a better way to do this? > Thanks! > |
Thu, Jun 8 2006 1:08 PM | Permanent Link |
> Only when the search button is clicked and the mouse moved quickly to
> the side afterwards, will the hourglass cursor show. The key is that the cursor is only picked up from the form when it moves. As Bill shows, you should alter screen.cursor. /Matthew Jones/ | |
Thu, Jun 8 2006 1:43 PM | Permanent Link |
"Robert" | "B Miller" <bmiller@nospam.com> wrote in message news:806A396E-2D13-4DDC-83E4-93CA7A708166@news.elevatesoft.com... > Here's what I do: > procedure TsomeForm.DoQuery; > var > Save_Cursor : TCursor; > begin > Save_Cursor := Screen.Cursor; > Screen.Cursor := crHourGlass; Actually, crSQLWait is more appropriate, IMO. Robert |
Fri, Jun 9 2006 10:49 AM | Permanent Link |
"B Miller" | Yes, I'm making changes to my code now. crSQLWait is more appropriate.
Thanks, Bill > Actually, crSQLWait is more appropriate, IMO. > > Robert > |
Fri, Jun 9 2006 12:03 PM | Permanent Link |
Nathan | Thanks! This is exactly what I needed. It seems to be working now...and I did use the crSQLWait cursor too like was suggested.
"B Miller" <bmiller@nospam.com> wrote: Here's what I do: procedure TsomeForm.DoQuery; var Save_Cursor : TCursor; begin Save_Cursor := Screen.Cursor; Screen.Cursor := crHourGlass; try // set query info here someQuery.Active := true; finally Screen.Cursor := Save_Cursor; end; end; I don't make it part of the progress. I just save before and restore after. Regards, Bill |
Fri, Jun 9 2006 11:25 PM | Permanent Link |
Oliver Bock | Nathan wrote:
> Is there a way to display an hourglass cursor while performing an SQL query? I have a database with 5 linked tables and am making a search form for the user. The matching > results are displayed in a wwDBGrid, but since the search is not instant, I want an hourglass cursor to display so the user knows the system is not hung up. The class below achieves this effect, but with less code each time you need to use it. The cursor will be reset as soon as the 'hourglass' variable goes out of scope or is set to nil, even if an exception occurs. To use it: var hourglass: IUnknown; begin hourglass := THourglassCursor.Create; ... whatever stuff you want to do end; type THourglassCursor = class(TInterfacedObject) private fOldCursor: TCursor; public constructor Create; destructor Destroy; override; end; constructor THourglassCursor.Create; begin inherited; fOldCursor := Screen.Cursor; // To force a change. Sometimes it thinks it's an arrow but is not // showing one. It then ignores the change to an hourglass. Screen.Cursor := crNone; Screen.Cursor := crHourglass; end; destructor THourglassCursor.Destroy; begin // Make sure no one's been fiddling. Assert(Screen.Cursor = crHourglass); Screen.Cursor := fOldCursor; inherited; end; |
Mon, Jun 12 2006 12:32 PM | Permanent Link |
Chris Erdal | "B Miller" <bmiller@nospam.com> wrote in
news:806A396E-2D13-4DDC-83E4-93CA7A708166@news.elevatesoft.com: > Here's what I do: > procedure TsomeForm.DoQuery; > var > Save_Cursor : TCursor; > begin > Save_Cursor := Screen.Cursor; > Screen.Cursor := crHourGlass; > try > // set query info here > someQuery.Active := true; > finally > Screen.Cursor := Save_Cursor; > end; > end; > I use your technique with a twist to allow nesting calls to the hourglass: 2 global variables in my universal MyRoutines.pas (not terribly OOP) Var WaitCursor_SC:TCursor; WaitCursor_Nb:Integer = 0; and a procedure to call in a try..finally block with either true or false to start or end the hourglass cursor: Procedure WaitCursor(Waiting:Boolean); begin if Waiting = true then begin if WaitCursor_Nb = 0 then // 1st time round only, to allow nesting WaitCursor_SC := Screen.Cursor; inc(WaitCursor_Nb); Screen.Cursor := crHourGlass; end else begin dec(WaitCursor_Nb); if WaitCursor_Nb = 0 then // reset only when 0 nested calls left Screen.Cursor := WaitCursor_SC; end; // Application.ProcessMessages; end; -- Chris |
This web page was last updated on Friday, September 20, 2024 at 05:39 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |