wordpad: Add quick print support.
This commit is contained in:
parent
6d73cd1138
commit
f586e1cce1
|
@ -31,9 +31,10 @@
|
|||
#define ID_PRINT 1010
|
||||
#define ID_PREVIEW 1011
|
||||
#define ID_PRINTSETUP 1012
|
||||
#define ID_PRINT_QUICK 1013
|
||||
|
||||
#define ID_FIND 1013
|
||||
#define ID_FIND_NEXT 1014
|
||||
#define ID_FIND 1014
|
||||
#define ID_FIND_NEXT 1015
|
||||
|
||||
#define ID_ALIGN_LEFT 1100
|
||||
#define ID_ALIGN_CENTER 1101
|
||||
|
|
|
@ -929,6 +929,7 @@ static int twips_to_centmm(int twips)
|
|||
}
|
||||
|
||||
static HGLOBAL devMode;
|
||||
static HGLOBAL devNames;
|
||||
|
||||
static void print(LPPRINTDLGW pd)
|
||||
{
|
||||
|
@ -1006,6 +1007,7 @@ static void dialog_printsetup(void)
|
|||
ps.rtMargin.top = twips_to_centmm(margins.top);
|
||||
ps.rtMargin.bottom = twips_to_centmm(margins.bottom);
|
||||
ps.hDevMode = devMode;
|
||||
ps.hDevNames = devNames;
|
||||
|
||||
if(PageSetupDlgW(&ps))
|
||||
{
|
||||
|
@ -1014,9 +1016,40 @@ static void dialog_printsetup(void)
|
|||
margins.top = centmm_to_twips(ps.rtMargin.top);
|
||||
margins.bottom = centmm_to_twips(ps.rtMargin.bottom);
|
||||
devMode = ps.hDevMode;
|
||||
devNames = ps.hDevNames;
|
||||
}
|
||||
}
|
||||
|
||||
static void print_quick(void)
|
||||
{
|
||||
PRINTDLGW pd;
|
||||
ZeroMemory(&pd, sizeof(pd));
|
||||
|
||||
if(devMode && devNames)
|
||||
{
|
||||
LPDEVNAMES dn = GlobalLock(devNames);
|
||||
LPDEVMODEW dm = GlobalLock(devMode);
|
||||
pd.hDC = CreateDCW((LPWSTR)dn + dn->wDriverOffset,
|
||||
(LPWSTR)dn + dn->wDeviceOffset, 0, dm);
|
||||
GlobalUnlock(dn);
|
||||
GlobalUnlock(dm);
|
||||
} else
|
||||
{
|
||||
ZeroMemory(&pd, sizeof(pd));
|
||||
pd.lStructSize = sizeof(pd);
|
||||
pd.Flags = PD_RETURNDC | PD_RETURNDEFAULT;
|
||||
pd.hwndOwner = hMainWnd;
|
||||
pd.hDevMode = (HGLOBAL)devMode;
|
||||
|
||||
PrintDlgW(&pd);
|
||||
|
||||
devMode = pd.hDevMode;
|
||||
devNames = pd.hDevNames;
|
||||
}
|
||||
|
||||
print(&pd);
|
||||
}
|
||||
|
||||
static void dialog_print(void)
|
||||
{
|
||||
PRINTDLGW pd;
|
||||
|
@ -1030,6 +1063,7 @@ static void dialog_print(void)
|
|||
pd.nMinPage = 1;
|
||||
pd.nMaxPage = 1;
|
||||
pd.hDevMode = devMode;
|
||||
pd.hDevNames = devNames;
|
||||
|
||||
SendMessageW(hEditorWnd, EM_GETSEL, (WPARAM)&from, (LPARAM)&to);
|
||||
if(from == to)
|
||||
|
@ -1038,6 +1072,7 @@ static void dialog_print(void)
|
|||
if(PrintDlgW(&pd))
|
||||
{
|
||||
devMode = pd.hDevMode;
|
||||
devNames = pd.hDevNames;
|
||||
print(&pd);
|
||||
}
|
||||
}
|
||||
|
@ -1643,7 +1678,7 @@ static LRESULT OnCreate( HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||
AddButton(hToolBarWnd, nStdBitmaps+STD_FILEOPEN, ID_FILE_OPEN);
|
||||
AddButton(hToolBarWnd, nStdBitmaps+STD_FILESAVE, ID_FILE_SAVE);
|
||||
AddSeparator(hToolBarWnd);
|
||||
AddButton(hToolBarWnd, nStdBitmaps+STD_PRINT, ID_PRINT);
|
||||
AddButton(hToolBarWnd, nStdBitmaps+STD_PRINT, ID_PRINT_QUICK);
|
||||
AddButton(hToolBarWnd, nStdBitmaps+STD_PRINTPRE, ID_PREVIEW);
|
||||
AddSeparator(hToolBarWnd);
|
||||
AddButton(hToolBarWnd, nStdBitmaps+STD_FIND, ID_FIND);
|
||||
|
@ -1888,6 +1923,10 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||
dialog_print();
|
||||
break;
|
||||
|
||||
case ID_PRINT_QUICK:
|
||||
print_quick();
|
||||
break;
|
||||
|
||||
case ID_PREVIEW:
|
||||
{
|
||||
static const WCHAR wszNotImplemented[] = {'N','o','t',' ',
|
||||
|
|
Loading…
Reference in New Issue