471,316 Members | 1,056 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,316 software developers and data experts.

WaitCursor / hourglass in custom printpreview dialog

Hi,

I have created a simple custom PrintPreviewDialog consisting of a simple
standard PrintPreviewControl (.NET 1.1) on a WindowsForm with a few buttons
(for printing, zooming, etc.). It is working fine, except for that I cannot
figure out how display the waitcursor / hourglass while the preview is
preparing to show the document *and then go back to the default cursor when
the document is displayed*. Turning on the waitcursor is easy, but what
event should I hook into to turn it off??

What happens when I preview a document that is about 50 pages long is that
you get the blank form on the screen and then nothing happens for maybe 40
seconds and then you get a "Generating Preview" message and then the
document is displayed. It is during the initial 40 seconds that I need an
hourglass or something to let the users know that something is happening in
the background.

Here are some snippets of what I am doing currently:

// Constructor:
public PreviewDialog(System.Drawing.Printing.PrintDocumen t printDocument,
int zoom)
{
InitializeComponent();
_printDocument = printDocument;
_zoom = zoom;
}

private void PreviewDialog_Load(object sender, System.EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
Initialize();
//this.Cursor = Cursors.Default; // This gets hit instantly, so you
never see an hourglass.
}

private void Initialize()
{
uxPrintPreview.Anchor = AnchorStyles.Bottom | AnchorStyles.Top |
AnchorStyles.Left | AnchorStyles.Right;
uxPrintPreview.Zoom = zoom;
this.WindowState = FormWindowState.Maximized;
uxPrintPreview.Document = printDocument1 = printDocument;
}

// The calling code:
using (PreviewDialog form = new PreviewDialog(c1Report1.Document))
{
form.ShowDialog(this);
}

If there was an event like LastPageFinished or DocumentRendered or similar
in the PrintPreviewControl, I would be home free, but I cannot find anything
like that.

Any help on this would be greatly appreciated.

Thanks,
Lars



Dec 18 '05 #1
6 6226

private void PreviewDialog_Load(object sender, System.EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
Initialize();
//this.Cursor = Cursors.Default; // This gets hit instantly, so you
never see an hourglass.
}


You could try

Cursor.Current = Cursors.WaitCursor;

Seems to be ok when I tried it.
Dec 19 '05 #2
using (PreviewDialog form = new PreviewDialog(c1Report1.Document))
{
this.Cursor = Cursors.WaitCursor;
form.ShowDialog(this);
this.Cursor = Cursors.Default;
}

--

Derek Davis
dd******@gmail.com

"Lars" <no****@dev.null> wrote in message
news:11*************@corp.supernews.com...
Hi,

I have created a simple custom PrintPreviewDialog consisting of a simple
standard PrintPreviewControl (.NET 1.1) on a WindowsForm with a few
buttons (for printing, zooming, etc.). It is working fine, except for
that I cannot figure out how display the waitcursor / hourglass while the
preview is preparing to show the document *and then go back to the default
cursor when the document is displayed*. Turning on the waitcursor is
easy, but what event should I hook into to turn it off??

What happens when I preview a document that is about 50 pages long is that
you get the blank form on the screen and then nothing happens for maybe 40
seconds and then you get a "Generating Preview" message and then the
document is displayed. It is during the initial 40 seconds that I need an
hourglass or something to let the users know that something is happening
in the background.

Here are some snippets of what I am doing currently:

// Constructor:
public PreviewDialog(System.Drawing.Printing.PrintDocumen t printDocument,
int zoom)
{
InitializeComponent();
_printDocument = printDocument;
_zoom = zoom;
}

private void PreviewDialog_Load(object sender, System.EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
Initialize();
//this.Cursor = Cursors.Default; // This gets hit instantly, so you
never see an hourglass.
}

