4 * Copyright 1998,99 Marcel Baur <mbaur@g26.ethz.ch>
5 * To be distributed under the Wine License
27 static LRESULT WINAPI
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(LPSTR szFileName
) {
48 CHAR szMessage
[MAX_STRING_LEN
];
49 CHAR szRessource
[MAX_STRING_LEN
];
51 /* Load and format szMessage */
52 LoadString(Globals
.hInstance
, IDS_NOTFOUND
, szRessource
, sizeof(szRessource
));
53 wsprintf(szMessage
, szRessource
, szFileName
);
56 LoadString(Globals
.hInstance
, IDS_ERROR
, szRessource
, sizeof(szRessource
));
58 /* Display Modal Dialog */
59 nResult
= MessageBox(Globals
.hMainWnd
, szMessage
, szRessource
, MB_ICONEXCLAMATION
);
63 int AlertFileNotSaved(LPSTR szFileName
) {
66 CHAR szMessage
[MAX_STRING_LEN
];
67 CHAR szRessource
[MAX_STRING_LEN
];
69 /* Load and format Message */
71 LoadString(Globals
.hInstance
, IDS_NOTSAVED
, szRessource
, sizeof(szRessource
));
72 wsprintf(szMessage
, szRessource
, szFileName
);
76 LoadString(Globals
.hInstance
, IDS_ERROR
, szRessource
, sizeof(szRessource
));
79 nResult
= MessageBox(Globals
.hMainWnd
, szMessage
, szRessource
, MB_ICONEXCLAMATION
|MB_YESNOCANCEL
);
84 VOID
AlertOutOfMemory(void) {
87 nResult
= AlertIDS(IDS_OUT_OF_MEMORY
, IDS_ERROR
, MB_ICONEXCLAMATION
);
92 BOOL
ExistFile(LPCSTR szFilename
) {
94 * Returns: TRUE - if "szFileName" exists
95 * FALSE - if it does not
97 WIN32_FIND_DATA entry
;
100 hFile
= FindFirstFile(szFilename
, &entry
);
102 return (hFile
!=INVALID_HANDLE_VALUE
);
105 VOID
DoSaveFile(VOID
) {
107 /* FIXME: Really Save the file */
108 /* ... (Globals.szFileName); */
112 BOOL
DoCloseFile(void) {
113 /* Return value: TRUE - User agreed to close (both save/don't save) */
114 /* FALSE - User cancelled close by selecting "Cancel" */
118 if (strlen(Globals
.szFileName
)>0) {
119 /* prompt user to save changes */
120 nResult
= AlertFileNotSaved(Globals
.szFileName
);
122 case IDYES
: DoSaveFile();
127 case IDCANCEL
: return(FALSE
);
130 default: return(FALSE
);
135 /* Forget file name */
136 lstrcpy(Globals
.szFileName
, "");
137 LANGUAGE_UpdateWindowCaption();
142 void DoOpenFile(LPCSTR szFileName
) {
144 /* Close any files and prompt to save changes */
146 GetFileTitle(szFileName
, Globals
.szFileName
, sizeof(Globals
.szFileName
));
147 LANGUAGE_UpdateWindowCaption();
149 LoadBufferFromFile(szFileName
);
154 VOID
DIALOG_FileNew(VOID
)
156 /* Close any files and promt to save changes */
162 VOID
DIALOG_FileOpen(VOID
)
164 OPENFILENAME openfilename
;
165 CHAR szPath
[MAX_PATHNAME_LEN
];
166 CHAR szDir
[MAX_PATHNAME_LEN
];
167 CHAR szzFilter
[2 * MAX_STRING_LEN
+ 100];
168 CHAR szDefaultExt
[4];
171 lstrcpy(szDefaultExt
, "txt");
173 LoadString(Globals
.hInstance
, IDS_TEXT_FILES_TXT
, p
, MAX_STRING_LEN
);
177 LoadString(Globals
.hInstance
, IDS_ALL_FILES
, p
, MAX_STRING_LEN
);
183 GetCurrentDirectory(sizeof(szDir
), szDir
);
184 lstrcpy(szPath
,"*.txt");
186 openfilename
.lStructSize
= sizeof(OPENFILENAME
);
187 openfilename
.hwndOwner
= Globals
.hMainWnd
;
188 openfilename
.hInstance
= Globals
.hInstance
;
189 openfilename
.lpstrFilter
= szzFilter
;
190 openfilename
.lpstrCustomFilter
= 0;
191 openfilename
.nMaxCustFilter
= 0;
192 openfilename
.nFilterIndex
= 0;
193 openfilename
.lpstrFile
= szPath
;
194 openfilename
.nMaxFile
= sizeof(szPath
);
195 openfilename
.lpstrFileTitle
= 0;
196 openfilename
.nMaxFileTitle
= 0;
197 openfilename
.lpstrInitialDir
= szDir
;
198 openfilename
.lpstrTitle
= 0;
199 openfilename
.Flags
= OFN_FILEMUSTEXIST
+ OFN_PATHMUSTEXIST
;
200 openfilename
.nFileOffset
= 0;
201 openfilename
.nFileExtension
= 0;
202 openfilename
.lpstrDefExt
= szDefaultExt
;
203 openfilename
.lCustData
= 0;
204 openfilename
.lpfnHook
= 0;
205 openfilename
.lpTemplateName
= 0;
207 if (GetOpenFileName(&openfilename
)) {
209 if (ExistFile(openfilename
.lpstrFile
))
210 DoOpenFile(openfilename
.lpstrFile
);
212 AlertFileNotFound(openfilename
.lpstrFile
);
217 VOID
DIALOG_FileSave(VOID
)
219 /* FIXME: Save File */
224 VOID
DIALOG_FileSaveAs(VOID
)
227 CHAR szPath
[MAX_PATHNAME_LEN
];
228 CHAR szDir
[MAX_PATHNAME_LEN
];
229 CHAR szDefaultExt
[4];
230 CHAR szzFilter
[2 * MAX_STRING_LEN
+ 100];
234 lstrcpy(szDefaultExt
, "txt");
236 LoadString(Globals
.hInstance
, IDS_TEXT_FILES_TXT
, p
, MAX_STRING_LEN
);
240 LoadString(Globals
.hInstance
, IDS_ALL_FILES
, p
, MAX_STRING_LEN
);
246 lstrcpy(szPath
,"*.*");
248 GetCurrentDirectory(sizeof(szDir
), szDir
);
250 saveas
.lStructSize
= sizeof(OPENFILENAME
);
251 saveas
.hwndOwner
= Globals
.hMainWnd
;
252 saveas
.hInstance
= Globals
.hInstance
;
253 saveas
.lpstrFilter
= szzFilter
;
254 saveas
.lpstrCustomFilter
= 0;
255 saveas
.nMaxCustFilter
= 0;
256 saveas
.nFilterIndex
= 0;
257 saveas
.lpstrFile
= szPath
;
258 saveas
.nMaxFile
= sizeof(szPath
);
259 saveas
.lpstrFileTitle
= 0;
260 saveas
.nMaxFileTitle
= 0;
261 saveas
.lpstrInitialDir
= szDir
;
262 saveas
.lpstrTitle
= 0;
263 saveas
.Flags
= OFN_PATHMUSTEXIST
+ OFN_OVERWRITEPROMPT
+ OFN_HIDEREADONLY
;
264 saveas
.nFileOffset
= 0;
265 saveas
.nFileExtension
= 0;
266 saveas
.lpstrDefExt
= szDefaultExt
;
267 saveas
.lCustData
= 0;
269 saveas
.lpTemplateName
= 0;
271 if (GetSaveFileName(&saveas
)) {
272 lstrcpy(Globals
.szFileName
, saveas
.lpstrFile
);
273 LANGUAGE_UpdateWindowCaption();
278 VOID
DIALOG_FilePrint(VOID
)
287 CHAR szDocumentName
[MAX_STRING_LEN
]; /* Name of document */
288 CHAR szPrinterName
[MAX_STRING_LEN
]; /* Name of the printer */
289 CHAR szDeviceName
[MAX_STRING_LEN
]; /* Name of the printer device */
290 CHAR szOutput
[MAX_STRING_LEN
]; /* in which file/device to print */
292 /* LPDEVMODE hDevMode; */
293 /* LPDEVNAMES hDevNames; */
295 /* hDevMode = GlobalAlloc(GMEM_MOVEABLE + GMEM_ZEROINIT, sizeof(DEVMODE)); */
296 /* hDevNames = GlobalAlloc(GMEM_MOVEABLE + GMEM_ZEROINIT, sizeof(DEVNAMES)); */
298 /* Get Current Settings */
300 printer
.lStructSize
= sizeof(PRINTDLG
);
301 printer
.hwndOwner
= Globals
.hMainWnd
;
302 printer
.hInstance
= Globals
.hInstance
;
304 /* Let PrintDlg create a DEVMODE structure */
305 printer
.hDevMode
= 0;
306 printer
.hDevNames
= 0;
308 printer
.Flags
= PD_RETURNDEFAULT
;
309 printer
.nFromPage
= 0;
311 printer
.nMinPage
= 0;
312 printer
.nMaxPage
= 0;
314 printer
.lCustData
= 0;
315 printer
.lpfnPrintHook
= 0;
316 printer
.lpfnSetupHook
= 0;
317 printer
.lpPrintTemplateName
= 0;
318 printer
.lpSetupTemplateName
= 0;
319 printer
.hPrintTemplate
= 0;
320 printer
.hSetupTemplate
= 0;
322 nResult
= PrintDlg(&printer
);
324 /* hContext = CreateDC(, szDeviceName, "TEST.TXT", 0); */
326 /* Congratulations to those Microsoft Engineers responsable */
327 /* for the following pointer acrobatics */
329 assert(printer
.hDevNames
!=0);
331 nBase
= (LONG
)(printer
.hDevNames
);
333 nOffset
= (WORD
)((LPDEVNAMES
) printer
.hDevNames
)->wDriverOffset
;
334 lstrcpy(szPrinterName
, (LPCSTR
) (nBase
+ nOffset
));
336 nOffset
= (WORD
)((LPDEVNAMES
) printer
.hDevNames
)->wDeviceOffset
;
337 lstrcpy(szDeviceName
, (LPCSTR
) (nBase
+ nOffset
));
339 nOffset
= (WORD
)((LPDEVNAMES
) printer
.hDevNames
)->wOutputOffset
;
340 lstrcpy(szOutput
, (LPCSTR
) (nBase
+ nOffset
));
342 MessageBox(Globals
.hMainWnd
, szPrinterName
, "Printer Name", MB_ICONEXCLAMATION
);
343 MessageBox(Globals
.hMainWnd
, szDeviceName
, "Device Name", MB_ICONEXCLAMATION
);
344 MessageBox(Globals
.hMainWnd
, szOutput
, "Output", MB_ICONEXCLAMATION
);
346 /* Set some default flags */
348 bFlags
= PD_RETURNDC
+ PD_SHOWHELP
;
351 /* Remove "Print Selection" if there is no selection */
352 bFlags
= bFlags
+ PD_NOSELECTION
;
355 printer
.Flags
= bFlags
;
357 printer.nFromPage = 0;
359 printer.nMinPage = 0;
360 printer.nMaxPage = 0;
363 /* Let commdlg manage copy settings */
364 printer
.nCopies
= (WORD
)PD_USEDEVMODECOPIES
;
366 if (PrintDlg(&printer
)) {
368 /* initialize DOCINFO */
369 di
.cbSize
= sizeof(DOCINFO
);
370 lstrcpy((LPSTR
)di
.lpszDocName
, szDocumentName
);
371 lstrcpy((LPSTR
)di
.lpszOutput
, szOutput
);
373 hContext
= printer
.hDC
;
375 assert( (int) hContext
!=PD_RETURNDC
);
377 SetMapMode(hContext
, MM_LOMETRIC
);
378 /* SetViewPortExExt(hContext, 10, 10, 0); */
379 SetBkMode(hContext
, OPAQUE
);
381 nResult
= TextOut(hContext
, 0, 0, " ", 1);
382 assert(nResult
!= 0);
384 nResult
= StartDoc(hContext
, &di
);
385 assert(nResult
!= SP_ERROR
);
387 nResult
= StartPage(hContext
);
390 /* FIXME: actually print */
392 nResult
= EndPage(hContext
);
396 MessageBox(Globals
.hMainWnd
, "Generic Error", "Print Engine Error", MB_ICONEXCLAMATION
);
399 MessageBox(Globals
.hMainWnd
, "The print job was aborted.", "Print Engine Error", MB_ICONEXCLAMATION
);
402 MessageBox(Globals
.hMainWnd
, "The print job was aborted using the Print Manager ", "Print Engine Error", MB_ICONEXCLAMATION
);
405 MessageBox(Globals
.hMainWnd
, "Out of disk space", "Print Engine Error", MB_ICONEXCLAMATION
);
411 MessageBox(Globals
.hMainWnd
, "Default", "Print", MB_ICONEXCLAMATION
);
413 nResult
= EndDoc(hContext
);
415 nResult
= DeleteDC(hContext
);
419 /* GlobalFree(hDevNames); */
420 /* GlobalFree(hDevMode); */
423 VOID
DIALOG_FilePageSetup(VOID
)
428 VOID
DIALOG_FilePrinterSetup(VOID
)
432 printer
.lStructSize
= sizeof(PRINTDLG
);
433 printer
.hwndOwner
= Globals
.hMainWnd
;
434 printer
.hInstance
= Globals
.hInstance
;
435 printer
.hDevMode
= 0;
436 printer
.hDevNames
= 0;
438 printer
.Flags
= PD_PRINTSETUP
;
439 printer
.nFromPage
= 0;
441 printer
.nMinPage
= 0;
442 printer
.nMaxPage
= 0;
444 printer
.lCustData
= 0;
445 printer
.lpfnPrintHook
= 0;
446 printer
.lpfnSetupHook
= 0;
447 printer
.lpPrintTemplateName
= 0;
448 printer
.lpSetupTemplateName
= 0;
449 printer
.hPrintTemplate
= 0;
450 printer
.hSetupTemplate
= 0;
452 if (PrintDlg(&printer
)) {
458 VOID
DIALOG_FileExit(VOID
)
465 VOID
DIALOG_EditUndo(VOID
)
467 MessageBox(Globals
.hMainWnd
, "Undo", "Debug", MB_ICONEXCLAMATION
);
471 VOID
DIALOG_EditCut(VOID
)
475 hMem
= GlobalAlloc(GMEM_ZEROINIT
, 99);
477 OpenClipboard(Globals
.hMainWnd
);
480 /* FIXME: Get text */
481 lstrcpy((CHAR
*)hMem
, "Hello World");
483 SetClipboardData(CF_TEXT
, hMem
);
489 VOID
DIALOG_EditCopy(VOID
)
493 hMem
= GlobalAlloc(GMEM_ZEROINIT
, 99);
495 OpenClipboard(Globals
.hMainWnd
);
498 /* FIXME: Get text */
499 lstrcpy((CHAR
*)hMem
, "Hello World");
501 SetClipboardData(CF_TEXT
, hMem
);
507 VOID
DIALOG_EditPaste(VOID
)
511 if (IsClipboardFormatAvailable(CF_TEXT
)) {
512 OpenClipboard(Globals
.hMainWnd
);
513 hClipText
= GetClipboardData(CF_TEXT
);
515 MessageBox(Globals
.hMainWnd
, (CHAR
*)hClipText
, "PASTE", MB_ICONEXCLAMATION
);
519 VOID
DIALOG_EditDelete(VOID
)
524 VOID
DIALOG_EditSelectAll(VOID
)
529 VOID
DIALOG_EditTimeDate(VOID
)
532 LPSYSTEMTIME lpst
= &st
;
533 CHAR szDate
[MAX_STRING_LEN
];
537 GetDateFormat(LOCALE_USER_DEFAULT
, LOCALE_SLONGDATE
, lpst
, NULL
, date
, MAX_STRING_LEN
);
538 GetTimeFormat(LOCALE_USER_DEFAULT
, LOCALE_STIMEFORMAT
, lpst
, NULL
, date
, MAX_STRING_LEN
);
542 VOID
DIALOG_EditWrap(VOID
)
544 Globals
.bWrapLongLines
= !Globals
.bWrapLongLines
;
545 CheckMenuItem(Globals
.hEditMenu
, NP_EDIT_WRAP
, MF_BYCOMMAND
|
546 (Globals
.bWrapLongLines
? MF_CHECKED
: MF_UNCHECKED
));
549 VOID
DIALOG_Search(VOID
)
551 Globals
.find
.lStructSize
= sizeof(Globals
.find
);
552 Globals
.find
.hwndOwner
= Globals
.hMainWnd
;
553 Globals
.find
.hInstance
= Globals
.hInstance
;
554 Globals
.find
.lpstrFindWhat
= (CHAR
*) &Globals
.szFindText
;
555 Globals
.find
.wFindWhatLen
= sizeof(Globals
.szFindText
);
556 Globals
.find
.lpstrReplaceWith
= 0;
557 Globals
.find
.wReplaceWithLen
= 0;
558 Globals
.find
.Flags
= FR_DOWN
;
559 Globals
.find
.lCustData
= 0;
560 Globals
.find
.lpfnHook
= 0;
561 Globals
.find
.lpTemplateName
= 0;
563 /* We only need to create the modal FindReplace dialog which will */
564 /* notify us of incoming events using hMainWnd Window Messages */
566 Globals
.hFindReplaceDlg
= FindText(&Globals
.find
);
567 assert(Globals
.hFindReplaceDlg
!=0);
570 VOID
DIALOG_SearchNext(VOID
)
575 VOID
DIALOG_HelpContents(VOID
)
577 WinHelp(Globals
.hMainWnd
, HELPFILE
, HELP_INDEX
, 0);
580 VOID
DIALOG_HelpSearch(VOID
)
585 VOID
DIALOG_HelpHelp(VOID
)
587 WinHelp(Globals
.hMainWnd
, HELPFILE
, HELP_HELPONHELP
, 0);
590 VOID
DIALOG_HelpLicense(VOID
)
592 WineLicense(Globals
.hMainWnd
);
595 VOID
DIALOG_HelpNoWarranty(VOID
)
597 WineWarranty(Globals
.hMainWnd
);
600 VOID
DIALOG_HelpAboutWine(VOID
)
602 CHAR szNotepad
[MAX_STRING_LEN
];
604 LoadString(Globals
.hInstance
, IDS_NOTEPAD
, szNotepad
, sizeof(szNotepad
));
605 ShellAbout(Globals
.hMainWnd
, szNotepad
, "Notepad\n" WINE_RELEASE_INFO
, 0);
608 /***********************************************************************
613 VOID
DIALOG_PageSetup(VOID
)
617 lpfnDlg
= MakeProcInstance(DIALOG_PAGESETUP_DlgProc
, Globals
.hInstance
);
618 DialogBox(Globals
.hInstance
, STRING_PAGESETUP_Xx
, Globals
.hMainWnd
, (DLGPROC
)lpfnDlg
);
619 FreeProcInstance(lpfnDlg
);
623 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
625 * DIALOG_PAGESETUP_DlgProc
628 static LRESULT WINAPI
DIALOG_PAGESETUP_DlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
637 /* save user input and close dialog */
638 GetDlgItemText(hDlg
, NP_PAGESETUP_HEAD
, Globals
.szHeader
, sizeof(Globals
.szHeader
));
639 GetDlgItemText(hDlg
, NP_PAGESETUP_TAIL
, Globals
.szFooter
, sizeof(Globals
.szFooter
));
640 GetDlgItemText(hDlg
, NP_PAGESETUP_TOP
, Globals
.szMarginTop
, sizeof(Globals
.szMarginTop
));
641 GetDlgItemText(hDlg
, NP_PAGESETUP_BOTTOM
, Globals
.szMarginBottom
, sizeof(Globals
.szMarginBottom
));
642 GetDlgItemText(hDlg
, NP_PAGESETUP_LEFT
, Globals
.szMarginLeft
, sizeof(Globals
.szMarginLeft
));
643 GetDlgItemText(hDlg
, NP_PAGESETUP_RIGHT
, Globals
.szMarginRight
, sizeof(Globals
.szMarginRight
));
644 EndDialog(hDlg
, IDOK
);
648 /* discard user input and close dialog */
649 EndDialog(hDlg
, IDCANCEL
);
653 /* FIXME: Bring this to work */
654 MessageBox(Globals
.hMainWnd
, "Sorry, no help available", "Help", MB_ICONEXCLAMATION
);
660 /* fetch last user input prior to display dialog */
661 SetDlgItemText(hDlg
, NP_PAGESETUP_HEAD
, Globals
.szHeader
);
662 SetDlgItemText(hDlg
, NP_PAGESETUP_TAIL
, Globals
.szFooter
);
663 SetDlgItemText(hDlg
, NP_PAGESETUP_TOP
, Globals
.szMarginTop
);
664 SetDlgItemText(hDlg
, NP_PAGESETUP_BOTTOM
, Globals
.szMarginBottom
);
665 SetDlgItemText(hDlg
, NP_PAGESETUP_LEFT
, Globals
.szMarginLeft
);
666 SetDlgItemText(hDlg
, NP_PAGESETUP_RIGHT
, Globals
.szMarginRight
);