Commit f586e1cc authored by Alexander Nicolaysen Sørnes's avatar Alexander Nicolaysen Sørnes Committed by Alexandre Julliard

wordpad: Add quick print support.

parent 6d73cd11
...@@ -31,9 +31,10 @@ ...@@ -31,9 +31,10 @@
#define ID_PRINT 1010 #define ID_PRINT 1010
#define ID_PREVIEW 1011 #define ID_PREVIEW 1011
#define ID_PRINTSETUP 1012 #define ID_PRINTSETUP 1012
#define ID_PRINT_QUICK 1013
#define ID_FIND 1013 #define ID_FIND 1014
#define ID_FIND_NEXT 1014 #define ID_FIND_NEXT 1015
#define ID_ALIGN_LEFT 1100 #define ID_ALIGN_LEFT 1100
#define ID_ALIGN_CENTER 1101 #define ID_ALIGN_CENTER 1101
......
...@@ -929,6 +929,7 @@ static int twips_to_centmm(int twips) ...@@ -929,6 +929,7 @@ static int twips_to_centmm(int twips)
} }
static HGLOBAL devMode; static HGLOBAL devMode;
static HGLOBAL devNames;
static void print(LPPRINTDLGW pd) static void print(LPPRINTDLGW pd)
{ {
...@@ -1006,6 +1007,7 @@ static void dialog_printsetup(void) ...@@ -1006,6 +1007,7 @@ static void dialog_printsetup(void)
ps.rtMargin.top = twips_to_centmm(margins.top); ps.rtMargin.top = twips_to_centmm(margins.top);
ps.rtMargin.bottom = twips_to_centmm(margins.bottom); ps.rtMargin.bottom = twips_to_centmm(margins.bottom);
ps.hDevMode = devMode; ps.hDevMode = devMode;
ps.hDevNames = devNames;
if(PageSetupDlgW(&ps)) if(PageSetupDlgW(&ps))
{ {
...@@ -1014,9 +1016,40 @@ static void dialog_printsetup(void) ...@@ -1014,9 +1016,40 @@ static void dialog_printsetup(void)
margins.top = centmm_to_twips(ps.rtMargin.top); margins.top = centmm_to_twips(ps.rtMargin.top);
margins.bottom = centmm_to_twips(ps.rtMargin.bottom); margins.bottom = centmm_to_twips(ps.rtMargin.bottom);
devMode = ps.hDevMode; 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) static void dialog_print(void)
{ {
PRINTDLGW pd; PRINTDLGW pd;
...@@ -1030,6 +1063,7 @@ static void dialog_print(void) ...@@ -1030,6 +1063,7 @@ static void dialog_print(void)
pd.nMinPage = 1; pd.nMinPage = 1;
pd.nMaxPage = 1; pd.nMaxPage = 1;
pd.hDevMode = devMode; pd.hDevMode = devMode;
pd.hDevNames = devNames;
SendMessageW(hEditorWnd, EM_GETSEL, (WPARAM)&from, (LPARAM)&to); SendMessageW(hEditorWnd, EM_GETSEL, (WPARAM)&from, (LPARAM)&to);
if(from == to) if(from == to)
...@@ -1038,6 +1072,7 @@ static void dialog_print(void) ...@@ -1038,6 +1072,7 @@ static void dialog_print(void)
if(PrintDlgW(&pd)) if(PrintDlgW(&pd))
{ {
devMode = pd.hDevMode; devMode = pd.hDevMode;
devNames = pd.hDevNames;
print(&pd); print(&pd);
} }
} }
...@@ -1643,7 +1678,7 @@ static LRESULT OnCreate( HWND hWnd, WPARAM wParam, LPARAM lParam) ...@@ -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_FILEOPEN, ID_FILE_OPEN);
AddButton(hToolBarWnd, nStdBitmaps+STD_FILESAVE, ID_FILE_SAVE); AddButton(hToolBarWnd, nStdBitmaps+STD_FILESAVE, ID_FILE_SAVE);
AddSeparator(hToolBarWnd); AddSeparator(hToolBarWnd);
AddButton(hToolBarWnd, nStdBitmaps+STD_PRINT, ID_PRINT); AddButton(hToolBarWnd, nStdBitmaps+STD_PRINT, ID_PRINT_QUICK);
AddButton(hToolBarWnd, nStdBitmaps+STD_PRINTPRE, ID_PREVIEW); AddButton(hToolBarWnd, nStdBitmaps+STD_PRINTPRE, ID_PREVIEW);
AddSeparator(hToolBarWnd); AddSeparator(hToolBarWnd);
AddButton(hToolBarWnd, nStdBitmaps+STD_FIND, ID_FIND); AddButton(hToolBarWnd, nStdBitmaps+STD_FIND, ID_FIND);
...@@ -1888,6 +1923,10 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam) ...@@ -1888,6 +1923,10 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam)
dialog_print(); dialog_print();
break; break;
case ID_PRINT_QUICK:
print_quick();
break;
case ID_PREVIEW: case ID_PREVIEW:
{ {
static const WCHAR wszNotImplemented[] = {'N','o','t',' ', static const WCHAR wszNotImplemented[] = {'N','o','t',' ',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment