Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query regarding Hourglass cursor effect

Status
Not open for further replies.

CHeighlund

Programmer
Jun 11, 2007
163
0
0
US
I have been requested to add the 'hourglass' cursor to a project I worked on in the past. However, I am running into some strange problems getting this to work correctly.

I have seen the code examples given in this forum, but they do not appear to work for me. I believe this is because of the way the program was written - every function in it is called in linear fashion as needed from the on create event. All processing, file handling, and the final call to the program that uses the results of this one, are either done in or called from the on create segment.

Attempting to put the hourglass cursor code in there, even with 'application.processmesages' around it, did nothing. Is there any way to force the cursor to appear as an hourglass with this setup, or do I need to look for another way to show that something is being done?
 
Here's an example from a program I wrote that changes the cursor to the hour glass, maybe it will help you see where you should put your code.....

Code:
procedure TfrmMain.SelectPanels1Click(Sender: TObject);
var
Save_Cursor : TCursor;
begin
  Save_Cursor := Screen.Cursor;
  Screen.Cursor := crHourGlass;
  try
  with TfrmPanelSelect.Create(frmMain) do
  begin
    SelectDate := GetInputDate;
    if SelectDate <> '' then
    begin
      show;
    end
    else
      Destroy;
  end;
  finally
    Screen.Cursor := Save_Cursor;  { Always restore to normal }
  end;
end;


Leslie

Have you met Hardy Heron?
 
I thank you for the code sample, but as I've said, I'e already seen similar samples, and tried to follow them as my model. Perhaps I didn't make my earlier statements clear enough.

The form this is being called on never shows up. The OnCreate event starts processing the data, calls the program procedures which finish the processing and the generation of the output file, calls up a second program which takes in that output for its own purposes, then closes the program. All of this occurs before the form itself would ever show on the screen - the first real sign anything is occuring is when the second program (this one interactive) pops up on the screen. With a large enough input file, there can be ten or fifteen minutes between the time the original program was started and the time this occurs. During that time, I was requested to make the cursor an hourglass, but my own attempts, with code pretty much identical to yours, failed to do so. I believe (though I am not certain) that this happened (the hourglass failure) because the form never officially appeared.

Is there some way to force the hourglass to appear even if the form it is being called by does not? I think that is the basic question I am trying to ask here.
 
So you've put the Cursor on the OUTSIDE of the formCreate call? Have you tried putting it in the project file?

Leslie
 
I'm not sure what you're saying there. I created the TCursor variable as a form-level variable - was that a mistake?
 
I put this in and it kept the hourglass until I closed the form.

Code:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    Save_Cursor : TCursor;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Save_Cursor := Screen.Cursor;
  Screen.Cursor := crHourGlass;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  Screen.Cursor := Save_Cursor;
end;

end.


Leslie

Have you met Hardy Heron?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top