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
a28f91f1
Commit
a28f91f1
authored
Jun 02, 2007
by
Alexander Nicolaysen Sørnes
Committed by
Alexandre Julliard
Jun 04, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wordpad: Add file saving support.
parent
d072e8b1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
wordpad.c
programs/wordpad/wordpad.c
+51
-0
No files found.
programs/wordpad/wordpad.c
View file @
a28f91f1
...
...
@@ -114,6 +114,22 @@ static DWORD CALLBACK stream_in(DWORD_PTR cookie, LPBYTE buffer, LONG cb, LONG *
return
0
;
}
static
DWORD
CALLBACK
stream_out
(
DWORD_PTR
cookie
,
LPBYTE
buffer
,
LONG
cb
,
LONG
*
pcb
)
{
DWORD
written
;
int
ret
;
HANDLE
hFile
=
(
HANDLE
)
cookie
;
ret
=
WriteFile
(
hFile
,
buffer
,
cb
,
&
written
,
0
);
if
(
!
ret
||
(
cb
!=
written
))
return
1
;
*
pcb
=
cb
;
return
0
;
}
static
WCHAR
wszFileName
[
MAX_PATH
];
static
void
set_caption
(
LPCWSTR
wszNewFileName
)
...
...
@@ -213,6 +229,35 @@ static void DialogOpenFile(void)
}
}
static
void
DoSaveFile
(
LPCWSTR
wszSaveFileName
)
{
HANDLE
hFile
;
EDITSTREAM
stream
;
LRESULT
ret
;
hFile
=
CreateFileW
(
wszSaveFileName
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
if
(
hFile
==
INVALID_HANDLE_VALUE
)
return
;
stream
.
dwCookie
=
(
DWORD_PTR
)
hFile
;
stream
.
pfnCallback
=
stream_out
;
/* FIXME: Handle different formats */
ret
=
SendMessageW
(
hEditorWnd
,
EM_STREAMOUT
,
SF_RTF
,
(
LPARAM
)
&
stream
);
CloseHandle
(
hFile
);
SetFocus
(
hEditorWnd
);
if
(
!
ret
)
return
;
lstrcpyW
(
wszFileName
,
wszSaveFileName
);
set_caption
(
wszFileName
);
}
static
void
HandleCommandLine
(
LPWSTR
cmdline
)
{
WCHAR
delimiter
;
...
...
@@ -455,6 +500,12 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam)
break
;
case
ID_FILE_SAVE
:
if
(
wszFileName
[
0
])
DoSaveFile
(
wszFileName
);
else
MessageBox
(
hWnd
,
"Can only save existing for now"
,
"WordPad"
,
MB_OK
);
break
;
case
ID_PRINT
:
case
ID_PREVIEW
:
case
ID_FIND
:
...
...
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