wordpad: Cache text length.
This commit is contained in:
parent
7a9f72863d
commit
8f19111325
|
@ -30,6 +30,7 @@ typedef struct _previewinfo
|
||||||
int pages;
|
int pages;
|
||||||
int pages_shown;
|
int pages_shown;
|
||||||
int *pageEnds, pageCapacity;
|
int *pageEnds, pageCapacity;
|
||||||
|
int textlength;
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
HDC hdc2;
|
HDC hdc2;
|
||||||
HDC hdcSized;
|
HDC hdcSized;
|
||||||
|
@ -638,10 +639,12 @@ LRESULT CALLBACK preview_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
preview.bmSize.cx = twips_to_pixels(preview.rcPage.right, GetDeviceCaps(hdc, LOGPIXELSX));
|
preview.bmSize.cx = twips_to_pixels(preview.rcPage.right, GetDeviceCaps(hdc, LOGPIXELSX));
|
||||||
preview.bmSize.cy = twips_to_pixels(preview.rcPage.bottom, GetDeviceCaps(hdc, LOGPIXELSY));
|
preview.bmSize.cy = twips_to_pixels(preview.rcPage.bottom, GetDeviceCaps(hdc, LOGPIXELSY));
|
||||||
|
|
||||||
|
preview.textlength = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)>, 0);
|
||||||
|
|
||||||
fr.hdc = CreateCompatibleDC(hdc);
|
fr.hdc = CreateCompatibleDC(hdc);
|
||||||
fr.hdcTarget = hdcTarget;
|
fr.hdcTarget = hdcTarget;
|
||||||
fr.chrg.cpMin = 0;
|
fr.chrg.cpMin = 0;
|
||||||
fr.chrg.cpMax = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)>, 0);
|
fr.chrg.cpMax = preview.textlength;
|
||||||
preview.pages = get_num_pages(hEditorWnd, fr);
|
preview.pages = get_num_pages(hEditorWnd, fr);
|
||||||
DeleteDC(fr.hdc);
|
DeleteDC(fr.hdc);
|
||||||
DeleteDC(hdcTarget);
|
DeleteDC(hdcTarget);
|
||||||
|
@ -1031,7 +1034,6 @@ LRESULT print_preview(HWND hwndPreview)
|
||||||
/* Update for page changes. */
|
/* Update for page changes. */
|
||||||
static void update_preview(HWND hMainWnd)
|
static void update_preview(HWND hMainWnd)
|
||||||
{
|
{
|
||||||
GETTEXTLENGTHEX gt;
|
|
||||||
RECT paper;
|
RECT paper;
|
||||||
HWND hEditorWnd = GetDlgItem(hMainWnd, IDC_EDITOR);
|
HWND hEditorWnd = GetDlgItem(hMainWnd, IDC_EDITOR);
|
||||||
HWND hwndPreview = GetDlgItem(hMainWnd, IDC_PREVIEW);
|
HWND hwndPreview = GetDlgItem(hMainWnd, IDC_PREVIEW);
|
||||||
|
@ -1046,10 +1048,8 @@ static void update_preview(HWND hMainWnd)
|
||||||
fr.rc.bottom -= margins.bottom;
|
fr.rc.bottom -= margins.bottom;
|
||||||
fr.rc.right -= margins.right;
|
fr.rc.right -= margins.right;
|
||||||
|
|
||||||
gt.flags = GTL_DEFAULT;
|
|
||||||
gt.codepage = 1200;
|
|
||||||
fr.chrg.cpMin = 0;
|
fr.chrg.cpMin = 0;
|
||||||
fr.chrg.cpMax = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)>, 0);
|
fr.chrg.cpMax = preview.textlength;
|
||||||
|
|
||||||
paper.left = 0;
|
paper.left = 0;
|
||||||
paper.right = preview.bmSize.cx;
|
paper.right = preview.bmSize.cx;
|
||||||
|
|
Loading…
Reference in New Issue