1 /* -*-c-style:stroustrup-*-
4 * Copyright 1998,99 Marcel Baur <mbaur@g26.ethz.ch>
5 * Copyright 2002 Sylvain Petreolle <spetreolle@yahoo.fr>
6 * Copyright 2002 Andriy Palamarchuk
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Suite 500, Boston, MA 02110-1335, USA
32 static const __WCHAR helpfileW
[] = { 'n','o','t','e','p','a','d','.','h','l','p',0 };
34 static INT_PTR WINAPI
DIALOG_AboutLilyPadDlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
);
35 static INT_PTR WINAPI
DIALOG_PAGESETUP_DlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
);
37 VOID
ShowLastError(void)
39 DWORD error
= GetLastError();
40 if (error
!= NO_ERROR
)
43 __WCHAR szTitle
[MAX_STRING_LEN
];
45 LoadString(Globals
.hInstance
, STRING_ERROR
, szTitle
, SIZEOF(szTitle
));
47 FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_SYSTEM
,
49 (LPTSTR
) &lpMsgBuf
, 0, NULL
);
50 MessageBox(NULL
, lpMsgBuf
, szTitle
, MB_OK
| MB_ICONERROR
);
56 * Sets the caption of the main window according to Globals.szFileTitle:
57 * Untitled - LilyPad if no file is open
58 * filename - LilyPad if a file is given
60 static void UpdateWindowCaption(void)
62 __WCHAR szCaption
[MAX_STRING_LEN
];
63 __WCHAR szLilyPad
[MAX_STRING_LEN
];
64 static const __WCHAR hyphenW
[] = { ' ','-',' ',0 };
66 LoadString(Globals
.hInstance
, STRING_LILYPAD
, szCaption
, SIZEOF(szCaption
));
68 if (Globals
.szFileTitle
[0] != '\0')
69 lstrcpy (szCaption
, Globals
.szFileTitle
);
71 LoadString(Globals
.hInstance
, STRING_UNTITLED
, szCaption
, SIZEOF(szCaption
));
73 LoadString(Globals
.hInstance
, STRING_LILYPAD
, szLilyPad
, SIZEOF(szLilyPad
));
74 lstrcat(szCaption
, hyphenW
);
75 lstrcat(szCaption
, szLilyPad
);
77 SetWindowText(Globals
.hMainWnd
, szCaption
);
80 int DIALOG_StringMsgBox(HWND hParent
, int formatId
, __LPCWSTR szString
, DWORD dwFlags
)
82 __WCHAR szMessage
[MAX_STRING_LEN
];
83 __WCHAR szResource
[MAX_STRING_LEN
];
85 /* Load and format szMessage */
86 LoadString(Globals
.hInstance
, formatId
, szResource
, SIZEOF(szResource
));
87 wnsprintf(szMessage
, SIZEOF(szMessage
), szResource
, szString
);
90 if ((dwFlags
& MB_ICONMASK
) == MB_ICONEXCLAMATION
)
91 LoadString(Globals
.hInstance
, STRING_ERROR
, szResource
, SIZEOF(szResource
));
93 LoadString(Globals
.hInstance
, STRING_LILYPAD
, szResource
, SIZEOF(szResource
));
95 /* Display Modal Dialog */
97 hParent
= Globals
.hMainWnd
;
98 return MessageBox(hParent
, szMessage
, szResource
, dwFlags
);
101 static void AlertFileNotFound(__LPCWSTR szFileName
)
103 DIALOG_StringMsgBox(0, STRING_NOTFOUND
, szFileName
, MB_ICONEXCLAMATION
|MB_OK
);
106 static int AlertFileNotSaved(__LPCWSTR szFileName
)
108 __WCHAR szUntitled
[MAX_STRING_LEN
];
110 LoadString(Globals
.hInstance
, STRING_UNTITLED
, szUntitled
, SIZEOF(szUntitled
));
112 return DIALOG_StringMsgBox(0,
114 szFileName
[0] ? szFileName
: szUntitled
,
115 MB_ICONQUESTION
|MB_YESNOCANCEL
);
120 * TRUE - if file exists
121 * FALSE - if file does not exist
123 BOOL
FileExists(__LPCWSTR szFilename
)
125 WIN32_FIND_DATA entry
;
128 hFile
= FindFirstFile(szFilename
, &entry
);
131 return (hFile
!= INVALID_HANDLE_VALUE
);
135 static VOID
DoSaveFile(VOID
)
142 hFile
= CreateFile(Globals
.szFileName
, GENERIC_WRITE
, FILE_SHARE_WRITE
,
143 NULL
, OPEN_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
144 if(hFile
== INVALID_HANDLE_VALUE
)
150 size
= GetWindowTextLengthA(Globals
.hEdit
) + 1;
151 pTemp
= HeapAlloc(GetProcessHeap(), 0, size
);
158 size
= GetWindowTextA(Globals
.hEdit
, pTemp
, size
);
160 if (!WriteFile(hFile
, pTemp
, size
, &dwNumWrite
, NULL
))
163 SendMessage(Globals
.hEdit
, EM_SETMODIFY
, FALSE
, 0);
167 HeapFree(GetProcessHeap(), 0, pTemp
);
172 * TRUE - User agreed to close (both save/don't save)
173 * FALSE - User cancelled close by selecting "Cancel"
175 BOOL
DoCloseFile(void)
178 static const __WCHAR empty_strW
[] = { 0 };
180 if (SendMessage(Globals
.hEdit
, EM_GETMODIFY
, 0, 0))
182 /* prompt user to save changes */
183 nResult
= AlertFileNotSaved(Globals
.szFileName
);
185 case IDYES
: DIALOG_FileSave();
190 case IDCANCEL
: return(FALSE
);
192 default: return(FALSE
);
196 SetFileName(empty_strW
);
198 UpdateWindowCaption();
203 void DoOpenFile(__LPCWSTR szFileName
)
205 static const __WCHAR dotlog
[] = { '.','L','O','G',0 };
212 /* Close any files and prompt to save changes */
216 hFile
= CreateFile(szFileName
, GENERIC_READ
, FILE_SHARE_READ
, NULL
,
217 OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
218 if(hFile
== INVALID_HANDLE_VALUE
)
220 AlertFileNotFound(szFileName
);
224 size
= GetFileSize(hFile
, NULL
);
225 if (size
== INVALID_FILE_SIZE
)
233 pTemp
= HeapAlloc(GetProcessHeap(), 0, size
);
241 if (!ReadFile(hFile
, pTemp
, size
, &dwNumRead
, NULL
))
244 HeapFree(GetProcessHeap(), 0, pTemp
);
250 pTemp
[dwNumRead
] = 0;
253 if (IsTextUnicode(pTemp
, dwNumRead
, NULL
))
255 __LPWSTR p
= (__LPWSTR
)pTemp
;
256 /* We need to strip BOM Unicode character, SetWindowTextW won't do it for us. */
257 if (*p
== 0xFEFF || *p
== 0xFFFE) p
++;
258 SetWindowText(Globals
.hEdit
, p
);
262 SetWindowText(Globals
.hEdit
, pTemp
);
264 HeapFree(GetProcessHeap(), 0, pTemp
);
266 SendMessage(Globals
.hEdit
, EM_SETMODIFY
, FALSE
, 0);
267 SendMessage(Globals
.hEdit
, EM_EMPTYUNDOBUFFER
, 0, 0);
268 SetFocus(Globals
.hEdit
);
270 /* If the file starts with .LOG, add a time/date at the end and set cursor after
271 * See http://support.microsoft.com/?kbid=260563
274 (Globals
.hEdit
, log
, sizeof(log
)/sizeof(log
[0])) && !lstrcmp(log
, dotlog
))
276 static const __WCHAR lfW
[] = { '\r','\n',0 };
277 SendMessage(Globals
.hEdit
, EM_SETSEL
, GetWindowTextLength(Globals
.hEdit
), -1);
278 SendMessage(Globals
.hEdit
, EM_REPLACESEL
, TRUE
, (LPARAM
)lfW
);
279 DIALOG_EditTimeDate();
280 SendMessage(Globals
.hEdit
, EM_REPLACESEL
, TRUE
, (LPARAM
)lfW
);
283 SetFileName(szFileName
);
284 UpdateWindowCaption();
287 VOID
DIALOG_FileNew(VOID
)
289 static const __WCHAR empty_strW
[] = { 0 };
291 /* Close any files and promt to save changes */
293 SetWindowText(Globals
.hEdit
, empty_strW
);
294 SendMessage(Globals
.hEdit
, EM_EMPTYUNDOBUFFER
, 0, 0);
295 SetFocus(Globals
.hEdit
);
299 VOID
DIALOG_FileOpen(VOID
)
301 OPENFILENAME openfilename
;
302 __WCHAR szPath
[MAX_PATH
];
303 __WCHAR szDir
[MAX_PATH
];
304 static const __WCHAR szDefaultExt
[] = { 'l','y',0 };
305 static const __WCHAR ly_files
[] = { '*','.','l','y',0 };
307 ZeroMemory(&openfilename
, sizeof(openfilename
));
309 GetCurrentDirectory(SIZEOF(szDir
), szDir
);
310 lstrcpy(szPath
, ly_files
);
312 openfilename
.lStructSize
= sizeof(openfilename
);
313 openfilename
.hwndOwner
= Globals
.hMainWnd
;
314 openfilename
.hInstance
= Globals
.hInstance
;
315 openfilename
.lpstrFilter
= Globals
.szFilter
;
316 openfilename
.lpstrFile
= szPath
;
317 openfilename
.nMaxFile
= SIZEOF(szPath
);
318 openfilename
.lpstrInitialDir
= szDir
;
319 openfilename
.Flags
= OFN_FILEMUSTEXIST
| OFN_PATHMUSTEXIST
|
321 openfilename
.lpstrDefExt
= szDefaultExt
;
324 if (GetOpenFileName(&openfilename
))
325 DoOpenFile(openfilename
.lpstrFile
);
329 VOID
DIALOG_FileSave(VOID
)
331 if (Globals
.szFileName
[0] == '\0')
337 VOID
DIALOG_FileSaveAs(VOID
)
340 __WCHAR szPath
[MAX_PATH
];
341 __WCHAR szDir
[MAX_PATH
];
342 static const __WCHAR szDefaultExt
[] = { 'l','y',0 };
343 static const __WCHAR ly_files
[] = { '*','.','l','y',0 };
345 ZeroMemory(&saveas
, sizeof(saveas
));
347 GetCurrentDirectory(SIZEOF(szDir
), szDir
);
348 lstrcpy(szPath
, ly_files
);
350 saveas
.lStructSize
= sizeof(OPENFILENAME
);
351 saveas
.hwndOwner
= Globals
.hMainWnd
;
352 saveas
.hInstance
= Globals
.hInstance
;
353 saveas
.lpstrFilter
= Globals
.szFilter
;
354 saveas
.lpstrFile
= szPath
;
355 saveas
.nMaxFile
= SIZEOF(szPath
);
356 saveas
.lpstrInitialDir
= szDir
;
357 saveas
.Flags
= OFN_PATHMUSTEXIST
| OFN_OVERWRITEPROMPT
|
359 saveas
.lpstrDefExt
= szDefaultExt
;
361 if (GetSaveFileName(&saveas
)) {
363 UpdateWindowCaption();
368 VOID
DIALOG_FilePrint(VOID
)
373 int cWidthPels
, cHeightPels
, border
;
374 int xLeft
, yTop
, pagecount
, dopage
, copycount
;
377 HFONT font
, old_font
=0;
380 static const __WCHAR times_new_romanW
[] = { 'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n',0 };
382 /* Get a small font and print some header info on each page */
383 hdrFont
.lfHeight
= 100;
385 hdrFont
.lfEscapement
= 0;
386 hdrFont
.lfOrientation
= 0;
387 hdrFont
.lfWeight
= FW_BOLD
;
388 hdrFont
.lfItalic
= 0;
389 hdrFont
.lfUnderline
= 0;
390 hdrFont
.lfStrikeOut
= 0;
391 hdrFont
.lfCharSet
= ANSI_CHARSET
;
392 hdrFont
.lfOutPrecision
= OUT_DEFAULT_PRECIS
;
393 hdrFont
.lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
394 hdrFont
.lfQuality
= PROOF_QUALITY
;
395 hdrFont
.lfPitchAndFamily
= VARIABLE_PITCH
| FF_ROMAN
;
396 lstrcpy(hdrFont
.lfFaceName
, times_new_romanW
);
398 font
= CreateFontIndirect(&hdrFont
);
400 /* Get Current Settings */
401 ZeroMemory(&printer
, sizeof(printer
));
402 printer
.lStructSize
= sizeof(printer
);
403 printer
.hwndOwner
= Globals
.hMainWnd
;
404 printer
.hDevMode
= Globals
.hDevMode
;
405 printer
.hDevNames
= Globals
.hDevNames
;
406 printer
.hInstance
= Globals
.hInstance
;
408 /* Set some default flags */
409 printer
.Flags
= PD_RETURNDC
;
410 printer
.nFromPage
= 0;
411 printer
.nMinPage
= 1;
412 /* we really need to calculate number of pages to set nMaxPage and nToPage */
414 printer
.nMaxPage
= -1;
416 /* Let commdlg manage copy settings */
417 printer
.nCopies
= (WORD
)PD_USEDEVMODECOPIES
;
419 if (!PrintDlg(&printer
)) return;
421 Globals
.hDevMode
= printer
.hDevMode
;
422 Globals
.hDevNames
= printer
.hDevNames
;
424 assert(printer
.hDC
!= 0);
426 /* initialize DOCINFO */
427 di
.cbSize
= sizeof(DOCINFO
);
428 di
.lpszDocName
= Globals
.szFileTitle
;
429 di
.lpszOutput
= NULL
;
430 di
.lpszDatatype
= NULL
;
433 if (StartDoc(printer
.hDC
, &di
) <= 0) return;
435 /* Get the page dimensions in pixels. */
436 cWidthPels
= GetDeviceCaps(printer
.hDC
, HORZRES
);
437 cHeightPels
= GetDeviceCaps(printer
.hDC
, VERTRES
);
439 /* Get the file text */
440 size
= GetWindowTextLength(Globals
.hEdit
) + 1;
441 pTemp
= HeapAlloc(GetProcessHeap(), 0, size
* sizeof(__WCHAR
));
447 size
= GetWindowText(Globals
.hEdit
, pTemp
, size
);
450 for (copycount
=1; copycount
<= printer
.nCopies
; copycount
++) {
454 static const __WCHAR letterM
[] = { 'M',0 };
456 if (pagecount
>= printer
.nFromPage
&&
457 /* ((printer.Flags & PD_PAGENUMS) == 0 || pagecount <= printer.nToPage))*/
458 pagecount
<= printer
.nToPage
)
463 old_font
= SelectObject(printer
.hDC
, font
);
464 GetTextExtentPoint32(printer
.hDC
, letterM
, 1, &szMetric
);
467 if (StartPage(printer
.hDC
) <= 0) {
468 static const __WCHAR failedW
[] = { 'S','t','a','r','t','P','a','g','e',' ','f','a','i','l','e','d',0 };
469 static const __WCHAR errorW
[] = { 'P','r','i','n','t',' ','E','r','r','o','r',0 };
470 MessageBox(Globals
.hMainWnd
, failedW
, errorW
, MB_ICONEXCLAMATION
);
473 /* Write a rectangle and header at the top of each page */
474 Rectangle(printer
.hDC
, border
, border
, cWidthPels
-border
, border
+szMetric
.cy
*2);
475 /* I don't know what's up with this TextOut command. This comes out
478 TextOut(printer
.hDC
, border
*2, border
+szMetric
.cy
/2, Globals
.szFileTitle
, lstrlen(Globals
.szFileTitle
));
481 /* The starting point for the main text */
483 yTop
= border
+szMetric
.cy
*4;
485 SelectObject(printer
.hDC
, old_font
);
486 GetTextExtentPoint32(printer
.hDC
, letterM
, 1, &szMetric
);
488 /* Since outputting strings is giving me problems, output the main
489 text one character at a time.
492 if (pTemp
[i
] == '\n') {
496 else if (pTemp
[i
] != '\r') {
498 TextOut(printer
.hDC
, xLeft
, yTop
, &pTemp
[i
], 1);
499 xLeft
+= szMetric
.cx
;
501 } while (i
++<size
&& yTop
<(cHeightPels
-border
*2));
504 EndPage(printer
.hDC
);
510 DeleteDC(printer
.hDC
);
511 HeapFree(GetProcessHeap(), 0, pTemp
);
514 VOID
DIALOG_FilePrinterSetup(VOID
)
518 ZeroMemory(&printer
, sizeof(printer
));
519 printer
.lStructSize
= sizeof(printer
);
520 printer
.hwndOwner
= Globals
.hMainWnd
;
521 printer
.hDevMode
= Globals
.hDevMode
;
522 printer
.hDevNames
= Globals
.hDevNames
;
523 printer
.hInstance
= Globals
.hInstance
;
524 printer
.Flags
= PD_PRINTSETUP
;
529 Globals
.hDevMode
= printer
.hDevMode
;
530 Globals
.hDevNames
= printer
.hDevNames
;
533 VOID
DIALOG_FileExit(VOID
)
535 PostMessage(Globals
.hMainWnd
, WM_CLOSE
, 0, 0l);
538 VOID
DIALOG_EditUndo(VOID
)
540 SendMessage(Globals
.hEdit
, EM_UNDO
, 0, 0);
543 VOID
DIALOG_EditCut(VOID
)
545 SendMessage(Globals
.hEdit
, WM_CUT
, 0, 0);
548 VOID
DIALOG_EditCopy(VOID
)
550 SendMessage(Globals
.hEdit
, WM_COPY
, 0, 0);
553 VOID
DIALOG_EditPaste(VOID
)
555 SendMessage(Globals
.hEdit
, WM_PASTE
, 0, 0);
558 VOID
DIALOG_EditDelete(VOID
)
560 SendMessage(Globals
.hEdit
, WM_CLEAR
, 0, 0);
563 VOID
DIALOG_EditSelectAll(VOID
)
565 SendMessage(Globals
.hEdit
, EM_SETSEL
, 0, (LPARAM
)-1);
568 VOID
DIALOG_EditTimeDate(VOID
)
571 __WCHAR szDate
[MAX_STRING_LEN
];
572 static const __WCHAR spaceW
[] = { ' ',0 };
576 GetTimeFormat(LOCALE_USER_DEFAULT
, 0, &st
, NULL
, szDate
, MAX_STRING_LEN
);
577 SendMessage(Globals
.hEdit
, EM_REPLACESEL
, TRUE
, (LPARAM
)szDate
);
579 SendMessage(Globals
.hEdit
, EM_REPLACESEL
, TRUE
, (LPARAM
)spaceW
);
581 GetDateFormat(LOCALE_USER_DEFAULT
, DATE_LONGDATE
, &st
, NULL
, szDate
, MAX_STRING_LEN
);
582 SendMessage(Globals
.hEdit
, EM_REPLACESEL
, TRUE
, (LPARAM
)szDate
);
585 VOID
DIALOG_EditWrap(VOID
)
588 static const __WCHAR editW
[] = { 'e','d','i','t',0 };
589 DWORD dwStyle
= WS_CHILD
| WS_VISIBLE
| WS_BORDER
| WS_VSCROLL
|
590 ES_AUTOVSCROLL
| ES_MULTILINE
;
595 size
= GetWindowTextLength(Globals
.hEdit
) + 1;
596 pTemp
= HeapAlloc(GetProcessHeap(), 0, size
* sizeof(__WCHAR
));
602 GetWindowText(Globals
.hEdit
, pTemp
, size
);
603 modify
= SendMessage(Globals
.hEdit
, EM_GETMODIFY
, 0, 0);
604 DestroyWindow(Globals
.hEdit
);
605 GetClientRect(Globals
.hMainWnd
, &rc
);
606 if( Globals
.bWrapLongLines
) dwStyle
|= WS_HSCROLL
| ES_AUTOHSCROLL
;
607 Globals
.hEdit
= CreateWindowEx(WS_EX_CLIENTEDGE
, editW
, NULL
, dwStyle
,
608 0, 0, rc
.right
, rc
.bottom
, Globals
.hMainWnd
,
609 NULL
, Globals
.hInstance
, NULL
);
610 SendMessage(Globals
.hEdit
, WM_SETFONT
, (WPARAM
)Globals
.hFont
, (LPARAM
)FALSE
);
611 SetWindowText(Globals
.hEdit
, pTemp
);
612 SendMessage(Globals
.hEdit
, EM_SETMODIFY
, (WPARAM
)modify
, 0);
613 SetFocus(Globals
.hEdit
);
614 HeapFree(GetProcessHeap(), 0, pTemp
);
616 Globals
.bWrapLongLines
= !Globals
.bWrapLongLines
;
617 CheckMenuItem(GetMenu(Globals
.hMainWnd
), CMD_WRAP
,
618 MF_BYCOMMAND
| (Globals
.bWrapLongLines
? MF_CHECKED
: MF_UNCHECKED
));
621 VOID
DIALOG_SelectFont(VOID
)
624 LOGFONT lf
=Globals
.lfFont
;
626 ZeroMemory( &cf
, sizeof(cf
) );
627 cf
.lStructSize
=sizeof(cf
);
628 cf
.hwndOwner
=Globals
.hMainWnd
;
630 cf
.Flags
=CF_SCREENFONTS
| CF_INITTOLOGFONTSTRUCT
;
632 if( ChooseFont(&cf
) )
634 HFONT currfont
=Globals
.hFont
;
636 Globals
.hFont
=CreateFontIndirect( &lf
);
638 SendMessage( Globals
.hEdit
, WM_SETFONT
, (WPARAM
)Globals
.hFont
, (LPARAM
)TRUE
);
640 DeleteObject( currfont
);
644 VOID
DIALOG_Search(VOID
)
646 ZeroMemory(&Globals
.find
, sizeof(Globals
.find
));
647 Globals
.find
.lStructSize
= sizeof(Globals
.find
);
648 Globals
.find
.hwndOwner
= Globals
.hMainWnd
;
649 Globals
.find
.hInstance
= Globals
.hInstance
;
650 Globals
.find
.lpstrFindWhat
= Globals
.szFindText
;
651 Globals
.find
.wFindWhatLen
= SIZEOF(Globals
.szFindText
);
652 Globals
.find
.Flags
= FR_DOWN
|FR_HIDEWHOLEWORD
;
654 /* We only need to create the modal FindReplace dialog which will */
655 /* notify us of incoming events using hMainWnd Window Messages */
657 Globals
.hFindReplaceDlg
= FindText(&Globals
.find
);
658 assert(Globals
.hFindReplaceDlg
!=0);
661 VOID
DIALOG_SearchNext(VOID
)
663 if (Globals
.lastFind
.lpstrFindWhat
== NULL
)
665 else /* use the last find data */
666 LILYPAD_DoFind(&Globals
.lastFind
);
669 VOID
DIALOG_HelpContents(VOID
)
671 WinHelp(Globals
.hMainWnd
, helpfileW
, HELP_INDEX
, 0);
674 VOID
DIALOG_HelpSearch(VOID
)
679 VOID
DIALOG_HelpHelp(VOID
)
681 WinHelp(Globals
.hMainWnd
, helpfileW
, HELP_HELPONHELP
, 0);
684 VOID
DIALOG_HelpAboutLilyPad(VOID
)
686 DialogBox (Globals
.hInstance
, MAKEINTRESOURCE(DIALOG_ABOUTLILYPAD
),
687 Globals
.hMainWnd
, DIALOG_AboutLilyPadDlgProc
);
690 static INT_PTR WINAPI
DIALOG_AboutLilyPadDlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
698 EndDialog (hDlg
, IDOK
);
701 EndDialog (hDlg
, IDCANCEL
);
714 /***********************************************************************
716 * DIALOG_FilePageSetup
718 VOID
DIALOG_FilePageSetup(void)
720 DialogBox(Globals
.hInstance
, MAKEINTRESOURCE(DIALOG_PAGESETUP
),
721 Globals
.hMainWnd
, DIALOG_PAGESETUP_DlgProc
);
725 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
727 * DIALOG_PAGESETUP_DlgProc
730 static INT_PTR WINAPI
DIALOG_PAGESETUP_DlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
739 /* save user input and close dialog */
740 GetDlgItemText(hDlg
, 0x141, Globals
.szHeader
, SIZEOF(Globals
.szHeader
));
741 GetDlgItemText(hDlg
, 0x143, Globals
.szFooter
, SIZEOF(Globals
.szFooter
));
742 GetDlgItemText(hDlg
, 0x14A, Globals
.szMarginTop
, SIZEOF(Globals
.szMarginTop
));
743 GetDlgItemText(hDlg
, 0x150, Globals
.szMarginBottom
, SIZEOF(Globals
.szMarginBottom
));
744 GetDlgItemText(hDlg
, 0x147, Globals
.szMarginLeft
, SIZEOF(Globals
.szMarginLeft
));
745 GetDlgItemText(hDlg
, 0x14D, Globals
.szMarginRight
, SIZEOF(Globals
.szMarginRight
));
746 EndDialog(hDlg
, IDOK
);
750 /* discard user input and close dialog */
751 EndDialog(hDlg
, IDCANCEL
);
756 /* FIXME: Bring this to work */
757 static const __WCHAR sorryW
[] = { 'S','o','r','r','y',',',' ','n','o',' ','h','e','l','p',' ','a','v','a','i','l','a','b','l','e',0 };
758 static const __WCHAR helpW
[] = { 'H','e','l','p',0 };
759 MessageBox(Globals
.hMainWnd
, sorryW
, helpW
, MB_ICONEXCLAMATION
);
769 /* fetch last user input prior to display dialog */
770 SetDlgItemText(hDlg
, 0x141, Globals
.szHeader
);
771 SetDlgItemText(hDlg
, 0x143, Globals
.szFooter
);
772 SetDlgItemText(hDlg
, 0x14A, Globals
.szMarginTop
);
773 SetDlgItemText(hDlg
, 0x150, Globals
.szMarginBottom
);
774 SetDlgItemText(hDlg
, 0x147, Globals
.szMarginLeft
);
775 SetDlgItemText(hDlg
, 0x14D, Globals
.szMarginRight
);
784 * TRUE - Placement successful.
785 * FALSE - Placement outside of text.
787 BOOL
GotoLineColumn(int nLine
, int nColumn
)
794 /* Line count is zero based. */
798 /* The number of lines. */
799 nLines
= SendMessage(Globals
.hEdit
, EM_GETLINECOUNT
, 0, 0);
804 /* The number of characters in the selected line. */
805 nCharacters
= SendMessage(Globals
.hEdit
, EM_LINELENGTH
, nLine
, 0);
807 if (nColumn
> nCharacters
)
810 /* The desired line's character index. */
811 nIndex
= SendMessage(Globals
.hEdit
, EM_LINEINDEX
, nLine
, 0);
813 /* select the text .. place cursor */
814 SendMessage(Globals
.hEdit
, EM_SETSEL
, nIndex
+ nColumn
, nIndex
+ nColumn
);