4 * Copyright 1998 Marcel Baur <mbaur@g26.ethz.ch>
5 * To be distributed under the Wine License
28 static LRESULT
DIALOG_PAGESETUP_DlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
);
31 int AlertIDS(UINT ids_message
, UINT ids_caption
, WORD type
) {
33 * Given some ids strings, this acts as a language-aware wrapper for
36 CHAR szMessage
[MAX_STRING_LEN
];
37 CHAR szCaption
[MAX_STRING_LEN
];
39 LoadString(Globals
.hInstance
, ids_message
, szMessage
, sizeof(szMessage
));
40 LoadString(Globals
.hInstance
, ids_caption
, szCaption
, sizeof(szCaption
));
42 return (MessageBox(Globals
.hMainWnd
, szMessage
, szCaption
, type
));
45 void AlertFileNotFound(LPCSTR szFilename
) {
49 nResult
= AlertIDS(IDS_NOTFOUND
, IDS_ERROR
, MB_ICONEXCLAMATION
);
53 VOID
AlertOutOfMemory(void) {
57 nResult
= AlertIDS(IDS_OUT_OF_MEMORY
, IDS_ERROR
, MB_ICONEXCLAMATION
);
62 BOOL
ExistFile(LPCSTR szFilename
) {
64 * Returns: TRUE - if "szFileName" exists
65 * FALSE - if it does not
67 WIN32_FIND_DATA entry
;
70 handle
= FindFirstFile(szFilename
, &entry
);
72 return (handle
!=INVALID_HANDLE_VALUE32
);
75 VOID
DoSaveFile(VOID
) {
76 // Really Save the file
78 // ... (Globals.szFileName);
82 BOOL
DoCloseFile(void) {
83 // Return value: TRUE - User agreed to close (both save/don't save)
84 // FALSE - User cancelled close by selecting "Cancel"
86 CHAR szMessage
[MAX_STRING_LEN
];
87 CHAR szCaption
[MAX_STRING_LEN
];
91 if (strlen(Globals
.szFileName
)>0) {
93 // prompt user to save changes
95 // FIXME: The following resources are not yet in the .rc files
96 // szMessage, szCaption show up random values. Please keep these lines!
98 strcpy(szMessage
, "Save changes ?");
99 strcpy(szCaption
, "Save changes");
101 // LoadString(Globals.hInstance, ids_savechanges, szMessage, sizeof(szMessage));
102 // LoadString(Globals.hInstance, ids_savetitle, szCaption, sizeof(szCaption));
104 nResult
= MessageBox(Globals
.hMainWnd
, szMessage
, szCaption
, MB_YESNOCANCEL
);
107 case IDYES
: DoSaveFile();
112 case IDCANCEL
: return(FALSE
);
115 default: return(FALSE
);
123 lstrcpy(Globals
.szFileName
, "");
124 LANGUAGE_UpdateWindowCaption();
131 void DoOpenFile(LPCSTR szFileName
) {
133 // Close any files and prompt to save changes
137 lstrcpy(Globals
.szFileName
, szFileName
);
138 LANGUAGE_UpdateWindowCaption();
144 VOID
DIALOG_FileNew(VOID
)
146 // Close any files and promt to save changes
155 VOID
DIALOG_FileOpen(VOID
)
158 OPENFILENAME openfilename
;
159 CHAR szPath
[MAX_PATHNAME_LEN
];
160 CHAR szDir
[MAX_PATHNAME_LEN
];
161 CHAR szzFilter
[2 * MAX_STRING_LEN
+ 100];
162 CHAR szDefaultExt
[4];
165 lstrcpy(szDefaultExt
, "txt");
167 LoadString(Globals
.hInstance
, IDS_TEXT_FILES_TXT
, p
, MAX_STRING_LEN
);
171 LoadString(Globals
.hInstance
, IDS_ALL_FILES
, p
, MAX_STRING_LEN
);
177 GetCurrentDirectory(sizeof(szDir
), szDir
);
178 lstrcpy(szPath
,"*.txt");
180 openfilename
.lStructSize
= sizeof(OPENFILENAME
);
181 openfilename
.hwndOwner
= Globals
.hMainWnd
;
182 openfilename
.hInstance
= Globals
.hInstance
;
183 openfilename
.lpstrFilter
= szzFilter
;
184 openfilename
.lpstrCustomFilter
= 0;
185 openfilename
.nMaxCustFilter
= 0;
186 openfilename
.nFilterIndex
= 0;
187 openfilename
.lpstrFile
= szPath
;
188 openfilename
.nMaxFile
= sizeof(szPath
);
189 openfilename
.lpstrFileTitle
= 0;
190 openfilename
.nMaxFileTitle
= 0;
191 openfilename
.lpstrInitialDir
= szDir
;
192 openfilename
.lpstrTitle
= 0;
193 openfilename
.Flags
= OFN_FILEMUSTEXIST
+ OFN_PATHMUSTEXIST
;
194 openfilename
.nFileOffset
= 0;
195 openfilename
.nFileExtension
= 0;
196 openfilename
.lpstrDefExt
= szDefaultExt
;
197 openfilename
.lCustData
= 0;
198 openfilename
.lpfnHook
= 0;
199 openfilename
.lpTemplateName
= 0;
201 if (GetOpenFileName(&openfilename
)) {
203 if (ExistFile(openfilename
.lpstrFile
))
204 DoOpenFile(openfilename
.lpstrFile
);
206 AlertFileNotFound(openfilename
.lpstrFile
);
211 VOID
DIALOG_FileSave(VOID
)
213 fprintf(stderr
, "FileSave()\n");
216 VOID
DIALOG_FileSaveAs(VOID
)
219 CHAR szPath
[MAX_PATHNAME_LEN
];
220 CHAR szDir
[MAX_PATHNAME_LEN
];
221 CHAR szDefaultExt
[4];
222 CHAR szzFilter
[2 * MAX_STRING_LEN
+ 100];
226 lstrcpy(szDefaultExt
, "txt");
228 LoadString(Globals
.hInstance
, IDS_TEXT_FILES_TXT
, p
, MAX_STRING_LEN
);
232 LoadString(Globals
.hInstance
, IDS_ALL_FILES
, p
, MAX_STRING_LEN
);
238 lstrcpy(szPath
,"*.*");
240 GetCurrentDirectory(sizeof(szDir
), szDir
);
242 saveas
.lStructSize
= sizeof(OPENFILENAME
);
243 saveas
.hwndOwner
= Globals
.hMainWnd
;
244 saveas
.hInstance
= Globals
.hInstance
;
245 saveas
.lpstrFilter
= szzFilter
;
246 saveas
.lpstrCustomFilter
= 0;
247 saveas
.nMaxCustFilter
= 0;
248 saveas
.nFilterIndex
= 0;
249 saveas
.lpstrFile
= szPath
;
250 saveas
.nMaxFile
= sizeof(szPath
);
251 saveas
.lpstrFileTitle
= 0;
252 saveas
.nMaxFileTitle
= 0;
253 saveas
.lpstrInitialDir
= szDir
;
254 saveas
.lpstrTitle
= 0;
255 saveas
.Flags
= OFN_PATHMUSTEXIST
+ OFN_OVERWRITEPROMPT
+ OFN_HIDEREADONLY
;
256 saveas
.nFileOffset
= 0;
257 saveas
.nFileExtension
= 0;
258 saveas
.lpstrDefExt
= szDefaultExt
;
259 saveas
.lCustData
= 0;
261 saveas
.lpTemplateName
= 0;
263 if (GetSaveFileName(&saveas
)) {
264 lstrcpy(Globals
.szFileName
, saveas
.lpstrFile
);
265 LANGUAGE_UpdateWindowCaption();
270 VOID
DIALOG_FilePrint(VOID
)
273 printer
.lStructSize
= sizeof(PRINTDLG
);
274 printer
.hwndOwner
= Globals
.hMainWnd
;
275 printer
.hInstance
= Globals
.hInstance
;
276 printer
.hDevMode
= 0;
277 printer
.hDevNames
= 0;
280 printer
.nFromPage
= 0;
282 printer
.nMinPage
= 0;
283 printer
.nMaxPage
= 0;
285 printer
.lCustData
= 0;
286 printer
.lpfnPrintHook
= 0;
287 printer
.lpfnSetupHook
= 0;
288 printer
.lpPrintTemplateName
= 0;
289 printer
.lpSetupTemplateName
= 0;
290 printer
.hPrintTemplate
= 0;
291 printer
.hSetupTemplate
= 0;
293 if (PrintDlg(&printer
)) {
298 VOID
DIALOG_FilePageSetup(VOID
)
303 VOID
DIALOG_FilePrinterSetup(VOID
)
306 printer
.lStructSize
= sizeof(PRINTDLG
);
307 printer
.hwndOwner
= Globals
.hMainWnd
;
308 printer
.hInstance
= Globals
.hInstance
;
309 printer
.hDevMode
= 0;
310 printer
.hDevNames
= 0;
312 printer
.Flags
= PD_PRINTSETUP
;
313 printer
.nFromPage
= 0;
315 printer
.nMinPage
= 0;
316 printer
.nMaxPage
= 0;
318 printer
.lCustData
= 0;
319 printer
.lpfnPrintHook
= 0;
320 printer
.lpfnSetupHook
= 0;
321 printer
.lpPrintTemplateName
= 0;
322 printer
.lpSetupTemplateName
= 0;
323 printer
.hPrintTemplate
= 0;
324 printer
.hSetupTemplate
= 0;
326 if (PrintDlg(&printer
)) {
332 VOID
DIALOG_FileExit(VOID
)
339 VOID
DIALOG_EditUndo(VOID
)
341 fprintf(stderr
, "EditUndo()\n");
344 VOID
DIALOG_EditCut(VOID
)
346 fprintf(stderr
, "EditCut()\n");
349 VOID
DIALOG_EditCopy(VOID
)
351 fprintf(stderr
, "EditCopy()\n");
354 VOID
DIALOG_EditPaste(VOID
)
356 fprintf(stderr
, "EditPaste()\n");
359 VOID
DIALOG_EditDelete(VOID
)
361 fprintf(stderr
, "EditDelete()\n");
364 VOID
DIALOG_EditSelectAll(VOID
)
366 fprintf(stderr
, "EditSelectAll()\n");
369 VOID
DIALOG_EditTimeDate(VOID
)
374 VOID
DIALOG_EditWrap(VOID
)
376 Globals
.bWrapLongLines
= !Globals
.bWrapLongLines
;
377 CheckMenuItem(Globals
.hEditMenu
, NP_EDIT_WRAP
, MF_BYCOMMAND
|
378 (Globals
.bWrapLongLines
? MF_CHECKED
: MF_UNCHECKED
));
381 VOID
DIALOG_Search(VOID
)
384 CHAR szFind
[MAX_PATHNAME_LEN
+10];
385 CHAR szReplace
[MAX_PATHNAME_LEN
+10];
389 lstrcpy(szReplace
, "");
390 lstrcpy(szFind
, Globals
.szFindText
);
392 find
.lStructSize
= sizeof(FINDREPLACE
);
393 find
.hwndOwner
= Globals
.hMainWnd
;
395 find
.lpstrFindWhat
= szFind
;
396 find
.wFindWhatLen
= MAX_PATHNAME_LEN
;
397 find
.lpstrReplaceWith
= szReplace
;
398 find
.wReplaceWithLen
= MAX_PATHNAME_LEN
;
399 find
.Flags
= FR_DOWN
;
402 find
.lpTemplateName
= 0;
404 hResult
= FindText(&find
);
407 lstrcpy(Globals
.szFindText
, szFind
);
416 VOID
DIALOG_SearchNext(VOID
)
418 fprintf(stderr
, "SearchNext()\n");
421 VOID
DIALOG_HelpContents(VOID
)
423 WinHelp(Globals
.hMainWnd
, HELPFILE
, HELP_INDEX
, 0);
426 VOID
DIALOG_HelpSearch(VOID
)
428 fprintf(stderr
, "HelpSearch()\n");
431 VOID
DIALOG_HelpHelp(VOID
)
433 WinHelp(Globals
.hMainWnd
, HELPFILE
, HELP_HELPONHELP
, 0);
436 VOID
DIALOG_HelpLicense(VOID
)
438 WineLicense(Globals
.hMainWnd
, Globals
.lpszLanguage
);
441 VOID
DIALOG_HelpNoWarranty(VOID
)
443 WineWarranty(Globals
.hMainWnd
, Globals
.lpszLanguage
);
446 VOID
DIALOG_HelpAboutWine(VOID
)
448 ShellAbout(Globals
.hMainWnd
, "Notepad", "Notepad\n" WINE_RELEASE_INFO
, 0);
451 /***********************************************************************
456 VOID
DIALOG_PageSetup(VOID
)
460 lpfnDlg
= MakeProcInstance(DIALOG_PAGESETUP_DlgProc
, Globals
.hInstance
);
461 DialogBox(Globals
.hInstance
, STRING_PAGESETUP_Xx
, Globals
.hMainWnd
, lpfnDlg
);
462 FreeProcInstance(lpfnDlg
);
465 /***********************************************************************
470 VOID
DIALOG_TimeDate(VOID
)
472 // uses [KERNEL32.310] (ole2nls.c)
475 LPSYSTEMTIME lpst
= &st
;
476 CHAR szDate
[MAX_STRING_LEN
];
480 GetDateFormat(LOCALE_USER_DEFAULT
, LOCALE_SLONGDATE
, lpst
, NULL
, date
, MAX_STRING_LEN
);
482 printf("Date: %s\n", date
);
484 GetTimeFormat(LOCALE_USER_DEFAULT
, LOCALE_STIMEFORMAT
, lpst
, NULL
, date
, MAX_STRING_LEN
);
486 printf("Time: %s\n", date
);
490 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
492 * DIALOG_PAGESETUP_DlgProc
495 static LRESULT
DIALOG_PAGESETUP_DlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
503 EndDialog(hDlg
, IDOK
);
507 EndDialog(hDlg
, IDCANCEL
);
513 SetDlgItemText(hDlg
, NP_PAGESETUP_HEAD
, Globals
.szHeader
);
514 SetDlgItemText(hDlg
, NP_PAGESETUP_TAIL
, Globals
.szFooter
);
515 SetDlgItemText(hDlg
, NP_PAGESETUP_TOP
, Globals
.szMarginTop
);
516 SetDlgItemText(hDlg
, NP_PAGESETUP_BOTTOM
, Globals
.szMarginBottom
);
517 SetDlgItemText(hDlg
, NP_PAGESETUP_LEFT
, Globals
.szMarginLeft
);
518 SetDlgItemText(hDlg
, NP_PAGESETUP_RIGHT
, Globals
.szMarginRight
);
527 /* Local Variables: */
528 /* c-file-style: "GNU" */