Subject Re: [IBO] Cursory conundrum
Author Helen Borrie
At 11:13 PM 11/05/2003 +0000, you wrote:
>I have an TIB_SessionProps on my main form with UseCursor=true.
>
>When I call a certain modal form (which uses a TIB_Cursor to populate
>a TComboBox in its AfterFetchRow handler (with AutoFetchAll=true)), I
>get the crSQLWait cursor even when the fetching is complete. How can
>I get back the default cursor?
>
>I've tried setting the TIB_SessionProps->UseCursor=false before
>creating and showing the modal form, and I've manually attempted to
>set the modal forms' cursor to crDefault by adding a test button to
>the form, all without success.
>
>The crSQLWait only appears when mousing over the modal form, and is
>gone when the form closes, or I call another non-modal form (which
>initially has the crSQLWait cursor) to execute another query's Locate
>method. It then returns again if I use the cursor to fetch data for
>any other TComboBox, eg

OK, you have two different situations here. In the case of the modal form,
just do this:

procedure TMyForm.DisplayModalForm;
var
KeepCursor: TIB_ScreenCursor;
begin
..
try
KeepCursor := IB_Session.BusyCursor;
Session.BusyCursor := Screen.Cursor;
<might need to call Application.ProcessMessages if the UI has to do
something else before calling the modal process>
<create modal form and wait for Close request / response>
...
finally
IB_Session.BusyCursor := IB_Session.BusyCursor;
...
end;
end;


> IB_Cursor1->SQL->Clear();
> IB_Cursor1->SQL->Add("Select HDR_ID, HDRTXT from HDRTEXT order by
>HDRTXT");
> IB_Cursor1->First();
> IB_Cursor1->Unprepare();
>
>In AfterFetchRow(), I just use code like...
>
> sCat = IB_Cursor1->FieldByName("HDRTXT")->AsString;
> index = IB_Cursor1->FieldByName("HDR_ID")->AsInteger;
> Hdr1CB->Items->AddObject(sCat, (TObject*)index);
>
>
>Any suggestions please?

This one is a different situation. Generally, you want the Wait cursor
here and UseCursor is the way you achieve that. If you don't want the wait
cursor in this type of situation, either don't use UseCursor at all, or
override it as above.

If you want the whole thing to be seamless to the user, enclose the block
inside a BeginBusy() - EndBusy() pair so that the cursor doesn't
flicker. Again, use a try....finally sequence so that, regardless of what
else happens, the busy cursor gets switched off when the procedure completes.

Sorry if this is a bit *cursory*. I'm in a race against time right now...

cheers,
Helen

---------------------
See you at the First European Firebird Conference May 19-20 in Fulda,
Germany
http://www.firebird-conference.com