473,692 Members | 2,965 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WaitCursor / hourglass in custom printpreview dialog

Hi,

I have created a simple custom PrintPreviewDia log consisting of a simple
standard PrintPreviewCon trol (.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(S ystem.Drawing.P rinting.PrintDo cument printDocument,
int zoom)
{
InitializeCompo nent();
_printDocument = printDocument;
_zoom = zoom;
}

private void PreviewDialog_L oad(object sender, System.EventArg s e)
{
this.Cursor = Cursors.WaitCur sor;
Initialize();
//this.Cursor = Cursors.Default ; // This gets hit instantly, so you
never see an hourglass.
}

private void Initialize()
{
uxPrintPreview. Anchor = AnchorStyles.Bo ttom | AnchorStyles.To p |
AnchorStyles.Le ft | AnchorStyles.Ri ght;
uxPrintPreview. Zoom = zoom;
this.WindowStat e = FormWindowState .Maximized;
uxPrintPreview. Document = printDocument1 = printDocument;
}

// The calling code:
using (PreviewDialog form = new PreviewDialog(c 1Report1.Docume nt))
{
form.ShowDialog (this);
}

If there was an event like LastPageFinishe d or DocumentRendere d or similar
in the PrintPreviewCon trol, 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 6368

private void PreviewDialog_L oad(object sender, System.EventArg s e)
{
this.Cursor = Cursors.WaitCur sor;
Initialize();
//this.Cursor = Cursors.Default ; // This gets hit instantly, so you
never see an hourglass.
}


You could try

Cursor.Current = Cursors.WaitCur sor;

Seems to be ok when I tried it.
Dec 19 '05 #2
using (PreviewDialog form = new PreviewDialog(c 1Report1.Docume nt))
{
this.Cursor = Cursors.WaitCur sor;
form.ShowDialog (this);
this.Cursor = Cursors.Default ;
}

--

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

"Lars" <no****@dev.nul l> wrote in message
news:11******** *****@corp.supe rnews.com...
Hi,

I have created a simple custom PrintPreviewDia log consisting of a simple
standard PrintPreviewCon trol (.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(S ystem.Drawing.P rinting.PrintDo cument printDocument,
int zoom)
{
InitializeCompo nent();
_printDocument = printDocument;
_zoom = zoom;
}

private void PreviewDialog_L oad(object sender, System.EventArg s e)
{
this.Cursor = Cursors.WaitCur sor;
Initialize();
//this.Cursor = Cursors.Default ; // This gets hit instantly, so you
never see an hourglass.
}

private void Initialize()
{
uxPrintPreview. Anchor = AnchorStyles.Bo ttom | AnchorStyles.To p |
AnchorStyles.Le ft | AnchorStyles.Ri ght;
uxPrintPreview. Zoom = zoom;
this.WindowStat e = FormWindowState .Maximized;
uxPrintPreview. Document = printDocument1 = printDocument;
}

// The calling code:
using (PreviewDialog form = new PreviewDialog(c 1Report1.Docume nt))
{
form.ShowDialog (this);
}

If there was an event like LastPageFinishe d or DocumentRendere d or similar
in the PrintPreviewCon trol, 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_L oad(object sender, System.EventArg s e)
{
this.Cursor = Cursors.WaitCur sor;
Initialize();
//this.Cursor = Cursors.Default ; // This gets hit instantly, so you
never see an hourglass.
}


You could try

Cursor.Current = Cursors.WaitCur sor;

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.Curso r =
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******** ******@TK2MSFTN GP14.phx.gbl...
using (PreviewDialog form = new PreviewDialog(c 1Report1.Docume nt))
{
this.Cursor = Cursors.WaitCur sor;
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.Curso r = 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.nul l> wrote in message
news:11******** *****@corp.supe rnews.com...

"carion1" <ddavis76 _at_ gmail _dot_ com> wrote in message
news:e7******** ******@TK2MSFTN GP14.phx.gbl...
using (PreviewDialog form = new PreviewDialog(c 1Report1.Docume nt))
{
this.Cursor = Cursors.WaitCur sor;
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.Curso r = 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******** ******@TK2MSFTN GP11.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2016
by: LARB | last post by:
Good morning, I have a print routine where I use a "printpreview dialog' control. The text is perfect BUT when I then print the job all the text is completely crazy, a bit like "wingdings".
1
2015
by: Randy | last post by:
Hello, I'm trying to print a simple string using the PrintPreviewDialog. I get the string to show up in the PrintPreview dialog, but when I click the Printer icon, it just prints a blank page. There's something I'm doing wrong. Can someone give me some code to print a simple string in the PrintPreview dialog box? Thanks
2
2424
by: seash | last post by:
H i had set WaitCursor for some processing in my application, This works fine for my Windowsform, but i want to extend this wait cursor to all other programs i.e only waitcursor(hourglass) should appear on my screen irrespective of Mouse position on any application on the screen when i move mouse cursor(hour glass) from out of my application it is changing to default cursor(with hour glass), i think it is normal. but i want the hourglass to...
2
10090
by: KarenP | last post by:
In my Windows Forms application, while executing a process that takes some time, I am changing the cursor to the hourglass by setting Cursor.Current = Cursors.WaitCursor. This is working just fine, except that any mouse events generated during this wait period (such as clicking on a button, etc.), get processed once the processing is complete. For example, while waiting for my task to complete, I click on a button (even though the...
2
3009
by: Lenster | last post by:
I am trying to show an hourglass mouse cursor and disable the main form whilst waiting for some activity to finish. The problem I have come across is that as soon as you disable the main form the cursor returns to the default arrow. Does anyone know of an alternative approach ? It can be easily simulated with a project containing a single form with a button and timer on as follows :
1
2034
by: veerleverbr | last post by:
Hi, In my VB.NET code, at a certain moment I set the cursor to the hourglass: Cursor = System.Windows.Forms.Cursors.WaitCursor Then a lot of things happen in my form, but also in other controls on the form or loaded in memory (but not actually on the form)... Afterwards, I set my cursor back to normal:
11
2360
by: Adam Right | last post by:
Hi, I am using .Net Framework 2.0 final, and i use .Net printing library to print a document. I use printPreview dialog to print the document but after preview was shown, when i press the "print" button, i cannot print the document although there is some words on the preview. So, is there a bug in the preview? Thanks...
1
1691
by: mtczx232 | last post by:
A. I remember microsoft add some features about WaitCursor in Window.Forms, but I not find it now? B. I have some Try..Catch in some module and it's suppose to be long time. I need to change cursor to hourglass. but I have two problem: 1. the function in module not have access to form, (unless I send me into the module function, but I not like it) 2. if occur err and control jump to catch block, I need to write extra code to return...
2
2105
by: eBob.com | last post by:
I have a print application modeled on a program which I found via this newsgroup. (I still have comments in German in it!) The model uses ExtendedPrintPreviewDialog but I don't seem to have that so I am using PrintPreviewDialog. It prints fine. But the PrintPreview dialog shows only one blank page. Before I resort to posting code, is there some simple and/or common mistake I could have made which would explain why PrintPreview shows...
0
8611
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8549
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8812
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7643
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6475
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4565
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2989
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2245
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1967
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.