Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
77bf8991
Commit
77bf8991
authored
Jul 08, 2007
by
Alexander Nicolaysen Sørnes
Committed by
Alexandre Julliard
Jul 09, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wordpad: Prompt for saving file changes.
parent
7a6fbf2b
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
184 additions
and
44 deletions
+184
-44
De.rc
programs/wordpad/De.rc
+6
-0
En.rc
programs/wordpad/En.rc
+6
-0
Fr.rc
programs/wordpad/Fr.rc
+6
-0
Hu.rc
programs/wordpad/Hu.rc
+6
-0
Ko.rc
programs/wordpad/Ko.rc
+6
-0
Nl.rc
programs/wordpad/Nl.rc
+6
-0
No.rc
programs/wordpad/No.rc
+6
-0
Pl.rc
programs/wordpad/Pl.rc
+6
-0
Ru.rc
programs/wordpad/Ru.rc
+6
-0
Tr.rc
programs/wordpad/Tr.rc
+6
-0
resource.h
programs/wordpad/resource.h
+3
-0
wordpad.c
programs/wordpad/wordpad.c
+121
-44
No files found.
programs/wordpad/De.rc
View file @
77bf8991
...
...
@@ -80,3 +80,9 @@ BEGIN
STRING_TEXT_FILES_TXT, "Textdateien (*.txt)"
STRING_ALL_FILES, "Alle Dokumente (*.*)"
END
STRINGTABLE DISCARDABLE
BEGIN
STRING_DEFAULT_FILENAME, "Document"
STRING_PROMPT_SAVE_CHANGES, "Save changes to '%s'?"
END
programs/wordpad/En.rc
View file @
77bf8991
...
...
@@ -80,3 +80,9 @@ BEGIN
STRING_TEXT_FILES_TXT, "Text files (*.txt)"
STRING_ALL_FILES, "All documents (*.*)"
END
STRINGTABLE DISCARDABLE
BEGIN
STRING_DEFAULT_FILENAME, "Document"
STRING_PROMPT_SAVE_CHANGES, "Save changes to '%s'?"
END
programs/wordpad/Fr.rc
View file @
77bf8991
...
...
@@ -73,3 +73,9 @@ BEGIN
END
END
END
STRINGTABLE DISCARDABLE
BEGIN
STRING_DEFAULT_FILENAME, "Document"
STRING_PROMPT_SAVE_CHANGES, "Save changes to '%s'?"
END
programs/wordpad/Hu.rc
View file @
77bf8991
...
...
@@ -73,3 +73,9 @@ BEGIN
END
END
END
STRINGTABLE DISCARDABLE
BEGIN
STRING_DEFAULT_FILENAME, "Document"
STRING_PROMPT_SAVE_CHANGES, "Save changes to '%s'?"
END
programs/wordpad/Ko.rc
View file @
77bf8991
...
...
@@ -81,3 +81,9 @@ BEGIN
STRING_TEXT_FILES_TXT, "텍스트 파일 (*.txt)"
STRING_ALL_FILES, "모둔 문서 (*.*)"
END
STRINGTABLE DISCARDABLE
BEGIN
STRING_DEFAULT_FILENAME, "Document"
STRING_PROMPT_SAVE_CHANGES, "Save changes to '%s'?"
END
programs/wordpad/Nl.rc
View file @
77bf8991
...
...
@@ -73,3 +73,9 @@ BEGIN
END
END
END
STRINGTABLE DISCARDABLE
BEGIN
STRING_DEFAULT_FILENAME, "Document"
STRING_PROMPT_SAVE_CHANGES, "Save changes to '%s'?"
END
programs/wordpad/No.rc
View file @
77bf8991
...
...
@@ -80,3 +80,9 @@ BEGIN
STRING_TEXT_FILES_TXT, "Tekstfiler (*.txt)"
STRING_ALL_FILES, "Alle filer (*.*)"
END
STRINGTABLE DISCARDABLE
BEGIN
STRING_DEFAULT_FILENAME, "Dokument"
STRING_PROMPT_SAVE_CHANGES, "Lagre endringer i %s?"
END
programs/wordpad/Pl.rc
View file @
77bf8991
...
...
@@ -81,3 +81,9 @@ BEGIN
STRING_TEXT_FILES_TXT, "Dokument tekstowy (*.txt)"
STRING_ALL_FILES, "Wszystkie dokumenty (*.*)"
END
STRINGTABLE DISCARDABLE
BEGIN
STRING_DEFAULT_FILENAME, "Document"
STRING_PROMPT_SAVE_CHANGES, "Save changes to '%s'?"
END
programs/wordpad/Ru.rc
View file @
77bf8991
...
...
@@ -71,3 +71,9 @@ BEGIN
END
END
END
STRINGTABLE DISCARDABLE
BEGIN
STRING_DEFAULT_FILENAME, "Document"
STRING_PROMPT_SAVE_CHANGES, "Save changes to '%s'?"
END
programs/wordpad/Tr.rc
View file @
77bf8991
...
...
@@ -75,3 +75,9 @@ BEGIN
END
END
END
STRINGTABLE DISCARDABLE
BEGIN
STRING_DEFAULT_FILENAME, "Document"
STRING_PROMPT_SAVE_CHANGES, "Save changes to '%s'?"
END
programs/wordpad/resource.h
View file @
77bf8991
...
...
@@ -74,3 +74,6 @@
#define STRING_ALL_FILES 1400
#define STRING_TEXT_FILES_TXT 1401
#define STRING_RICHTEXT_FILES_RTF 1402
#define STRING_DEFAULT_FILENAME 1403
#define STRING_PROMPT_SAVE_CHANGES 1404
programs/wordpad/wordpad.c
View file @
77bf8991
...
...
@@ -47,6 +47,8 @@ static HWND hMainWnd;
static
HWND
hEditorWnd
;
static
WCHAR
wszFilter
[
MAX_STRING_LEN
];
static
WCHAR
wszDefaultFileName
[
MAX_STRING_LEN
];
static
WCHAR
wszSaveChanges
[
MAX_STRING_LEN
];
static
LRESULT
OnSize
(
HWND
hWnd
,
WPARAM
wParam
,
LPARAM
lParam
);
...
...
@@ -72,6 +74,12 @@ static void DoLoadStrings(void)
lstrcpyW
(
p
,
files_all
);
p
+=
lstrlenW
(
p
)
+
1
;
*
p
=
'\0'
;
p
=
wszDefaultFileName
;
LoadStringW
(
hInstance
,
STRING_DEFAULT_FILENAME
,
p
,
MAX_STRING_LEN
);
p
=
wszSaveChanges
;
LoadStringW
(
hInstance
,
STRING_PROMPT_SAVE_CHANGES
,
p
,
MAX_STRING_LEN
);
}
static
void
AddButton
(
HWND
hwndToolBar
,
int
nImage
,
int
nCommand
)
...
...
@@ -136,31 +144,27 @@ static WCHAR wszFileName[MAX_PATH];
static
void
set_caption
(
LPCWSTR
wszNewFileName
)
{
static
const
WCHAR
wszSeparator
[]
=
{
' '
,
'-'
,
' '
};
WCHAR
*
wszCaption
;
SIZE_T
length
=
0
;
if
(
wszNewFileName
)
{
WCHAR
*
wszCaption
;
SIZE_T
length
=
0
;
if
(
!
wszNewFileName
)
wszNewFileName
=
wszDefaultFileName
;
wszCaption
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
lstrlenW
(
wszNewFileName
)
*
sizeof
(
WCHAR
)
+
sizeof
(
wszSeparator
)
+
sizeof
(
wszAppTitle
));
wszCaption
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
lstrlenW
(
wszNewFileName
)
*
sizeof
(
WCHAR
)
+
sizeof
(
wszSeparator
)
+
sizeof
(
wszAppTitle
));
if
(
!
wszCaption
)
return
;
if
(
!
wszCaption
)
return
;
memcpy
(
wszCaption
,
wszNewFileName
,
lstrlenW
(
wszNewFileName
)
*
sizeof
(
WCHAR
));
length
+=
lstrlenW
(
wszNewFileName
);
memcpy
(
wszCaption
+
length
,
wszSeparator
,
sizeof
(
wszSeparator
));
length
+=
sizeof
(
wszSeparator
)
/
sizeof
(
WCHAR
);
memcpy
(
wszCaption
+
length
,
wszAppTitle
,
sizeof
(
wszAppTitle
));
memcpy
(
wszCaption
,
wszNewFileName
,
lstrlenW
(
wszNewFileName
)
*
sizeof
(
WCHAR
));
length
+=
lstrlenW
(
wszNewFileName
);
memcpy
(
wszCaption
+
length
,
wszSeparator
,
sizeof
(
wszSeparator
));
length
+=
sizeof
(
wszSeparator
)
/
sizeof
(
WCHAR
);
memcpy
(
wszCaption
+
length
,
wszAppTitle
,
sizeof
(
wszAppTitle
));
SetWindowTextW
(
hMainWnd
,
wszCaption
);
SetWindowTextW
(
hMainWnd
,
wszCaption
);
HeapFree
(
GetProcessHeap
(),
0
,
wszCaption
);
}
else
{
SetWindowTextW
(
hMainWnd
,
wszAppTitle
);
}
HeapFree
(
GetProcessHeap
(),
0
,
wszCaption
);
}
static
void
DoOpenFile
(
LPCWSTR
szOpenFileName
)
...
...
@@ -186,27 +190,7 @@ static void DoOpenFile(LPCWSTR szOpenFileName)
set_caption
(
szOpenFileName
);
lstrcpyW
(
wszFileName
,
szOpenFileName
);
}
static
void
DialogOpenFile
(
void
)
{
OPENFILENAMEW
ofn
;
WCHAR
wszFile
[
MAX_PATH
]
=
{
'\0'
};
static
const
WCHAR
wszDefExt
[]
=
{
'r'
,
't'
,
'f'
,
'\0'
};
ZeroMemory
(
&
ofn
,
sizeof
(
ofn
));
ofn
.
lStructSize
=
sizeof
(
ofn
);
ofn
.
Flags
=
OFN_HIDEREADONLY
|
OFN_FILEMUSTEXIST
|
OFN_PATHMUSTEXIST
;
ofn
.
hwndOwner
=
hMainWnd
;
ofn
.
lpstrFilter
=
wszFilter
;
ofn
.
lpstrFile
=
wszFile
;
ofn
.
nMaxFile
=
MAX_PATH
;
ofn
.
lpstrDefExt
=
wszDefExt
;
if
(
GetOpenFileNameW
(
&
ofn
))
DoOpenFile
(
ofn
.
lpstrFile
);
SendMessageW
(
hEditorWnd
,
EM_SETMODIFY
,
FALSE
,
0
);
}
static
void
DoSaveFile
(
LPCWSTR
wszSaveFileName
)
...
...
@@ -236,6 +220,7 @@ static void DoSaveFile(LPCWSTR wszSaveFileName)
lstrcpyW
(
wszFileName
,
wszSaveFileName
);
set_caption
(
wszFileName
);
SendMessageW
(
hEditorWnd
,
EM_SETMODIFY
,
FALSE
,
0
);
}
static
void
DialogSaveFile
(
void
)
...
...
@@ -261,6 +246,86 @@ static void DialogSaveFile(void)
DoSaveFile
(
sfn
.
lpstrFile
);
}
static
BOOL
prompt_save_changes
(
void
)
{
if
(
!
wszFileName
[
0
])
{
GETTEXTLENGTHEX
gt
;
gt
.
flags
=
GTL_NUMCHARS
;
gt
.
codepage
=
1200
;
if
(
!
SendMessageW
(
hEditorWnd
,
EM_GETTEXTLENGTHEX
,
(
WPARAM
)
&
gt
,
0
))
return
TRUE
;
}
if
(
!
SendMessageW
(
hEditorWnd
,
EM_GETMODIFY
,
0
,
0
))
{
return
TRUE
;
}
else
{
LPWSTR
displayFileName
;
WCHAR
*
text
;
int
ret
;
if
(
!
wszFileName
[
0
])
displayFileName
=
wszDefaultFileName
;
else
displayFileName
=
wszFileName
;
text
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
(
lstrlenW
(
displayFileName
)
+
lstrlenW
(
wszSaveChanges
))
*
sizeof
(
WCHAR
));
if
(
!
text
)
return
FALSE
;
wsprintfW
(
text
,
wszSaveChanges
,
displayFileName
);
ret
=
MessageBoxW
(
hMainWnd
,
text
,
wszAppTitle
,
MB_YESNOCANCEL
|
MB_ICONEXCLAMATION
);
HeapFree
(
GetProcessHeap
(),
0
,
text
);
switch
(
ret
)
{
case
IDNO
:
return
TRUE
;
break
;
case
IDYES
:
if
(
wszFileName
[
0
])
DoSaveFile
(
wszFileName
);
else
DialogSaveFile
();
return
TRUE
;
default:
return
FALSE
;
}
}
}
static
void
DialogOpenFile
(
void
)
{
OPENFILENAMEW
ofn
;
WCHAR
wszFile
[
MAX_PATH
]
=
{
'\0'
};
static
const
WCHAR
wszDefExt
[]
=
{
'r'
,
't'
,
'f'
,
'\0'
};
ZeroMemory
(
&
ofn
,
sizeof
(
ofn
));
ofn
.
lStructSize
=
sizeof
(
ofn
);
ofn
.
Flags
=
OFN_HIDEREADONLY
|
OFN_FILEMUSTEXIST
|
OFN_PATHMUSTEXIST
;
ofn
.
hwndOwner
=
hMainWnd
;
ofn
.
lpstrFilter
=
wszFilter
;
ofn
.
lpstrFile
=
wszFile
;
ofn
.
nMaxFile
=
MAX_PATH
;
ofn
.
lpstrDefExt
=
wszDefExt
;
if
(
GetOpenFileNameW
(
&
ofn
))
{
prompt_save_changes
();
DoOpenFile
(
ofn
.
lpstrFile
);
}
}
static
void
HandleCommandLine
(
LPWSTR
cmdline
)
{
WCHAR
delimiter
;
...
...
@@ -473,6 +538,7 @@ static LRESULT OnCreate( HWND hWnd, WPARAM wParam, LPARAM lParam)
DoDefaultFont
();
DoLoadStrings
();
SendMessageW
(
hEditorWnd
,
EM_SETMODIFY
,
FALSE
,
0
);
return
0
;
}
...
...
@@ -559,10 +625,14 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam)
break
;
case
ID_FILE_NEW
:
set_caption
(
NULL
);
wszFileName
[
0
]
=
'\0'
;
SetWindowTextW
(
hwndEditor
,
wszFileName
);
/* FIXME: set default format too */
if
(
prompt_save_changes
())
{
set_caption
(
NULL
);
wszFileName
[
0
]
=
'\0'
;
SetWindowTextW
(
hwndEditor
,
wszFileName
);
SendMessageW
(
hEditorWnd
,
EM_SETMODIFY
,
FALSE
,
0
);
/* FIXME: set default format too */
}
break
;
case
ID_FILE_OPEN
:
...
...
@@ -887,6 +957,11 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara
PostQuitMessage
(
0
);
break
;
case
WM_CLOSE
:
if
(
prompt_save_changes
())
PostQuitMessage
(
0
);
break
;
case
WM_ACTIVATE
:
if
(
LOWORD
(
wParam
))
SetFocus
(
GetDlgItem
(
hWnd
,
IDC_EDITOR
));
...
...
@@ -934,6 +1009,8 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hOldInstance, LPSTR szCmdPar
CW_USEDEFAULT
,
CW_USEDEFAULT
,
680
,
260
,
NULL
,
NULL
,
hInstance
,
NULL
);
ShowWindow
(
hMainWnd
,
SW_SHOWDEFAULT
);
set_caption
(
NULL
);
HandleCommandLine
(
GetCommandLineW
());
while
(
GetMessageW
(
&
msg
,
0
,
0
,
0
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment