17 |
* along with WinPT; if not, write to the Free Software Foundation, |
* along with WinPT; if not, write to the Free Software Foundation, |
18 |
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
19 |
*/ |
*/ |
|
|
|
20 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
21 |
#include <config.h> |
#include <config.h> |
22 |
#endif |
#endif |
23 |
|
|
24 |
#include <windows.h> |
#include <windows.h> |
|
#include <windows.h> |
|
25 |
#include <stdio.h> |
#include <stdio.h> |
26 |
|
|
27 |
#include "wptTypes.h" |
#include "wptTypes.h" |
32 |
#include "wptNLS.h" |
#include "wptNLS.h" |
33 |
#include "resource.h" |
#include "resource.h" |
34 |
|
|
35 |
|
#ifdef _MSC_VER |
36 |
|
#include "winpt_header.h" |
37 |
|
|
38 |
|
static DWORD help_arr[] = { |
39 |
|
IDC_CLIPEDIT_SEND, WPT_CLIPEDIT_COPY, |
40 |
|
IDC_CLIPEDIT_CLEAR, WPT_CLIPEDIT_CLEAR, |
41 |
|
IDC_CLIPEDIT_LOAD, WPT_CLIPEDIT_LOAD, |
42 |
|
IDC_CLIPEDIT_SAVE, WPT_CLIPEDIT_SAVE, |
43 |
|
IDC_CLIPEDIT_QUOTE, WPT_CLIPEDIT_QUOTE, |
44 |
|
0, 0 |
45 |
|
}; |
46 |
|
#endif |
47 |
|
|
48 |
/* Load the clipboard contents into the text field in @dlg. |
/* Load the clipboard contents into the text field in @dlg. |
49 |
Return value: 0 on success. */ |
Return value: 0 on success. */ |
109 |
if (GetOpenFileName (&open)) { |
if (GetOpenFileName (&open)) { |
110 |
if( (size=get_file_size (file)) > MAX_CLIPTEXT_SIZE) { |
if( (size=get_file_size (file)) > MAX_CLIPTEXT_SIZE) { |
111 |
id = msg_box (dlg, _("The file you want to add is very large.\n" |
id = msg_box (dlg, _("The file you want to add is very large.\n" |
112 |
"Still proceed?"), _("Clipboard"), MB_INFO|MB_YESNO); |
"Still proceed?"), _("Clipboard"), |
113 |
if (id == IDNO) |
MB_INFO|MB_YESNO); |
114 |
|
if (id == IDNO) |
115 |
return -1; |
return -1; |
116 |
} |
} |
117 |
fp = fopen (file, "rb"); |
fp = fopen (file, "rb"); |
118 |
if (!fp) { |
if (!fp) { |
119 |
msg_box (dlg, winpt_strerror (WPTERR_FILE_OPEN), _("Clipboard"), MB_ERR); |
msg_box (dlg, winpt_strerror (WPTERR_FILE_OPEN), |
120 |
|
_("Clipboard"), MB_ERR); |
121 |
return FALSE; |
return FALSE; |
122 |
} |
} |
123 |
p = new char[size+1]; |
p = new char[size+1]; |
139 |
{ |
{ |
140 |
OPENFILENAME save; |
OPENFILENAME save; |
141 |
FILE *fp; |
FILE *fp; |
142 |
char *p; |
char *p=NULL; |
143 |
char file[300] = ""; |
char file[300] = ""; |
144 |
DWORD nbytes; |
DWORD nbytes; |
145 |
int id; |
int id; |
164 |
} |
} |
165 |
fp = fopen (file, "wb"); |
fp = fopen (file, "wb"); |
166 |
if (!fp) { |
if (!fp) { |
167 |
msg_box (dlg, winpt_strerror (WPTERR_FILE_CREAT), _("Clipboard"), MB_ERR); |
msg_box (dlg, winpt_strerror (WPTERR_FILE_CREAT), |
168 |
|
_("Clipboard"), MB_ERR); |
169 |
return FALSE; |
return FALSE; |
170 |
} |
} |
171 |
/* XXX: there is a NUL-byte at the end. */ |
/* XXX: there is a NUL-byte at the end. */ |
172 |
nbytes = SendDlgItemMessage (dlg, IDC_CLIPEDIT_CLIPTEXT2, WM_GETTEXTLENGTH, 0, 0); |
nbytes = SendDlgItemMessage (dlg, IDC_CLIPEDIT_CLIPTEXT2, |
173 |
|
WM_GETTEXTLENGTH, 0, 0); |
174 |
if (nbytes > 0) { |
if (nbytes > 0) { |
175 |
p = new char[nbytes+1]; |
p = new char[nbytes+1]; |
176 |
if (!p) |
if (!p) |
177 |
BUG (NULL); |
BUG (NULL); |
178 |
GetDlgItemText (dlg, IDC_CLIPEDIT_CLIPTEXT2, p, nbytes); |
GetDlgItemText (dlg, IDC_CLIPEDIT_CLIPTEXT2, p, nbytes); |
179 |
fwrite (p, 1, nbytes, fp); |
fwrite (p, 1, nbytes, fp); |
180 |
|
|
181 |
} |
} |
182 |
fclose (fp); |
fclose (fp); |
183 |
free_if_alloc (p); |
free_if_alloc (p); |
197 |
SetDlgItemText (dlg, IDC_CLIPEDIT_CLEAR, _("Clea&r")); |
SetDlgItemText (dlg, IDC_CLIPEDIT_CLEAR, _("Clea&r")); |
198 |
SetDlgItemText (dlg, IDC_CLIPEDIT_LOAD, _("&Load")); |
SetDlgItemText (dlg, IDC_CLIPEDIT_LOAD, _("&Load")); |
199 |
SetDlgItemText (dlg, IDC_CLIPEDIT_SAVE, _("&Save")); |
SetDlgItemText (dlg, IDC_CLIPEDIT_SAVE, _("&Save")); |
200 |
|
SetDlgItemText (dlg, IDC_CLIPEDIT_QUOTE, _("Add quotes")); |
201 |
|
SetDlgItemText (dlg, IDOK, _("&Exit")); |
202 |
|
|
203 |
load_clipboard (dlg); |
load_clipboard (dlg); |
204 |
center_window (dlg, NULL); |
center_window (dlg, NULL); |
246 |
case IDC_CLIPEDIT_LOAD: |
case IDC_CLIPEDIT_LOAD: |
247 |
if (!load_clipboard_from_file (dlg)) { |
if (!load_clipboard_from_file (dlg)) { |
248 |
/* XXX: for some files the code produces a crash! */ |
/* XXX: for some files the code produces a crash! */ |
249 |
PostMessage (dlg, WM_COMMAND, MAKEWPARAM(IDC_CLIPEDIT_SEND, 0), NULL); |
PostMessage (dlg, WM_COMMAND, MAKEWPARAM(IDC_CLIPEDIT_SEND, 0), 0); |
250 |
} |
} |
251 |
return TRUE; |
return TRUE; |
252 |
|
|
259 |
|
|
260 |
return FALSE; |
return FALSE; |
261 |
} |
} |
|
|
|