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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 static const WCHAR helpfileW
[] = { 'n','o','t','e','p','a','d','.','h','l','p',0 };
36 static INT_PTR WINAPI
DIALOG_PAGESETUP_DlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
);
38 VOID
ShowLastError(void)
40 DWORD error
= GetLastError();
41 if (error
!= NO_ERROR
)
44 WCHAR szTitle
[MAX_STRING_LEN
];
46 LoadString(Globals
.hInstance
, STRING_ERROR
, szTitle
, SIZEOF(szTitle
));
48 FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_SYSTEM
,
50 (LPTSTR
) &lpMsgBuf
, 0, NULL
);
51 MessageBox(NULL
, lpMsgBuf
, szTitle
, MB_OK
| MB_ICONERROR
);
57 * Sets the caption of the main window according to Globals.szFileTitle:
58 * Notepad - (untitled) if no file is open
59 * Notepad - [filename] if a file is given
61 static void UpdateWindowCaption(void)
63 WCHAR szCaption
[MAX_STRING_LEN
];
64 WCHAR szUntitled
[MAX_STRING_LEN
];
66 LoadString(Globals
.hInstance
, STRING_NOTEPAD
, szCaption
, SIZEOF(szCaption
));
68 if (Globals
.szFileTitle
[0] != '\0') {
69 static const WCHAR bracket_lW
[] = { ' ','-',' ','[',0 };
70 static const WCHAR bracket_rW
[] = { ']',0 };
71 lstrcat(szCaption
, bracket_lW
);
72 lstrcat(szCaption
, Globals
.szFileTitle
);
73 lstrcat(szCaption
, bracket_rW
);
77 static const WCHAR hyphenW
[] = { ' ','-',' ',0 };
78 LoadString(Globals
.hInstance
, STRING_UNTITLED
, szUntitled
, SIZEOF(szUntitled
));
79 lstrcat(szCaption
, hyphenW
);
80 lstrcat(szCaption
, szUntitled
);
83 SetWindowText(Globals
.hMainWnd
, szCaption
);
86 static void AlertFileNotFound(LPCWSTR szFileName
)
88 WCHAR szMessage
[MAX_STRING_LEN
];
89 WCHAR szResource
[MAX_STRING_LEN
];
91 /* Load and format szMessage */
92 LoadString(Globals
.hInstance
, STRING_NOTFOUND
, szResource
, SIZEOF(szResource
));
93 wsprintf(szMessage
, szResource
, szFileName
);
96 LoadString(Globals
.hInstance
, STRING_ERROR
, szResource
, SIZEOF(szResource
));
98 /* Display Modal Dialog */
99 MessageBox(Globals
.hMainWnd
, szMessage
, szResource
, MB_ICONEXCLAMATION
);
102 static int AlertFileNotSaved(LPCWSTR szFileName
)
104 WCHAR szMessage
[MAX_STRING_LEN
];
105 WCHAR szResource
[MAX_STRING_LEN
];
106 WCHAR szUntitled
[MAX_STRING_LEN
];
108 LoadString(Globals
.hInstance
, STRING_UNTITLED
, szUntitled
, SIZEOF(szUntitled
));
110 /* Load and format Message */
111 LoadString(Globals
.hInstance
, STRING_NOTSAVED
, szResource
, SIZEOF(szResource
));
112 wsprintf(szMessage
, szResource
, szFileName
[0] ? szFileName
: szUntitled
);
115 LoadString(Globals
.hInstance
, STRING_ERROR
, szResource
, SIZEOF(szResource
));
118 return MessageBox(Globals
.hMainWnd
, szMessage
, szResource
, MB_ICONEXCLAMATION
|MB_YESNOCANCEL
);
123 * TRUE - if file exists
124 * FALSE - if file does not exist
126 BOOL
FileExists(LPCWSTR szFilename
)
128 WIN32_FIND_DATA entry
;
131 hFile
= FindFirstFile(szFilename
, &entry
);
134 return (hFile
!= INVALID_HANDLE_VALUE
);
138 static VOID
DoSaveFile(VOID
)
143 LPVOID pConverted
= NULL
;
151 hFile
= CreateFile(Globals
.szFileName
, GENERIC_WRITE
, FILE_SHARE_WRITE
,
152 NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
153 if(hFile
== INVALID_HANDLE_VALUE
)
159 size
= GetWindowTextLengthW(Globals
.hEdit
) + 1;
160 pTemp
= HeapAlloc(GetProcessHeap(), 0, size
* sizeof(*pTemp
));
167 size
= GetWindowTextW(Globals
.hEdit
, pTemp
, size
);
169 switch(Globals
.iEncoding
)
175 case ENCODING_UNICODE
:
182 case ENCODING_UNICODE_BE
:
188 /* flip the endianness */
189 for (i
= 0; i
< size
; i
++)
191 pTemp
[i
] = ((pTemp
[i
] & 0x00FF) << 8)
192 | ((pTemp
[i
] & 0xFF00) >> 8);
207 iNewSize
= WideCharToMultiByte(iCodePage
, 0, pTemp
, size
, NULL
, 0, NULL
, NULL
);
208 pConverted
= HeapAlloc(GetProcessHeap(), 0, iNewSize
);
211 HeapFree(GetProcessHeap(), 0, pTemp
);
216 WideCharToMultiByte(iCodePage
, 0, pTemp
, size
, pConverted
, iNewSize
, NULL
, NULL
);
220 iNewSize
= size
* sizeof(WCHAR
);
223 if ((iBomSize
> 0) && !WriteFile(hFile
, bom
, iBomSize
, &dwNumWrite
, NULL
))
225 else if (!WriteFile(hFile
, pConverted
, iNewSize
, &dwNumWrite
, NULL
))
228 SendMessage(Globals
.hEdit
, EM_SETMODIFY
, FALSE
, 0);
231 HeapFree(GetProcessHeap(), 0, pTemp
);
234 HeapFree(GetProcessHeap(), 0, pConverted
);
239 * TRUE - User agreed to close (both save/don't save)
240 * FALSE - User cancelled close by selecting "Cancel"
242 BOOL
DoCloseFile(void)
245 static const WCHAR empty_strW
[] = { 0 };
247 if (SendMessage(Globals
.hEdit
, EM_GETMODIFY
, 0, 0))
249 /* prompt user to save changes */
250 nResult
= AlertFileNotSaved(Globals
.szFileName
);
252 case IDYES
: DIALOG_FileSave();
257 case IDCANCEL
: return(FALSE
);
260 default: return(FALSE
);
265 SetFileName(empty_strW
);
267 UpdateWindowCaption();
272 void DoOpenFile(LPCWSTR szFileName
)
274 static const WCHAR dotlog
[] = { '.','L','O','G',0 };
277 LPWSTR pTemp2
= NULL
;
286 /* Close any files and prompt to save changes */
290 hFile
= CreateFile(szFileName
, GENERIC_READ
, FILE_SHARE_READ
, NULL
,
291 OPEN_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
292 if(hFile
== INVALID_HANDLE_VALUE
)
298 size
= GetFileSize(hFile
, NULL
);
299 if (size
== INVALID_FILE_SIZE
)
306 pTemp
= HeapAlloc(GetProcessHeap(), 0, size
+ sizeof(WCHAR
));
314 if (!ReadFile(hFile
, pTemp
, size
, &dwNumRead
, NULL
))
317 HeapFree(GetProcessHeap(), 0, pTemp
);
323 pTemp
[dwNumRead
] = 0;
325 if (IsTextUnicode(pTemp
, dwNumRead
, NULL
))
328 p
[dwNumRead
/ 2] = 0;
330 /* We need to strip BOM Unicode character, SetWindowTextW won't do it for us. */
333 Globals
.iEncoding
= ENCODING_UNICODE_BE
;
336 else if (*p
== 0xFFFE)
338 Globals
.iEncoding
= ENCODING_UNICODE
;
345 if ((p2
[0] == 0xEF) && (p2
[1] == 0xBB) && (p2
[2] == 0xBF))
348 Globals
.iEncoding
= ENCODING_UTF8
;
355 Globals
.iEncoding
= ENCODING_ANSI
;
358 iNewSize
= MultiByteToWideChar(iCodePage
, 0, (LPCSTR
)p2
, dwNumRead
, NULL
, 0);
359 pTemp2
= HeapAlloc(GetProcessHeap(), 0, (iNewSize
+ 1) * sizeof(*pTemp2
));
363 HeapFree(GetProcessHeap(), 0, pTemp
);
367 MultiByteToWideChar(iCodePage
, 0, (LPCSTR
)p2
, dwNumRead
, pTemp2
, iNewSize
);
368 pTemp2
[iNewSize
] = 0;
371 SetWindowTextW(Globals
.hEdit
, p
);
373 HeapFree(GetProcessHeap(), 0, pTemp
);
375 HeapFree(GetProcessHeap(), 0, pTemp2
);
377 SendMessage(Globals
.hEdit
, EM_SETMODIFY
, FALSE
, 0);
378 SendMessage(Globals
.hEdit
, EM_EMPTYUNDOBUFFER
, 0, 0);
379 SetFocus(Globals
.hEdit
);
381 /* If the file starts with .LOG, add a time/date at the end and set cursor after
382 * See http://support.microsoft.com/?kbid=260563
384 if (GetWindowTextW(Globals
.hEdit
, log
, sizeof(log
)/sizeof(log
[0])) && !lstrcmp(log
, dotlog
))
386 static const WCHAR lfW
[] = { '\r','\n',0 };
387 SendMessage(Globals
.hEdit
, EM_SETSEL
, GetWindowTextLength(Globals
.hEdit
), -1);
388 SendMessage(Globals
.hEdit
, EM_REPLACESEL
, TRUE
, (LPARAM
)lfW
);
389 DIALOG_EditTimeDate();
390 SendMessage(Globals
.hEdit
, EM_REPLACESEL
, TRUE
, (LPARAM
)lfW
);
393 SetFileName(szFileName
);
394 UpdateWindowCaption();
397 VOID
DIALOG_FileNew(VOID
)
399 static const WCHAR empty_strW
[] = { 0 };
401 /* Close any files and promt to save changes */
403 SetWindowText(Globals
.hEdit
, empty_strW
);
404 SendMessage(Globals
.hEdit
, EM_EMPTYUNDOBUFFER
, 0, 0);
405 SetFocus(Globals
.hEdit
);
409 VOID
DIALOG_FileOpen(VOID
)
411 OPENFILENAME openfilename
;
412 WCHAR szDir
[MAX_PATH
];
413 WCHAR szPath
[MAX_PATH
];
414 static const WCHAR szDefaultExt
[] = { 't','x','t',0 };
415 static const WCHAR txt_files
[] = { '*','.','t','x','t',0 };
417 ZeroMemory(&openfilename
, sizeof(openfilename
));
419 GetCurrentDirectory(SIZEOF(szDir
), szDir
);
420 if (Globals
.szFileName
[0] == 0)
421 lstrcpy(szPath
, txt_files
);
423 lstrcpy(szPath
, Globals
.szFileName
);
425 openfilename
.lStructSize
= sizeof(openfilename
);
426 openfilename
.hwndOwner
= Globals
.hMainWnd
;
427 openfilename
.hInstance
= Globals
.hInstance
;
428 openfilename
.lpstrFilter
= Globals
.szFilter
;
429 openfilename
.lpstrFile
= szPath
;
430 openfilename
.nMaxFile
= SIZEOF(szPath
);
431 openfilename
.lpstrInitialDir
= szDir
;
432 openfilename
.Flags
= OFN_FILEMUSTEXIST
| OFN_PATHMUSTEXIST
|
434 openfilename
.lpstrDefExt
= szDefaultExt
;
437 if (GetOpenFileName(&openfilename
)) {
438 if (FileExists(openfilename
.lpstrFile
))
439 DoOpenFile(openfilename
.lpstrFile
);
441 AlertFileNotFound(openfilename
.lpstrFile
);
446 VOID
DIALOG_FileSave(VOID
)
448 if (Globals
.szFileName
[0] == '\0')
454 static UINT_PTR CALLBACK
DIALOG_FileSaveAs_Hook(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
463 hCombo
= GetDlgItem(hDlg
, ID_ENCODING
);
465 LoadString(Globals
.hInstance
, STRING_ANSI
, szText
, SIZEOF(szText
));
466 SendMessage(hCombo
, CB_ADDSTRING
, 0, (LPARAM
) szText
);
468 LoadString(Globals
.hInstance
, STRING_UNICODE
, szText
, SIZEOF(szText
));
469 SendMessage(hCombo
, CB_ADDSTRING
, 0, (LPARAM
) szText
);
471 LoadString(Globals
.hInstance
, STRING_UNICODE_BE
, szText
, SIZEOF(szText
));
472 SendMessage(hCombo
, CB_ADDSTRING
, 0, (LPARAM
) szText
);
474 LoadString(Globals
.hInstance
, STRING_UTF8
, szText
, SIZEOF(szText
));
475 SendMessage(hCombo
, CB_ADDSTRING
, 0, (LPARAM
) szText
);
477 SendMessage(hCombo
, CB_SETCURSEL
, Globals
.iEncoding
, 0);
481 if (((NMHDR
*) lParam
)->code
== CDN_FILEOK
)
483 pNotify
= (OFNOTIFY
*) lParam
;
484 hCombo
= GetDlgItem(hDlg
, ID_ENCODING
);
485 Globals
.iEncoding
= SendMessage(hCombo
, CB_GETCURSEL
, 0, 0);
492 VOID
DIALOG_FileSaveAs(VOID
)
495 WCHAR szDir
[MAX_PATH
];
496 WCHAR szPath
[MAX_PATH
];
497 static const WCHAR szDefaultExt
[] = { 't','x','t',0 };
498 static const WCHAR txt_files
[] = { '*','.','t','x','t',0 };
500 ZeroMemory(&saveas
, sizeof(saveas
));
502 GetCurrentDirectory(SIZEOF(szDir
), szDir
);
503 if (Globals
.szFileName
[0] == 0)
504 lstrcpy(szPath
, txt_files
);
506 lstrcpy(szPath
, Globals
.szFileName
);
508 saveas
.lStructSize
= sizeof(OPENFILENAME
);
509 saveas
.hwndOwner
= Globals
.hMainWnd
;
510 saveas
.hInstance
= Globals
.hInstance
;
511 saveas
.lpstrFilter
= Globals
.szFilter
;
512 saveas
.lpstrFile
= szPath
;
513 saveas
.nMaxFile
= SIZEOF(szPath
);
514 saveas
.lpstrInitialDir
= szDir
;
515 saveas
.Flags
= OFN_PATHMUSTEXIST
| OFN_OVERWRITEPROMPT
|
516 OFN_HIDEREADONLY
| OFN_EXPLORER
| OFN_ENABLETEMPLATE
| OFN_ENABLEHOOK
;
517 saveas
.lpstrDefExt
= szDefaultExt
;
518 saveas
.lpTemplateName
= MAKEINTRESOURCE(DIALOG_ENCODING
);
519 saveas
.lpfnHook
= DIALOG_FileSaveAs_Hook
;
521 if (GetSaveFileName(&saveas
)) {
523 UpdateWindowCaption();
528 VOID
DIALOG_FilePrint(VOID
)
533 int cWidthPels
, cHeightPels
, border
;
534 int xLeft
, yTop
, pagecount
, dopage
, copycount
;
537 HFONT font
, old_font
=0;
540 static const WCHAR times_new_romanW
[] = { 'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n',0 };
542 /* Get a small font and print some header info on each page */
543 hdrFont
.lfHeight
= 100;
545 hdrFont
.lfEscapement
= 0;
546 hdrFont
.lfOrientation
= 0;
547 hdrFont
.lfWeight
= FW_BOLD
;
548 hdrFont
.lfItalic
= 0;
549 hdrFont
.lfUnderline
= 0;
550 hdrFont
.lfStrikeOut
= 0;
551 hdrFont
.lfCharSet
= ANSI_CHARSET
;
552 hdrFont
.lfOutPrecision
= OUT_DEFAULT_PRECIS
;
553 hdrFont
.lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
554 hdrFont
.lfQuality
= PROOF_QUALITY
;
555 hdrFont
.lfPitchAndFamily
= VARIABLE_PITCH
| FF_ROMAN
;
556 lstrcpy(hdrFont
.lfFaceName
, times_new_romanW
);
558 font
= CreateFontIndirect(&hdrFont
);
560 /* Get Current Settings */
561 ZeroMemory(&printer
, sizeof(printer
));
562 printer
.lStructSize
= sizeof(printer
);
563 printer
.hwndOwner
= Globals
.hMainWnd
;
564 printer
.hInstance
= Globals
.hInstance
;
566 /* Set some default flags */
567 printer
.Flags
= PD_RETURNDC
;
568 printer
.nFromPage
= 0;
569 printer
.nMinPage
= 1;
570 /* we really need to calculate number of pages to set nMaxPage and nToPage */
572 printer
.nMaxPage
= -1;
574 /* Let commdlg manage copy settings */
575 printer
.nCopies
= (WORD
)PD_USEDEVMODECOPIES
;
577 if (!PrintDlg(&printer
)) return;
579 assert(printer
.hDC
!= 0);
581 /* initialize DOCINFO */
582 di
.cbSize
= sizeof(DOCINFO
);
583 di
.lpszDocName
= Globals
.szFileTitle
;
584 di
.lpszOutput
= NULL
;
585 di
.lpszDatatype
= NULL
;
588 if (StartDoc(printer
.hDC
, &di
) <= 0) return;
590 /* Get the page dimensions in pixels. */
591 cWidthPels
= GetDeviceCaps(printer
.hDC
, HORZRES
);
592 cHeightPels
= GetDeviceCaps(printer
.hDC
, VERTRES
);
594 /* Get the file text */
595 size
= GetWindowTextLengthW(Globals
.hEdit
) + 1;
596 pTemp
= HeapAlloc(GetProcessHeap(), 0, size
* sizeof(WCHAR
));
602 size
= GetWindowTextW(Globals
.hEdit
, pTemp
, size
);
605 for (copycount
=1; copycount
<= printer
.nCopies
; copycount
++) {
609 static const WCHAR letterM
[] = { 'M',0 };
611 if (pagecount
>= printer
.nFromPage
&&
612 /* ((printer.Flags & PD_PAGENUMS) == 0 || pagecount <= printer.nToPage))*/
613 pagecount
<= printer
.nToPage
)
618 old_font
= SelectObject(printer
.hDC
, font
);
619 GetTextExtentPoint32(printer
.hDC
, letterM
, 1, &szMetric
);
622 if (StartPage(printer
.hDC
) <= 0) {
623 static const WCHAR failedW
[] = { 'S','t','a','r','t','P','a','g','e',' ','f','a','i','l','e','d',0 };
624 static const WCHAR errorW
[] = { 'P','r','i','n','t',' ','E','r','r','o','r',0 };
625 MessageBox(Globals
.hMainWnd
, failedW
, errorW
, MB_ICONEXCLAMATION
);
628 /* Write a rectangle and header at the top of each page */
629 Rectangle(printer
.hDC
, border
, border
, cWidthPels
-border
, border
+szMetric
.cy
*2);
630 /* I don't know what's up with this TextOut command. This comes out
633 TextOut(printer
.hDC
, border
*2, border
+szMetric
.cy
/2, Globals
.szFileTitle
, lstrlen(Globals
.szFileTitle
));
636 /* The starting point for the main text */
638 yTop
= border
+szMetric
.cy
*4;
640 SelectObject(printer
.hDC
, old_font
);
641 GetTextExtentPoint32(printer
.hDC
, letterM
, 1, &szMetric
);
643 /* Since outputting strings is giving me problems, output the main
644 text one character at a time.
647 if (pTemp
[i
] == '\n') {
651 else if (pTemp
[i
] != '\r') {
653 TextOut(printer
.hDC
, xLeft
, yTop
, &pTemp
[i
], 1);
654 xLeft
+= szMetric
.cx
;
656 } while (i
++<size
&& yTop
<(cHeightPels
-border
*2));
659 EndPage(printer
.hDC
);
665 DeleteDC(printer
.hDC
);
666 HeapFree(GetProcessHeap(), 0, pTemp
);
669 VOID
DIALOG_FilePrinterSetup(VOID
)
673 ZeroMemory(&printer
, sizeof(printer
));
674 printer
.lStructSize
= sizeof(printer
);
675 printer
.hwndOwner
= Globals
.hMainWnd
;
676 printer
.hInstance
= Globals
.hInstance
;
677 printer
.Flags
= PD_PRINTSETUP
;
683 VOID
DIALOG_FileExit(VOID
)
685 PostMessage(Globals
.hMainWnd
, WM_CLOSE
, 0, 0l);
688 VOID
DIALOG_EditUndo(VOID
)
690 SendMessage(Globals
.hEdit
, EM_UNDO
, 0, 0);
693 VOID
DIALOG_EditCut(VOID
)
695 SendMessage(Globals
.hEdit
, WM_CUT
, 0, 0);
698 VOID
DIALOG_EditCopy(VOID
)
700 SendMessage(Globals
.hEdit
, WM_COPY
, 0, 0);
703 VOID
DIALOG_EditPaste(VOID
)
705 SendMessage(Globals
.hEdit
, WM_PASTE
, 0, 0);
708 VOID
DIALOG_EditDelete(VOID
)
710 SendMessage(Globals
.hEdit
, WM_CLEAR
, 0, 0);
713 VOID
DIALOG_EditSelectAll(VOID
)
715 SendMessage(Globals
.hEdit
, EM_SETSEL
, 0, (LPARAM
)-1);
718 VOID
DIALOG_EditTimeDate(VOID
)
721 WCHAR szDate
[MAX_STRING_LEN
];
722 static const WCHAR spaceW
[] = { ' ',0 };
726 GetTimeFormat(LOCALE_USER_DEFAULT
, 0, &st
, NULL
, szDate
, MAX_STRING_LEN
);
727 SendMessage(Globals
.hEdit
, EM_REPLACESEL
, TRUE
, (LPARAM
)szDate
);
729 SendMessage(Globals
.hEdit
, EM_REPLACESEL
, TRUE
, (LPARAM
)spaceW
);
731 GetDateFormat(LOCALE_USER_DEFAULT
, DATE_LONGDATE
, &st
, NULL
, szDate
, MAX_STRING_LEN
);
732 SendMessage(Globals
.hEdit
, EM_REPLACESEL
, TRUE
, (LPARAM
)szDate
);
735 VOID
DIALOG_EditWrap(VOID
)
737 static const WCHAR editW
[] = { 'e','d','i','t',0 };
738 DWORD dwStyle
= WS_CHILD
| WS_VISIBLE
| WS_BORDER
| WS_VSCROLL
|
739 ES_AUTOVSCROLL
| ES_MULTILINE
;
744 size
= GetWindowTextLength(Globals
.hEdit
) + 1;
745 pTemp
= HeapAlloc(GetProcessHeap(), 0, size
* sizeof(WCHAR
));
751 GetWindowText(Globals
.hEdit
, pTemp
, size
);
752 DestroyWindow(Globals
.hEdit
);
753 GetClientRect(Globals
.hMainWnd
, &rc
);
754 if( Globals
.bWrapLongLines
) dwStyle
|= WS_HSCROLL
| ES_AUTOHSCROLL
;
755 Globals
.hEdit
= CreateWindowEx(WS_EX_CLIENTEDGE
, editW
, NULL
, dwStyle
,
756 0, 0, rc
.right
, rc
.bottom
, Globals
.hMainWnd
,
757 NULL
, Globals
.hInstance
, NULL
);
758 SendMessage(Globals
.hEdit
, WM_SETFONT
, (WPARAM
)Globals
.hFont
, (LPARAM
)FALSE
);
759 SetWindowTextW(Globals
.hEdit
, pTemp
);
760 SetFocus(Globals
.hEdit
);
761 HeapFree(GetProcessHeap(), 0, pTemp
);
763 Globals
.bWrapLongLines
= !Globals
.bWrapLongLines
;
764 CheckMenuItem(GetMenu(Globals
.hMainWnd
), CMD_WRAP
,
765 MF_BYCOMMAND
| (Globals
.bWrapLongLines
? MF_CHECKED
: MF_UNCHECKED
));
768 VOID
DIALOG_SelectFont(VOID
)
771 LOGFONT lf
=Globals
.lfFont
;
773 ZeroMemory( &cf
, sizeof(cf
) );
774 cf
.lStructSize
=sizeof(cf
);
775 cf
.hwndOwner
=Globals
.hMainWnd
;
777 cf
.Flags
=CF_SCREENFONTS
;
779 if( ChooseFont(&cf
) )
781 HFONT currfont
=Globals
.hFont
;
783 Globals
.hFont
=CreateFontIndirect( &lf
);
785 SendMessage( Globals
.hEdit
, WM_SETFONT
, (WPARAM
)Globals
.hFont
, (LPARAM
)TRUE
);
787 DeleteObject( currfont
);
791 VOID
DIALOG_Search(VOID
)
793 ZeroMemory(&Globals
.find
, sizeof(Globals
.find
));
794 Globals
.find
.lStructSize
= sizeof(Globals
.find
);
795 Globals
.find
.hwndOwner
= Globals
.hMainWnd
;
796 Globals
.find
.hInstance
= Globals
.hInstance
;
797 Globals
.find
.lpstrFindWhat
= Globals
.szFindText
;
798 Globals
.find
.wFindWhatLen
= SIZEOF(Globals
.szFindText
);
799 Globals
.find
.Flags
= FR_DOWN
;
801 /* We only need to create the modal FindReplace dialog which will */
802 /* notify us of incoming events using hMainWnd Window Messages */
804 Globals
.hFindReplaceDlg
= FindText(&Globals
.find
);
805 assert(Globals
.hFindReplaceDlg
!=0);
808 VOID
DIALOG_SearchNext(VOID
)
810 /* FIXME: Search Next */
814 VOID
DIALOG_HelpContents(VOID
)
816 WinHelp(Globals
.hMainWnd
, helpfileW
, HELP_INDEX
, 0);
819 VOID
DIALOG_HelpSearch(VOID
)
824 VOID
DIALOG_HelpHelp(VOID
)
826 WinHelp(Globals
.hMainWnd
, helpfileW
, HELP_HELPONHELP
, 0);
829 VOID
DIALOG_HelpLicense(VOID
)
831 WineLicense(Globals
.hMainWnd
);
834 VOID
DIALOG_HelpNoWarranty(VOID
)
836 WineWarranty(Globals
.hMainWnd
);
839 VOID
DIALOG_HelpAboutWine(VOID
)
841 static const WCHAR notepadW
[] = { 'N','o','t','e','p','a','d','\n',0 };
842 WCHAR szNotepad
[MAX_STRING_LEN
];
844 LoadString(Globals
.hInstance
, STRING_NOTEPAD
, szNotepad
, SIZEOF(szNotepad
));
845 ShellAbout(Globals
.hMainWnd
, szNotepad
, notepadW
, 0);
849 /***********************************************************************
851 * DIALOG_FilePageSetup
853 VOID
DIALOG_FilePageSetup(void)
855 DialogBox(Globals
.hInstance
, MAKEINTRESOURCE(DIALOG_PAGESETUP
),
856 Globals
.hMainWnd
, DIALOG_PAGESETUP_DlgProc
);
860 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
862 * DIALOG_PAGESETUP_DlgProc
865 static INT_PTR WINAPI
DIALOG_PAGESETUP_DlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
874 /* save user input and close dialog */
875 GetDlgItemText(hDlg
, 0x141, Globals
.szHeader
, SIZEOF(Globals
.szHeader
));
876 GetDlgItemText(hDlg
, 0x143, Globals
.szFooter
, SIZEOF(Globals
.szFooter
));
877 GetDlgItemText(hDlg
, 0x14A, Globals
.szMarginTop
, SIZEOF(Globals
.szMarginTop
));
878 GetDlgItemText(hDlg
, 0x150, Globals
.szMarginBottom
, SIZEOF(Globals
.szMarginBottom
));
879 GetDlgItemText(hDlg
, 0x147, Globals
.szMarginLeft
, SIZEOF(Globals
.szMarginLeft
));
880 GetDlgItemText(hDlg
, 0x14D, Globals
.szMarginRight
, SIZEOF(Globals
.szMarginRight
));
881 EndDialog(hDlg
, IDOK
);
885 /* discard user input and close dialog */
886 EndDialog(hDlg
, IDCANCEL
);
891 /* FIXME: Bring this to work */
892 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 };
893 static const WCHAR helpW
[] = { 'H','e','l','p',0 };
894 MessageBox(Globals
.hMainWnd
, sorryW
, helpW
, MB_ICONEXCLAMATION
);
904 /* fetch last user input prior to display dialog */
905 SetDlgItemText(hDlg
, 0x141, Globals
.szHeader
);
906 SetDlgItemText(hDlg
, 0x143, Globals
.szFooter
);
907 SetDlgItemText(hDlg
, 0x14A, Globals
.szMarginTop
);
908 SetDlgItemText(hDlg
, 0x150, Globals
.szMarginBottom
);
909 SetDlgItemText(hDlg
, 0x147, Globals
.szMarginLeft
);
910 SetDlgItemText(hDlg
, 0x14D, Globals
.szMarginRight
);