753 // Returning TRUE means try to display the native print dialog 754 // which will either display an error message or prompt the 755 // user to install a printer. 756 return TRUE; 757 } 758 759 // Now, set-up the struct for the real calls to ::PrintDlg and ::CreateDC 760 761 pd.hwndOwner = hwndOwner; 762 pd.Flags = PD_ENABLEPRINTHOOK | PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE; 763 pd.lpfnPrintHook = (LPPRINTHOOKPROC)PrintDlgHook; 764 765 pd.nFromPage = (WORD)env->CallIntMethod(printCtrl, 766 AwtPrintControl::getFromPageID); 767 pd.nToPage = (WORD)env->CallIntMethod(printCtrl, 768 AwtPrintControl::getToPageID); 769 pd.nMinPage = (WORD)env->CallIntMethod(printCtrl, 770 AwtPrintControl::getMinPageID); 771 jint maxPage = env->CallIntMethod(printCtrl, 772 AwtPrintControl::getMaxPageID); 773 pd.nMaxPage = (maxPage <= (jint)((WORD)-1)) ? (WORD)maxPage : (WORD)-1; 774 // In the event that the application displays the dialog before 775 // installing a Printable, but sets a page range, then max page will be 1 776 // since the default state of a PrinterJob is an empty "Book" Pageable. 777 // Windows pops up an error dialog in such a case which isn't very 778 // forthcoming about the exact problem. 779 // So if we detect this fix up such a problem here. 780 if (pd.nMinPage > pd.nFromPage) pd.nMinPage = pd.nFromPage; 781 if (pd.nMaxPage < pd.nToPage) pd.nMaxPage = pd.nToPage; 782 if (pd.nFromPage > pd.nMinPage || pd.nToPage < pd.nMaxPage) { 783 pd.Flags |= PD_PAGENUMS; 784 } 785 786 if (env->CallBooleanMethod(printCtrl, 787 AwtPrintControl::getDestID)) { 788 pd.Flags |= PD_PRINTTOFILE; 789 } 790 791 jint selectType = env->CallIntMethod(printCtrl, 792 AwtPrintControl::getSelectID); 793 794 // selectType identifies whether No selection (2D) or 795 // SunPageSelection (AWT) 796 if (selectType != 0) { 797 pd.Flags |= selectType; 798 } 799 800 if (!env->CallBooleanMethod(printCtrl, 801 AwtPrintControl::getPrintToFileEnabledID)) { 802 pd.Flags |= PD_DISABLEPRINTTOFILE; 803 } 804 805 if (pd.hDevMode != NULL) { 806 DEVMODE *devmode = (DEVMODE *)::GlobalLock(pd.hDevMode); 807 DASSERT(!IsBadWritePtr(devmode, sizeof(DEVMODE))); 808 809 WORD copies = (WORD)env->CallIntMethod(printCtrl, 810 AwtPrintControl::getCopiesID); 811 if (copies > 0) { 812 devmode->dmFields |= DM_COPIES; | 753 // Returning TRUE means try to display the native print dialog 754 // which will either display an error message or prompt the 755 // user to install a printer. 756 return TRUE; 757 } 758 759 // Now, set-up the struct for the real calls to ::PrintDlg and ::CreateDC 760 761 pd.hwndOwner = hwndOwner; 762 pd.Flags = PD_ENABLEPRINTHOOK | PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE; 763 pd.lpfnPrintHook = (LPPRINTHOOKPROC)PrintDlgHook; 764 765 pd.nFromPage = (WORD)env->CallIntMethod(printCtrl, 766 AwtPrintControl::getFromPageID); 767 pd.nToPage = (WORD)env->CallIntMethod(printCtrl, 768 AwtPrintControl::getToPageID); 769 pd.nMinPage = (WORD)env->CallIntMethod(printCtrl, 770 AwtPrintControl::getMinPageID); 771 jint maxPage = env->CallIntMethod(printCtrl, 772 AwtPrintControl::getMaxPageID); 773 jint selectType = env->CallIntMethod(printCtrl, 774 AwtPrintControl::getSelectID); 775 pd.nMaxPage = (maxPage <= (jint)((WORD)-1)) ? (WORD)maxPage : (WORD)-1; 776 // In the event that the application displays the dialog before 777 // installing a Printable, but sets a page range, then max page will be 1 778 // since the default state of a PrinterJob is an empty "Book" Pageable. 779 // Windows pops up an error dialog in such a case which isn't very 780 // forthcoming about the exact problem. 781 // So if we detect this fix up such a problem here. 782 if (pd.nMinPage > pd.nFromPage) pd.nMinPage = pd.nFromPage; 783 if (pd.nMaxPage < pd.nToPage) pd.nMaxPage = pd.nToPage; 784 if (selectType != 0 && (pd.nFromPage > pd.nMinPage || pd.nToPage < pd.nMaxPage)) { 785 pd.Flags |= PD_PAGENUMS; 786 } 787 788 if (env->CallBooleanMethod(printCtrl, 789 AwtPrintControl::getDestID)) { 790 pd.Flags |= PD_PRINTTOFILE; 791 } 792 793 794 // selectType identifies whether No selection (2D) or 795 // SunPageSelection (AWT) 796 if (selectType != 0) { 797 pd.Flags |= selectType; 798 } 799 800 if (!env->CallBooleanMethod(printCtrl, 801 AwtPrintControl::getPrintToFileEnabledID)) { 802 pd.Flags |= PD_DISABLEPRINTTOFILE; 803 } 804 805 if (pd.hDevMode != NULL) { 806 DEVMODE *devmode = (DEVMODE *)::GlobalLock(pd.hDevMode); 807 DASSERT(!IsBadWritePtr(devmode, sizeof(DEVMODE))); 808 809 WORD copies = (WORD)env->CallIntMethod(printCtrl, 810 AwtPrintControl::getCopiesID); 811 if (copies > 0) { 812 devmode->dmFields |= DM_COPIES; |