📄 gvwprn.c
字号:
{
if (psfile.dsc != (CDSC *)NULL) {
int i;
psfile.page_list.current = psfile.pagenum;
psfile.page_list.multiple = TRUE;
if (psfile.page_list.select == (BOOL *)NULL)
return FALSE;
for (i=0; i<(int)(psfile.dsc->page_count); i++)
if (psfile.page_list.select[i]) {
psfile.page_list.current = i;
break;
}
return DialogBoxParamL(hlanguage, MAKEINTRESOURCE(IDD_MULTIPAGE),
hwnd, (DLGPROC)PageMultiDlgProc, (LPARAM)NULL);
}
if ((psfile.dsc == (CDSC *)NULL) || psfile.dsc->page_count == 0 ) {
/* all pages */
psfile.print_from = 1;
psfile.print_to = 999999;
}
else {
psfile.print_from = 1;
psfile.print_to = psfile.dsc->page_count;
}
psfile.print_oddeven = ALL_PAGES;
/* pfile.print_ignoredsc = FALSE; enabled only if DSC && PrintGDI */
/* psfile.page_list.reverse = FALSE; enabled only if DSC && GS device */
/* option.print_reverse set when printing and psfile.page_list.reverse */
if (DialogBoxParamL(hlanguage, MAKEINTRESOURCE(IDD_PAGERANGE), hwnd,
PageRangeDlgProc, (LPARAM)method) == IDOK) {
set_page_range();
return TRUE;
}
return FALSE;
}
void init_fixed_media(HWND hDlg, int id, int fixed_media)
{
TCHAR buf[MAXSTR];
/* Fill in Page Size combo box */
lstrcpy(buf, TEXT("Variable"));
load_string(IDS_PAGESIZE_VARIABLE, buf, sizeof(buf));
SendDlgItemMessageL(hDlg, id, CB_ADDSTRING, 0,
(LPARAM)((LPTSTR)buf));
lstrcpy(buf, TEXT("Fixed"));
load_string(IDS_PAGESIZE_FIXED, buf, sizeof(buf));
SendDlgItemMessageL(hDlg, id, CB_ADDSTRING, 0,
(LPARAM)((LPTSTR)buf));
lstrcpy(buf, TEXT("Shrink"));
load_string(IDS_PAGESIZE_SHRINK, buf, sizeof(buf));
SendDlgItemMessageL(hDlg, id, CB_ADDSTRING, 0,
(LPARAM)((LPTSTR)buf));
SendDlgItemMessage(hDlg, id, CB_SETCURSEL, fixed_media, 0L);
}
/* dialog box for selecting print/convert device and resolution */
BOOL CALLBACK _export
NewDeviceDlgProc(HWND hDlg, UINT wmsg, WPARAM wParam, LPARAM lParam)
{
char buf[128];
int i, idevice;
WORD notify_message;
char *p;
char *res;
char *s;
char entry[MAXSTR];
struct prop_item_s *proplist;
static BOOL bConvert; /* TRUE if convert, FALSE if printing */
PROFILE *prf;
switch (wmsg) {
case WM_INITDIALOG:
bConvert = (BOOL)lParam;
p = get_devices(bConvert);
res = p; /* save for free() */
while ( p!=(char *)NULL && strlen(p)!=0) {
SendDlgItemMessageA(hDlg, DEVICE_NAME, CB_ADDSTRING, 0,
(LPARAM)((LPSTR)p));
p += strlen(p) + 1;
}
free(res);
s = bConvert ? option.convert_device : option.printer_device;
if (SendDlgItemMessageA(hDlg, DEVICE_NAME, CB_SELECTSTRING, 0,
(LPARAM)(LPSTR)(s)) == CB_ERR) {
if (strlen(s))
SetDlgItemTextA(hDlg, DEVICE_NAME, s);
else
SendDlgItemMessageA(hDlg, DEVICE_NAME, CB_SETCURSEL, 0, 0L);
}
/* force update of DEVICE_RES */
s = bConvert ? option.convert_resolution : option.printer_resolution;
SendDlgNotification(hDlg, DEVICE_NAME, CBN_SELCHANGE);
if (SendDlgItemMessageA(hDlg, DEVICE_RES, CB_SELECTSTRING, 0,
(LPARAM)(LPSTR)(s)) == CB_ERR) {
if (strlen(s))
SetDlgItemTextA(hDlg, DEVICE_RES, s);
else
SendDlgItemMessage(hDlg, DEVICE_RES, CB_SETCURSEL, 0, 0L);
}
/* Fill in Page Size combo box */
init_fixed_media(hDlg, DEVICE_FIXEDMEDIA,
bConvert ? option.convert_fixed_media : option.print_fixed_media);
/* Uniprint button only when printing */
if (bConvert)
ShowWindow(GetDlgItem(hDlg, DEVICE_UNIPRINT), FALSE);
/* fill in page list box */
if (bConvert) {
if ( (psfile.dsc != (CDSC *)NULL) && (psfile.dsc->page_count != 0)) {
psfile.page_list.current = psfile.pagenum-1;
psfile.page_list.multiple = TRUE;
for (i=0; i< (int)psfile.dsc->page_count; i++)
psfile.page_list.select[i] = TRUE;
psfile.page_list.select[psfile.page_list.current] = TRUE;
psfile.page_list.reverse = option.print_reverse;
if (GetDlgItem(hDlg, PAGE_LIST) != (HWND)NULL)
PageMultiDlgProc(hDlg, wmsg, wParam, lParam);
}
else {
TCHAR tbuf[MAXSTR];
LPTSTR t;
psfile.page_list.multiple = FALSE;
EnableWindow(GetDlgItem(hDlg, PAGE_ALL), FALSE);
EnableWindow(GetDlgItem(hDlg, PAGE_ODD), FALSE);
EnableWindow(GetDlgItem(hDlg, PAGE_EVEN), FALSE);
EnableWindow(GetDlgItem(hDlg, PAGE_REVERSE), FALSE);
load_string(IDS_ALL, tbuf, sizeof(tbuf));
for (t=tbuf, i=0; *t; t++) {
if (*t != '&')
tbuf[i++] = *t;
}
tbuf[i] = '\0';
SendDlgItemMessage(hDlg, PAGE_LIST, LB_ADDSTRING, 0,
(LPARAM)((LPTSTR)tbuf));
EnableWindow(GetDlgItem(hDlg, PAGE_LISTTEXT), FALSE);
EnableWindow(GetDlgItem(hDlg, PAGE_LIST), FALSE);
}
}
return TRUE;
case WM_COMMAND:
notify_message = GetNotification(wParam,lParam);
switch (LOWORD(wParam)) {
case ID_HELP:
get_help();
return FALSE;
case PAGE_LIST:
if (notify_message == LBN_DBLCLK)
PostMessage(hDlg, WM_COMMAND, IDOK, 0L);
return FALSE;
case DEVICE_NAME:
if (notify_message != CBN_SELCHANGE) {
return FALSE;
}
idevice = (int)SendDlgItemMessage(hDlg, DEVICE_NAME,
CB_GETCURSEL, 0, 0L);
if (idevice == CB_ERR)
return FALSE;
if ( (prf = profile_open(szIniFile)) != (PROFILE *)NULL ) {
char section[MAXSTR];
SendDlgItemMessageA(hDlg, DEVICE_NAME, CB_GETLBTEXT,
idevice, (LPARAM)(LPSTR)entry);
if ( (proplist = get_properties(entry)) !=
(struct prop_item_s *)NULL ) {
free((char *)proplist);
EnableWindow(GetDlgItem(hDlg, DEVICE_PROP), TRUE);
}
else
EnableWindow(GetDlgItem(hDlg, DEVICE_PROP), FALSE);
/* now look up entry in gsview.ini */
/* and update DEVICE_RES list box */
profile_read_string(prf,
bConvert ? CONVERTSECTION : DEVSECTION,
entry, "", buf, sizeof(buf)-2);
buf[strlen(buf)+1] = '\0'; /* double NULL at end */
SendDlgItemMessage(hDlg, DEVICE_RES, CB_RESETCONTENT, 0, 0L);
p = buf;
if (*p == '\0') {
/* no resolutions can be set */
EnableWindow(GetDlgItem(hDlg, DEVICE_RES), FALSE);
EnableWindow(GetDlgItem(hDlg, DEVICE_RESTEXT), FALSE);
}
else {
EnableWindow(GetDlgItem(hDlg, DEVICE_RES), TRUE);
EnableWindow(GetDlgItem(hDlg, DEVICE_RESTEXT), TRUE);
while (*p!='\0') {
res = p;
while ((*p!='\0') && (*p!=','))
p++;
*p++ = '\0';
SendDlgItemMessageA(hDlg, DEVICE_RES, CB_ADDSTRING, 0,
(LPARAM)((LPSTR)res));
}
}
SendDlgItemMessage(hDlg, DEVICE_RES, CB_SETCURSEL, 0, 0L);
if (SendDlgItemMessageA(hDlg, DEVICE_RES, CB_GETLBTEXT,
0, (LPARAM)(LPSTR)buf) != CB_ERR)
SetDlgItemTextA(hDlg, DEVICE_RES, buf);
/* update printer options */
strcpy(section, entry);
strcat(section, " Options");
profile_read_string(prf, section, "Options", "",
buf, sizeof(buf)-2);
SetDlgItemTextA(hDlg, DEVICE_OPTIONS, buf);
profile_close(prf);
}
return FALSE;
case DEVICE_RES:
/* don't have anything to do */
return FALSE;
case DEVICE_PROP:
SendDlgItemMessageA(hDlg, DEVICE_NAME, WM_GETTEXT,
sizeof(entry)-1, (LPARAM)(LPSTR)entry);
if (strlen(entry) == 0)
return FALSE;
if ( (proplist = get_properties(entry))
!= (struct prop_item_s *)NULL ) {
free((char *)proplist);
nHelpTopic = IDS_TOPICPROP;
DialogBoxParamL(hlanguage, MAKEINTRESOURCE(IDD_PROP),
hDlg, PropDlgProc, (LPARAM)entry);
}
else
play_sound(SOUND_ERROR);
nHelpTopic = bConvert ? IDS_TOPICCONVERT : IDS_TOPICPRINT;
return FALSE;
case DEVICE_UNIPRINT:
DialogBoxParamL(hlanguage, MAKEINTRESOURCE(IDD_UNIPRINT), hDlg,
UniDlgProc, (LPARAM)NULL);
return FALSE;
case PAGE_ALL:
case PAGE_EVEN:
case PAGE_ODD:
PageMultiDlgProc(hDlg, wmsg, wParam, lParam);
return FALSE;
case IDOK:
/* save device name and resolution */
if (bConvert) {
GetDlgItemTextA(hDlg, DEVICE_NAME,
option.convert_device, sizeof(option.convert_device));
GetDlgItemTextA(hDlg, DEVICE_RES, option.convert_resolution,
sizeof(option.convert_resolution));
option.convert_fixed_media = (int)SendDlgItemMessage(
hDlg, DEVICE_FIXEDMEDIA, CB_GETCURSEL, 0, 0);
}
else {
GetDlgItemTextA(hDlg, DEVICE_NAME,
option.printer_device, sizeof(option.printer_device));
GetDlgItemTextA(hDlg, DEVICE_RES, option.printer_resolution,
sizeof(option.printer_resolution));
option.print_fixed_media = (int)SendDlgItemMessage(
hDlg, DEVICE_FIXEDMEDIA, CB_GETCURSEL, 0, 0);
}
option.print_reverse = psfile.page_list.reverse =
(int)SendDlgItemMessage(hDlg, PAGE_REVERSE,
BM_GETCHECK, 0, 0);
{ /* get options */
char section[MAXSTR];
if (bConvert)
strcpy(section, option.convert_device);
else
strcpy(section, option.printer_device);
strcat(section, " Options");
GetDlgItemTextA(hDlg, DEVICE_OPTIONS, buf, sizeof(buf)-2);
if ( (prf = profile_open(szIniFile)) != (PROFILE *)NULL ) {
profile_write_string(prf, section, "Options", buf);
profile_close(prf);
}
}
if (GetDlgItem(hDlg, PAGE_LIST) != (HWND)NULL) {
/* Do this for Convert dialog, but not
* Windows 4 dialog which doesn't have a
* PAGE_LIST on the dialog
*/
if ( (psfile.dsc != (CDSC *)NULL) &&
(psfile.dsc->page_count != 0))
PageMultiDlgProc(hDlg, wmsg, wParam, lParam);
}
EndDialog(hDlg, TRUE);
return TRUE;
case IDCANCEL:
EndDialog(hDlg, FALSE);
return TRUE;
}
break;
}
return FALSE;
}
#define GDI_ENTRY "GDI"
/* dialog box for GDI print settings*/
BOOL CALLBACK _export
GDIDlgProc(HWND hDlg, UINT wmsg, WPARAM wParam, LPARAM lParam)
{
char buf[128];
char entry[MAXSTR];
struct prop_item_s *proplist;
PROFILE *prf;
switch (wmsg) {
case WM_INITDIALOG:
if ( (prf = profile_open(szIniFile)) != (PROFILE *)NULL ) {
char section[MAXSTR];
SendDlgItemMessage(hDlg, option.print_gdi_depth,
BM_SETCHECK, 1, 0);
init_fixed_media(hDlg, DEVICE_FIXEDMEDIA,
option.print_gdi_fixed_media);
strcpy(section, GDI_ENTRY);
strcat(section, " Options");
profile_read_string(prf, section, "Options", "",
buf, sizeof(buf)-2);
SetDlgItemTextA(hDlg, DEVICE_OPTIONS, buf);
profile_close(prf);
}
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case ID_HELP:
get_help();
return FALSE;
case DEVICE_PROP:
/* should save help topic */
strncpy(entry, GDI_ENTRY, sizeof(entry));
if ( (proplist = get_properties(entry))
!= (struct prop_item_s *)NULL ) {
free((char *)proplist);
nHelpTopic = IDS_TOPICPROP;
DialogBoxParamL(hlanguage, MAKEINTRESOURCE(IDD_PROP),
hDlg, PropDlgProc, (LPARAM)entry);
}
else
play_sound(SOUND_ERROR);
nHelpTopic = IDS_TOPICPRINT;
return FALSE;
case IDOK:
/* get depth */
if (SendDlgItemMessage(hDlg, IDC_COLOUR, BM_GETCHECK, 0, 0))
option.print_gdi_depth = IDC_COLOUR;
else if (SendDlgItemMessage(hDlg, IDC_GREY, BM_GETCHECK, 0, 0))
option.print_gdi_depth = IDC_GREY;
else
option.print_gdi_depth = IDC_MONO;
option.print_gdi_fixed_media = (int)SendDlgItemMessage(
hDlg, DEVICE_FIXEDMEDIA, CB_GETCURSEL, 0, 0);
if ( (prf = profile_open(szIniFile)) != (PROFILE *)NULL ) {
/* get options */
char section[MAXSTR];
strcpy(section, GDI_ENTRY);
strcat(section, " Options");
GetDlgItemTextA(hDlg, DEVICE_OPTIONS, buf, sizeof(buf)-2);
profile_write_string(prf, section, "Options", buf);
profile_close(prf);
}
EndDialog(hDlg, TRUE);
return TRUE;
case IDCANCEL:
EndDialog(hDlg, FALSE);
return TRUE;
}
break;
}
return FALSE;
}
void
set_check_method(HWND hDlg, int method)
{
BOOL bPageSelection =
(psfile.dsc != (CDSC *)NULL) || (method == PRINT_GDI);
SendDlgItemMessage(hDlg, IDC_DEVICE_GDI, BM_SETCHECK,
(method == PRINT_GDI) ? 1 : 0, 0);
SendDlgItemMessage(hDlg, IDC_DEVICE_GS, BM_SETCHECK,
(method == PRINT_GS) ? 1 : 0, 0);
SendDlgItemMessage(hDlg, IDC_DEVICE_PS, BM_SETCHECK,
(method == PRINT_PS) ? 1 : 0, 0);
/* Printer properties can only be set for GDI printing */
EnableWindow(GetDlgItem(hDlg, 1025), method == PRINT_GDI);
/* We can only select a page range if DSC or PRINT_GDI */
EnableWindow(GetDlgItem(hDlg, IDC_SELECT_PAGES), bPageSelection);
EnableWindow(GetDlgItem(hDlg, 1057), bPageSelection);
EnableWindow(GetDlgItem(hDlg, 1058), bPageSelection);
EnableWindow(GetDlgItem(hDlg, 1089), bPageSelection);
EnableWindow(GetDlgItem(hDlg, 1090), bPageSelection);
EnableWindow(GetDlgItem(hDlg, 1152), bPageSelection);
EnableWindow(GetDlgItem(hDlg, 1153), bPageSelection);
}
int
get_method(HWND hDlg)
{
int print_method;
if (SendDlgItemMessage(hDlg, IDC_DEVICE_PS,
BM_GETCHECK, 0, 0))
print_method = PRINT_PS;
else if (SendDlgItemMessage(hDlg, IDC_DEVICE_GS,
BM_GETCHECK, 0, 0))
print_method = PRINT_GS;
else
print_method = PRINT_GDI;
return print_method;
}
UINT APIENTRY
PrintHookProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_INITDIALOG) {
/* Initialise our extra dialog entries from resource strings */
TCHAR buf[MAXSTR];
load_string(IDS_PRN_PRINTMETHOD, buf, sizeof(buf));
SetDlgItemText(hDlg, IDC_DEVICE_GROUP, buf);
load_string(IDS_PRN_WINDOWSGDI, buf, sizeof(buf));
SetDlgItemText(hDlg, IDC_DEVICE_GDI, buf);
load_string(IDS_PRN_GSDEVICE, buf, sizeof(buf));
SetDlgItemText(hDlg, IDC_DEVICE_GS, buf);
load_string(IDS_PRN_PSPRINTER, buf, sizeof(buf));
SetDlgItemText(hDlg, IDC_DEVICE_PS, buf);
load_string(IDS_PRN_SETTINGS, buf, sizeof(buf));
SetDlgItemText(hDlg, IDC_GS_WINDOWS, buf);
SetDlgItemText(hDlg, IDC_GS_DEVNAME, buf);
SetDlgItemText(hDlg, IDC_GS_ADVPS, buf);
load_string(IDS_PRN_HELP, buf, sizeof(buf));
SetDlgItemText(hDlg, ID_HELP, buf);
load_string(IDS_PRN_SELECTPAGES, buf, sizeof(buf));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -