• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 347
  • Last Modified:

How to get info from a PrintDialog box

I'm trying to get a couple of things from a PrintDialog box:  I need to know if the "All", "Pages", or "Selection" radio button has been pushed and, if the "Pages" radiobutton is pushed, what pages have been entered.

I use the following code to determine whether the OK button is pushed, but I can't find much help on the AllowPrintPages and AllowSelection properties.

                PrintDocument* pdoc = new PrintDocument();
      PrintDialog* pd = new PrintDialog();

      pd->Document = pdoc;

      if (pd->ShowDialog() == DialogResult::OK)
                {
                        etc.....
                }
0
restabro
Asked:
restabro
1 Solution
 
AlexFMCommented:
PrintDialog.PrinterSettings property returns PrinterSettings which contains this information.
0
 
restabroAuthor Commented:
That gets me a little closer, but please provide coding examples for the following conditions:

1.  Determining if the "All" button has been selected

2.  Determining if the "Pages" button has been selected

3.  If the "Pages" button has been selected, how to determine what the "From" page is

4.  Determining if the "Selection" button was pushed



Note that I increased the point total to 500. Thank you.

0
 
DanRollinsCommented:
These things are all clearly documented, including example code:
      http://windowssdk.msdn.microsoft.com/library/en-us/cpref29/html/T_System_Windows_Controls_PrintDialog_Members.asp
 
The "Pages" radio button was clicked if
   PrintDialog.UserPageRangeEnabled is true
   and PrintDialog.PrinterSettings.PageRangeSelection is PageRangeSelection.UserPages

The "Selection" radio button was clicked if
      PrintDialog.PrinterSettings.PageRangeSelection is not none

The "All" radio button was clicked if
      PrintDialog.PageRangeSelection is AllPages

The "Selection" radio button was clicked if
      PrintDialog.PageRangeSelection is not PageRangeSelection.None

The "From" is valid when
   PrintDialog.PageRangeSelection is PageRangeSelection.UserPages

   It can ve found by examining the first PageFom member of the first PageRange
   item in PrintDialog.PageRanges

-- Dan
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now