diff --git a/include/commdlg.h b/include/commdlg.h index 1d0103a0b8f..2a9545519e7 100644 --- a/include/commdlg.h +++ b/include/commdlg.h @@ -667,6 +667,8 @@ LRESULT WINAPI ReplaceTextDlgProcA(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM l LRESULT WINAPI ReplaceTextDlgProcW(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam); #define ReplaceTextProc WINELIB_NAME_AW(ReplaceTextDlgProc) LRESULT WINAPI PrintDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam, LPARAM lParam); +LRESULT WINAPI PrintDlgProcA(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam); +LRESULT WINAPI PrintDlgProcW(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam); LRESULT WINAPI PrintSetupDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam, LPARAM lParam); LRESULT WINAPI FormatCharDlgProc16(HWND16,UINT16,WPARAM16,LPARAM); LRESULT WINAPI FormatCharDlgProcA(HWND,UINT,WPARAM,LPARAM); diff --git a/include/resource.h b/include/resource.h index cdc2260fd9d..e3bc00f8c98 100644 --- a/include/resource.h +++ b/include/resource.h @@ -42,7 +42,8 @@ typedef enum SYSRES_DIALOG_CHOOSE_FONT, SYSRES_DIALOG_CHOOSE_COLOR, SYSRES_DIALOG_FIND_TEXT, - SYSRES_DIALOG_REPLACE_TEXT + SYSRES_DIALOG_REPLACE_TEXT, + SYSRES_DIALOG_PRINT32 } SYSTEM_RESOURCE; extern void LIBRES_RegisterResources(const wrc_resource32_t * const * Res); diff --git a/misc/commdlg.c b/misc/commdlg.c index c6054705a0c..fbdd89d6b66 100644 --- a/misc/commdlg.c +++ b/misc/commdlg.c @@ -3,6 +3,7 @@ * * Copyright 1994 Martin Ayotte * Copyright 1996 Albrecht Kleine + * Copyright 1999 Klaas van Gend */ #include @@ -1470,6 +1471,7 @@ LRESULT WINAPI ReplaceTextDlgProcW(HWND hWnd, UINT wMsg, WPARAM wParam, } + /*********************************************************************** * PrintDlg16 (COMMDLG.20) */ @@ -1504,34 +1506,287 @@ BOOL16 WINAPI PrintDlg16( SEGPTR printdlg ) } + /*********************************************************************** - * PrintDlg32A (COMDLG32.17) + * PrintDlgA (COMDLG32.17) + * + * Displays the the PRINT dialog box, which enables the user to specify + * specific properties of the print job. + * + * (Note: according to the MS Platform SDK, this call was in the past + * also used to display some PRINT SETUP dialog. As this is superseded + * by PageSetupDlg, this now results in an error!) + * + * RETURNS + * nonzero if the user pressed the OK button + * zero if the user cancelled the window or an error occurred + * + * BUGS + * The function is a stub only, returning TRUE to allow more programs + * to function. */ -BOOL WINAPI PrintDlgA( LPPRINTDLGA printdlg ) +BOOL WINAPI PrintDlgA( + LPPRINTDLGA lppd /* ptr to PRINTDLG32 struct */ + ) { - FIXME(commdlg, "(%p): stub\n",printdlg); - /* Altough returning FALSE is theoricaly the right thing - * most programs check for a printer at startup, and if - * none is found popup PrintDlg32A(), if it fails the program - * terminates; by returning TRUE the programs can still run - * as long as no printer related stuff is used +/* My implementing strategy: + * + * step 1: display the dialog and implement the layout-flags + * step 2: enter valid information in the fields (e.g. real printers) + * step 3: fix the RETURN-TRUE-ALWAYS Fixme by checking lppd->Flags for + * PD_RETURNDEFAULT + * step 4: implement all other specs + * step 5: allow customisation of the dialog box + * + * current implementation is in step 1. */ - return TRUE; + + HWND hwndDialog; + BOOL bRet = FALSE; + LPCVOID ptr = SYSRES_GetResPtr( SYSRES_DIALOG_PRINT32 ); + HINSTANCE hInst = WIN_GetWindowInstance( lppd->hwndOwner ); + + FIXME(commdlg, "KVG (%p): stub\n", lppd); + + /* + * FIXME : Should respond to TEMPLATE and HOOK flags here + * For now, only the standard dialog works. + */ + if (lppd->Flags & (PD_ENABLEPRINTHOOK | PD_ENABLEPRINTTEMPLATE | + PD_ENABLEPRINTTEMPLATEHANDLE | PD_ENABLESETUPHOOK | + PD_ENABLESETUPTEMPLATE|PD_ENABLESETUPTEMPLATEHANDLE)) + FIXME(commdlg, ": unimplemented flag (ignored)\n"); + + /* + * if lppd->Flags PD_RETURNDEFAULT is specified, the PrintDlg function + * does not display the dialog box, but returns with valid entries + * for hDevMode and hDevNames . + * + * Currently the flag is recognised, but we return empty hDevMode and + * and hDevNames. This will be fixed when I am in step 3. + */ + if (lppd->Flags & PD_RETURNDEFAULT) + { + WARN(commdlg, ": PrintDlg was requested to return printer info only." + "\n The return value currently does NOT provide these.\n"); + CommDlgLastError=PDERR_NODEVICES; /* return TRUE, thus never checked! */ + return(TRUE); + } + + if (lppd->Flags & PD_PRINTSETUP) + { + FIXME(commdlg, ": PrintDlg was requested to display PrintSetup box.\n"); + CommDlgLastError=PDERR_INITFAILURE; + return(FALSE); + } + + hwndDialog= DIALOG_CreateIndirect(hInst, ptr, TRUE, lppd->hwndOwner, + (DLGPROC16)PrintDlgProcA, (LPARAM)lppd, WIN_PROC_32A ); + if (hwndDialog) + bRet = DIALOG_DoDialogBox(hwndDialog, lppd->hwndOwner); + return bRet; } + + + /*********************************************************************** * PrintDlg32W (COMDLG32.18) */ BOOL WINAPI PrintDlgW( LPPRINTDLGW printdlg ) { - FIXME(commdlg, "empty stub\n" ); + FIXME(commdlg, "A really empty stub\n" ); return FALSE; } + /*********************************************************************** - * PrintDlgProc (COMMDLG.21) + * PRINTDLG_WMInitDialog [internal] + */ +LRESULT PRINTDLG_WMInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam, + LPPRINTDLGA lppd) +{ + SetWindowLongA(hDlg, DWL_USER, lParam); + TRACE(commdlg,"WM_INITDIALOG lParam=%08lX\n", lParam); + + if (lppd->lStructSize != sizeof(PRINTDLGA)) + { + FIXME(commdlg,"structure size failure !!!\n"); +/* EndDialog (hDlg, 0); + return FALSE; +*/ } + +/* Flag processing to set the according buttons on/off and + * Initialise the various values + */ + + /* Print range (All/Range/Selection) */ + if (lppd->nMinPage == lppd->nMaxPage) + lppd->Flags &= ~PD_NOPAGENUMS; + /* FIXME: I allow more freedom than either Win95 or WinNT, + * as officially we should return error if + * ToPage or FromPage is out-of-range + */ + if (lppd->nToPage < lppd->nMinPage) + lppd->nToPage = lppd->nMinPage; + if (lppd->nToPage > lppd->nMaxPage) + lppd->nToPage = lppd->nMaxPage; + if (lppd->nFromPage < lppd->nMinPage) + lppd->nFromPage = lppd->nMinPage; + if (lppd->nFromPage > lppd->nMaxPage) + lppd->nFromPage = lppd->nMaxPage; + SetDlgItemInt(hDlg, edt2, lppd->nFromPage, FALSE); + SetDlgItemInt(hDlg, edt3, lppd->nToPage, FALSE); + CheckRadioButton(hDlg, rad1, rad3, rad1); + if (lppd->Flags & PD_NOSELECTION) + EnableWindow(GetDlgItem(hDlg, rad3), FALSE); + else + if (lppd->Flags & PD_SELECTION) + CheckRadioButton(hDlg, rad1, rad3, rad3); + if (lppd->Flags & PD_NOPAGENUMS) + { + EnableWindow(GetDlgItem(hDlg, rad2), FALSE); + EnableWindow(GetDlgItem(hDlg, stc10),FALSE); + EnableWindow(GetDlgItem(hDlg, edt2), FALSE); + EnableWindow(GetDlgItem(hDlg, stc11),FALSE); + EnableWindow(GetDlgItem(hDlg, edt3), FALSE); + } + else + { + if (lppd->Flags & PD_PAGENUMS) + CheckRadioButton(hDlg, rad1, rad3, rad2); + } + /* FIXME: in Win95, the radiobutton "All" is displayed as + * "Print all xxx pages"... This is not done here (yet?) + */ + + /* Collate pages */ + if (lppd->Flags & PD_COLLATE) + FIXME(commdlg, "PD_COLLATE not implemented yet\n"); + + /* print to file */ + CheckDlgButton(hDlg, chx1, (lppd->Flags & PD_PRINTTOFILE) ? 1 : 0); + if (lppd->Flags & PD_DISABLEPRINTTOFILE) + EnableWindow(GetDlgItem(hDlg, chx1), FALSE); + if (lppd->Flags & PD_HIDEPRINTTOFILE) + ShowWindow(GetDlgItem(hDlg, chx1), SW_HIDE); + + /* status */ + +TRACE(commdlg, "succesful!\n"); + return TRUE; +} + + +/*********************************************************************** + * PRINTDLG_ValidateAndDuplicateSettings [internal] + */ +BOOL PRINTDLG_ValidateAndDuplicateSettings(HWND hDlg, LPPRINTDLGA lppd) +{ + WORD nToPage; + WORD nFromPage; + char TempBuffer[256]; + + /* check whether nFromPage and nToPage are within range defined by + * nMinPage and nMaxPage + */ + /* FIXMNo checking on rad2 is performed now, because IsDlgButtonCheck + * currently doesn't seem to know a state BST_CHECKED + */ +/* if (IsDlgButtonChecked(hDlg, rad2) == BST_CHECKED) */ + { + nFromPage = GetDlgItemInt(hDlg, edt2, NULL, FALSE); + nToPage = GetDlgItemInt(hDlg, edt3, NULL, FALSE); + if (nFromPage < lppd->nMinPage || nFromPage > lppd->nMaxPage || + nToPage < lppd->nMinPage || nToPage > lppd->nMaxPage) + { + FIXME(commdlg, "The MessageBox is not internationalised."); + sprintf(TempBuffer, "This value lies not within Page range\n" + "Please enter a value between %d and %d", + lppd->nMinPage, lppd->nMaxPage); + MessageBoxA(hDlg, TempBuffer, "Print", MB_OK | MB_ICONWARNING); + return(FALSE); + } + lppd->nFromPage = nFromPage; + lppd->nToPage = nToPage; + } + + return(TRUE); +} + + + +/*********************************************************************** + * PRINTDLG_WMCommand [internal] + */ +static LRESULT PRINTDLG_WMCommand(HWND hDlg, WPARAM wParam, + LPARAM lParam, LPPRINTDLGA lppd) +{ + switch (wParam) + { + case IDOK: + if (PRINTDLG_ValidateAndDuplicateSettings(hDlg, lppd) != TRUE) + return(FALSE); + MessageBoxA(hDlg, "OK was hit!", NULL, MB_OK); + DestroyWindow(hDlg); + return(TRUE); + case IDCANCEL: + MessageBoxA(hDlg, "CANCEL was hit!", NULL, MB_OK); + EndDialog(hDlg, FALSE); +/* DestroyWindow(hDlg); */ + return(FALSE); + } + return FALSE; +} + + + +/*********************************************************************** + * PrintDlgProcA [internal] + */ +LRESULT WINAPI PrintDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam, + LPARAM lParam) +{ + LPPRINTDLGA lppd; + LRESULT res=FALSE; + if (uMsg!=WM_INITDIALOG) + { + lppd=(LPPRINTDLGA)GetWindowLongA(hDlg, DWL_USER); + if (!lppd) + return FALSE; +} + else + { + lppd=(LPPRINTDLGA)lParam; + if (!PRINTDLG_WMInitDialog(hDlg, wParam, lParam, lppd)) + { + TRACE(commdlg, "PRINTDLG_WMInitDialog returned FALSE\n"); + return FALSE; + } + MessageBoxA(hDlg,"Warning: this dialog has no functionality yet!", + NULL, MB_OK); + } + switch (uMsg) + { + case WM_COMMAND: + return PRINTDLG_WMCommand(hDlg, wParam, lParam, lppd); + case WM_DESTROY: + return FALSE; + } + + return res; +} + + + + + + + +/*********************************************************************** + * PrintDlgProc16 (COMMDLG.21) */ LRESULT WINAPI PrintDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam, LPARAM lParam) @@ -1585,6 +1840,7 @@ LRESULT WINAPI PrintSetupDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam, } + /*********************************************************************** * CommDlgExtendedError (COMMDLG.26) */ diff --git a/resources/sysres_En.rc b/resources/sysres_En.rc index 69fa8474b76..3d6fb139398 100644 --- a/resources/sysres_En.rc +++ b/resources/sysres_En.rc @@ -252,3 +252,43 @@ FONT 8, "Helv" PUSHBUTTON "Cancel", IDCANCEL , 174, 55, 50, 14, WS_GROUP | WS_TABSTOP PUSHBUTTON "&Help", pshHelp , 174, 75, 50, 14, WS_GROUP | WS_TABSTOP } + + + +PRINT32 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36,24, 289,182 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Print32" +FONT 8, "Helv" +{ + DEFPUSHBUTTON "OK", IDOK, 176,161,50,14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON + PUSHBUTTON "Cancel", IDCANCEL, 232,161,50,14, WS_GROUP | WS_TABSTOP + + GROUPBOX "Printer", stc2, 7,2,275,87 + CHECKBOX "Print to fi&le",chx1, 224,73,49,10, BS_AUTOCHECKBOX | WS_TABSTOP + PUSHBUTTON "&Properties",psh3, 209,17,58,14 + LTEXT "&Name:", -1, 16,20,22,8 + COMBOBOX cmb1, 49,18,154,15,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP + LTEXT "Status:", -1, 16,37,23,8 + LTEXT "Dummy State",stc3, 63,37,120,8 + LTEXT "Type:", -1, 16,49,19,8 + LTEXT "Dummy Type", stc4, 63,49,120,8 + LTEXT "Where:", -1, 16,61,24,8 + LTEXT "Dummy Location",stc5, 63,61,120,8 + LTEXT "Comment:", -1, 16,73,32,8 + LTEXT "Dummy Remark",stc6, 63,73,120,8 + + GROUPBOX "Copies", stc7, 157,92,125,65 + LTEXT "Number of &copies:",stc8, 164,106,58,8 + CHECKBOX "C&ollate", chx2, 241,130,37,10, BS_AUTOCHECKBOX | WS_TABSTOP + EDITTEXT edt1, 240,104,34,13,ES_NUMBER + + GROUPBOX "Print Range",stc9, 7,92,141,65 + CONTROL "&All", rad1, "Button",BS_AUTORADIOBUTTON,15,106,23,10 + CONTROL "&Pages", rad2, "Button",BS_AUTORADIOBUTTON,15,124,36,10 + CONTROL "&Selection", rad3, "Button",BS_AUTORADIOBUTTON,15,142,45,10 + EDITTEXT edt2, 73,121,25,14, ES_NUMBER | ES_RIGHT + EDITTEXT edt3, 113,121,28,14,ES_NUMBER | ES_RIGHT + LTEXT "&to:", stc10,102,124,9,8 + LTEXT "&from:", stc11,55,124,16,8 +} +