1 |
/* wptClipEditDlg.cpp - Clipboard Editor dialog |
/* wptClipEditDlg.cpp - Clipboard Editor dialog |
2 |
* Copyright (C) 2000-2005 Timo Schulz |
* Copyright (C) 2000-2006 Timo Schulz |
3 |
* |
* |
4 |
* This file is part of WinPT. |
* This file is part of WinPT. |
5 |
* |
* |
34 |
|
|
35 |
#ifdef _MSC_VER |
#ifdef _MSC_VER |
36 |
#include "winpt_header.h" |
#include "winpt_header.h" |
37 |
|
|
38 |
static DWORD help_arr[] = { |
static DWORD help_arr[] = { |
39 |
IDC_CLIPEDIT_SEND, WPT_CLIPEDIT_COPY, |
IDC_CLIPEDIT_SEND, WPT_CLIPEDIT_COPY, |
40 |
IDC_CLIPEDIT_CLEAR, WPT_CLIPEDIT_CLEAR, |
IDC_CLIPEDIT_CLEAR, WPT_CLIPEDIT_CLEAR, |
41 |
IDC_CLIPEDIT_LOAD, WPT_CLIPEDIT_LOAD, |
IDC_CLIPEDIT_LOAD, WPT_CLIPEDIT_LOAD, |
42 |
IDC_CLIPEDIT_SAVE, WPT_CLIPEDIT_SAVE, |
IDC_CLIPEDIT_SAVE, WPT_CLIPEDIT_SAVE, |
43 |
IDC_CLIPEDIT_QUOTE, WPT_CLIPEDIT_QUOTE, |
IDC_CLIPEDIT_QUOTE, WPT_CLIPEDIT_QUOTE, |
44 |
0, 0 |
0, 0}; |
|
}; |
|
45 |
#endif |
#endif |
46 |
|
|
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. */ |
50 |
static int |
static int |
77 |
strcpy (p, cliptext); |
strcpy (p, cliptext); |
78 |
|
|
79 |
GlobalUnlock (clipmem); |
GlobalUnlock (clipmem); |
80 |
CloseClipboard (); |
CloseClipboard (); |
81 |
SetDlgItemText (dlg, IDC_CLIPEDIT_CLIPTEXT2, p); |
SetDlgItemText (dlg, IDC_CLIPEDIT_CLIPTEXT2, p); |
82 |
free_if_alloc (p); |
free_if_alloc (p); |
83 |
|
|
84 |
return 0; |
return 0; |
97 |
int id; |
int id; |
98 |
|
|
99 |
memset (&open, 0, sizeof (open)); |
memset (&open, 0, sizeof (open)); |
100 |
open.lStructSize = sizeof (OPENFILENAME); |
open.lStructSize = sizeof (OPENFILENAME); |
101 |
open.hInstance = glob_hinst; |
open.hInstance = glob_hinst; |
102 |
open.lpstrTitle = _("File Open"); |
open.lpstrTitle = _("File Open"); |
103 |
open.lpstrFilter = (char *)_("All Files (*.*)\0*.*\0\0"); |
open.lpstrFilter = "All Files (*.*)\0*.*\0\0"; |
104 |
open.hwndOwner = dlg; |
open.hwndOwner = dlg; |
105 |
open.lpstrFile = file; |
open.lpstrFile = file; |
106 |
open.nMaxFile = sizeof (file)-1; |
open.nMaxFile = sizeof (file)-1; |
107 |
open.Flags = OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST; |
open.Flags = OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST; |
108 |
|
|
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"), |
"Still proceed?"), _("Clipboard"), |
113 |
MB_INFO|MB_YESNO); |
MB_INFO|MB_YESNO); |
123 |
p = new char[size+1]; |
p = new char[size+1]; |
124 |
if (!p) |
if (!p) |
125 |
BUG (0); |
BUG (0); |
126 |
fread (p, 1, size, fp); |
memset (p, 0, size+1); |
127 |
p[size] = '\0'; |
size = fread (p, 1, size, fp); |
128 |
fclose (fp); |
fclose (fp); |
129 |
SetDlgItemText (dlg, IDC_CLIPEDIT_CLIPTEXT2, p); |
SetDlgItemText (dlg, IDC_CLIPEDIT_CLIPTEXT2, p); |
130 |
free_if_alloc (p); |
free_if_alloc (p); |
148 |
save.lStructSize = sizeof (OPENFILENAME); |
save.lStructSize = sizeof (OPENFILENAME); |
149 |
save.hInstance = glob_hinst; |
save.hInstance = glob_hinst; |
150 |
save.lpstrTitle = _("File Save"); |
save.lpstrTitle = _("File Save"); |
151 |
save.lpstrFile = (char *)_("All Files (*.*)\0*.*\0\0"); |
save.lpstrFile = (char *)"All Files (*.*)\0*.*\0\0"; |
152 |
save.hwndOwner = dlg; |
save.hwndOwner = dlg; |
153 |
save.lpstrFile = file; |
save.lpstrFile = file; |
154 |
save.nMaxFile = sizeof (file) - 1; |
save.nMaxFile = sizeof (file) - 1; |
155 |
save.Flags = OFN_OVERWRITEPROMPT; |
save.Flags = OFN_OVERWRITEPROMPT; |
156 |
|
|
157 |
if( GetSaveFileName( &save ) ) { |
if (GetSaveFileName (&save)) { |
158 |
if( file_exist_check( file ) == 0 ) { |
if (file_exist_check (file) == 0) { |
159 |
id = log_box (_("Clipboard"), MB_YESNO, |
id = log_box (_("Clipboard"), MB_YESNO, |
160 |
_("\"%s\" already exists.\n" |
_("\"%s\" already exists.\n" |
161 |
"Replace existing file?"), file); |
"Replace existing file?"), file); |
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")); |
SetDlgItemText (dlg, IDC_CLIPEDIT_QUOTE, _("Add quotes")); |
201 |
SetDlgItemText (dlg, IDOK, _("&Exit")); |
SetDlgItemText (dlg, IDOK, _("&Close")); |
202 |
|
|
203 |
load_clipboard (dlg); |
load_clipboard (dlg); |
204 |
center_window (dlg, NULL); |
center_window (dlg, NULL); |
205 |
SetForegroundWindow (dlg); |
SetForegroundWindow (dlg); |
206 |
return TRUE; |
return TRUE; |
207 |
|
|
208 |
case WM_SYSCOMMAND: |
case WM_HELP: |
209 |
if (LOWORD (wparam) == SC_CLOSE) |
html_help_dispatch (lparam, "winpt.chm::winpt_texts.txt", help_arr); |
210 |
EndDialog (dlg, TRUE); |
break; |
|
return TRUE; |
|
211 |
|
|
212 |
case WM_COMMAND: |
case WM_COMMAND: |
213 |
switch (LOWORD (wparam)) { |
switch (LOWORD (wparam)) { |
214 |
|
case IDCANCEL: |
215 |
|
EndDialog (dlg, FALSE); |
216 |
|
return TRUE; |
217 |
|
|
218 |
case IDOK: |
case IDOK: |
219 |
EndDialog (dlg, TRUE); |
EndDialog (dlg, TRUE); |
220 |
return TRUE; |
return TRUE; |
248 |
|
|
249 |
case IDC_CLIPEDIT_LOAD: |
case IDC_CLIPEDIT_LOAD: |
250 |
if (!load_clipboard_from_file (dlg)) { |
if (!load_clipboard_from_file (dlg)) { |
251 |
/* XXX: for some files the code produces a crash! */ |
CheckDlgButton (dlg, IDC_CLIPEDIT_QUOTE, BST_UNCHECKED); |
252 |
PostMessage (dlg, WM_COMMAND, MAKEWPARAM(IDC_CLIPEDIT_SEND, 0), 0); |
PostMessage (dlg, WM_COMMAND, MAKEWPARAM (IDC_CLIPEDIT_SEND, 0), 0); |
253 |
} |
} |
254 |
return TRUE; |
return TRUE; |
255 |
|
|