private void Initialize()
{
uxPrintPreview.Anchor = AnchorStyles.Bottom | AnchorStyles.Top |
AnchorStyles.Left | AnchorStyles.Right;
uxPrintPreview.Zoom = zoom;
this.WindowState = FormWindowState.Maximized;
uxPrintPreview.Document = printDocument1 = printDocument;
}

// The calling code:
using (PreviewDialog form = new PreviewDialog(c1Report1.Document))
{
form.ShowDialog(this);
}

If there was an event like LastPageFinished or DocumentRendered or similar
in the PrintPreviewControl, I would be home free, but I cannot find
anything like that.

Any help on this would be greatly appreciated.

Thanks,
Lars


Dec 19 '05 #3
>> private void PreviewDialog_Load(object sender, System.EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
Initialize();
//this.Cursor = Cursors.Default; // This gets hit instantly, so you
never see an hourglass.
}


You could try

Cursor.Current = Cursors.WaitCursor;

Seems to be ok when I tried it.

No, that does not make a difference. The problem is not to change to a
WaitCursor, but rather to know when to change it back to a default cursor.
For example, in my snippet above, I commented out "this.Cursor =
Cursors.Default" since it gets hit almost instantly (way before the page is
rendered), so you never see an hourglass.
Dec 19 '05 #4

"carion1" <ddavis76 _at_ gmail _dot_ com> wrote in message
news:e7**************@TK2MSFTNGP14.phx.gbl...
using (PreviewDialog form = new PreviewDialog(c1Report1.Document))
{
this.Cursor = Cursors.WaitCursor;
form.ShowDialog(this);
this.Cursor = Cursors.Default;
}

--

Derek Davis
dd******@gmail.com


If you read my post again, you'll see that I intentionally commented out
"this.Cursor = Cursors.Default;" since it does not work were it is. That
line gets hit almost instantly (way before the page is rendered), so you
never see an hourglass. What I am looking for is a a place to put that line
so that it gets hit AFTER the delay that takes place (while the preview
control is preparing the document to be viewed, or whatever it is doing).
In other words: before calling the preview control, I want to turn on the
hourglass and when the document is displayed in the preview I want to turn
off the hourglass.

Lars
Dec 19 '05 #5
The code I posted was the "calling" code. Could move the Cursor changes
outside of the using statement if you like.

--

Derek Davis
dd******@gmail.com

"Lars" <no****@dev.null> wrote in message
news:11*************@corp.supernews.com...

"carion1" <ddavis76 _at_ gmail _dot_ com> wrote in message
news:e7**************@TK2MSFTNGP14.phx.gbl...
using (PreviewDialog form = new PreviewDialog(c1Report1.Document))
{
this.Cursor = Cursors.WaitCursor;
form.ShowDialog(this);
this.Cursor = Cursors.Default;
}

--

Derek Davis
dd******@gmail.com


If you read my post again, you'll see that I intentionally commented out
"this.Cursor = Cursors.Default;" since it does not work were it is. That
line gets hit almost instantly (way before the page is rendered), so you
never see an hourglass. What I am looking for is a a place to put that
line so that it gets hit AFTER the delay that takes place (while the
preview control is preparing the document to be viewed, or whatever it is
doing). In other words: before calling the preview control, I want to turn
on the hourglass and when the document is displayed in the preview I want
to turn off the hourglass.

Lars

Dec 19 '05 #6

"carion1" <ddavis76 _at_ gmail _dot_ com> wrote in message
news:ur**************@TK2MSFTNGP11.phx.gbl...
The code I posted was the "calling" code. Could move the Cursor changes
outside of the using statement if you like.


I understand. The problem with that approach is that ShowDialog() does not
return until the preview window is closed. So even after the document is
rendered and displayed, the cursor remains an hourglass.

Lars
Dec 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Randy | last post: by
2 posts views Thread by seash | last post: by
2 posts views Thread by KarenP | last post: by
2 posts views Thread by Lenster | last post: by
1 post views Thread by veerleverbr | last post: by
11 posts views Thread by Adam Right | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.