Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexey Alyaev
wine
Commits
a28f91f1
Commit
a28f91f1
authored
17 years ago
by
Alexander Nicolaysen Sørnes
Committed by
Alexandre Julliard
17 years ago
Browse files
Options
Downloads
Patches
Plain Diff
wordpad: Add file saving support.
parent
d072e8b1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
programs/wordpad/wordpad.c
+51
-0
51 additions, 0 deletions
programs/wordpad/wordpad.c
with
51 additions
and
0 deletions
programs/wordpad/wordpad.c
+
51
−
0
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
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment