/[winpt]/trunk/Src/wptClipEditDlg.cpp
ViewVC logotype

Diff of /trunk/Src/wptClipEditDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 47 by werner, Mon Oct 31 14:04:59 2005 UTC revision 174 by twoaday, Thu Feb 2 08:20:50 2006 UTC
# Line 17  Line 17 
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"
# Line 34  Line 32 
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    #endif
46    
47  /* Load the clipboard contents into the text field in @dlg.  /* Load the clipboard contents into the text field in @dlg.
48     Return value: 0 on success. */     Return value: 0 on success. */
# Line 90  load_clipboard_from_file (HWND dlg) Line 99  load_clipboard_from_file (HWND dlg)
99      open.lStructSize = sizeof (OPENFILENAME);            open.lStructSize = sizeof (OPENFILENAME);      
100      open.hInstance = glob_hinst;                  open.hInstance = glob_hinst;            
101      open.lpstrTitle = _("File Open");            open.lpstrTitle = _("File Open");      
102      open.lpstrFilter = (char *)_("All Files (*.*)\0*.*\0\0");            open.lpstrFilter = (char *)"All Files (*.*)\0*.*\0\0";
103      open.hwndOwner = dlg;                open.hwndOwner = dlg;          
104      open.lpstrFile = file;                        open.lpstrFile = file;                  
105      open.nMaxFile = sizeof (file)-1;                      open.nMaxFile = sizeof (file)-1;                
# Line 99  load_clipboard_from_file (HWND dlg) Line 108  load_clipboard_from_file (HWND dlg)
108      if (GetOpenFileName (&open)) {      if (GetOpenFileName (&open)) {
109          if( (size=get_file_size (file)) > MAX_CLIPTEXT_SIZE) {                if( (size=get_file_size (file)) > MAX_CLIPTEXT_SIZE) {      
110              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"
111                                   "Still proceed?"), _("Clipboard"), MB_INFO|MB_YESNO);                                         "Still proceed?"), _("Clipboard"),
112              if (id == IDNO)                                MB_INFO|MB_YESNO);
113                if (id == IDNO)
114                  return -1;                  return -1;
115          }          }
116          fp = fopen (file, "rb");          fp = fopen (file, "rb");
117          if (!fp) {          if (!fp) {
118              msg_box (dlg, winpt_strerror (WPTERR_FILE_OPEN), _("Clipboard"), MB_ERR);              msg_box (dlg, winpt_strerror (WPTERR_FILE_OPEN),
119                         _("Clipboard"), MB_ERR);
120              return FALSE;              return FALSE;
121          }          }
122          p = new char[size+1];          p = new char[size+1];
# Line 127  save_clipboard_to_file (HWND dlg) Line 138  save_clipboard_to_file (HWND dlg)
138  {  {
139      OPENFILENAME save;      OPENFILENAME save;
140      FILE *fp;      FILE *fp;
141      char *p;      char *p=NULL;
142      char file[300] = "";      char file[300] = "";
143      DWORD nbytes;      DWORD nbytes;
144      int id;      int id;
# Line 136  save_clipboard_to_file (HWND dlg) Line 147  save_clipboard_to_file (HWND dlg)
147      save.lStructSize = sizeof (OPENFILENAME);            save.lStructSize = sizeof (OPENFILENAME);      
148      save.hInstance = glob_hinst;                  save.hInstance = glob_hinst;            
149      save.lpstrTitle = _("File Save");            save.lpstrTitle = _("File Save");      
150      save.lpstrFile = (char *)_("All Files (*.*)\0*.*\0\0");              save.lpstrFile = (char *)"All Files (*.*)\0*.*\0\0";
151      save.hwndOwner = dlg;                        save.hwndOwner = dlg;                  
152      save.lpstrFile = file;                        save.lpstrFile = file;                  
153      save.nMaxFile = sizeof (file) - 1;      save.nMaxFile = sizeof (file) - 1;
# Line 152  save_clipboard_to_file (HWND dlg) Line 163  save_clipboard_to_file (HWND dlg)
163          }          }
164          fp = fopen (file, "wb");          fp = fopen (file, "wb");
165          if (!fp) {          if (!fp) {
166              msg_box (dlg, winpt_strerror (WPTERR_FILE_CREAT), _("Clipboard"), MB_ERR);              msg_box (dlg, winpt_strerror (WPTERR_FILE_CREAT),
167                         _("Clipboard"), MB_ERR);
168              return FALSE;              return FALSE;
169          }          }
170          /* XXX: there is a NUL-byte at the end. */          /* XXX: there is a NUL-byte at the end. */
171          nbytes = SendDlgItemMessage (dlg, IDC_CLIPEDIT_CLIPTEXT2, WM_GETTEXTLENGTH, 0, 0);          nbytes = SendDlgItemMessage (dlg, IDC_CLIPEDIT_CLIPTEXT2,
172                                         WM_GETTEXTLENGTH, 0, 0);
173          if (nbytes > 0) {          if (nbytes > 0) {
174              p = new char[nbytes+1];              p = new char[nbytes+1];
175              if (!p)              if (!p)
176                  BUG (NULL);                  BUG (NULL);
177              GetDlgItemText (dlg, IDC_CLIPEDIT_CLIPTEXT2, p, nbytes);              GetDlgItemText (dlg, IDC_CLIPEDIT_CLIPTEXT2, p, nbytes);
178              fwrite (p, 1, nbytes, fp);              fwrite (p, 1, nbytes, fp);
179                
180          }                    }          
181          fclose (fp);          fclose (fp);
182          free_if_alloc (p);          free_if_alloc (p);
# Line 182  clip_edit_dlg_proc (HWND dlg, UINT msg, Line 196  clip_edit_dlg_proc (HWND dlg, UINT msg,
196          SetDlgItemText (dlg, IDC_CLIPEDIT_CLEAR, _("Clea&r"));          SetDlgItemText (dlg, IDC_CLIPEDIT_CLEAR, _("Clea&r"));
197          SetDlgItemText (dlg, IDC_CLIPEDIT_LOAD, _("&Load"));              SetDlgItemText (dlg, IDC_CLIPEDIT_LOAD, _("&Load"));    
198          SetDlgItemText (dlg, IDC_CLIPEDIT_SAVE, _("&Save"));          SetDlgItemText (dlg, IDC_CLIPEDIT_SAVE, _("&Save"));
199            SetDlgItemText (dlg, IDC_CLIPEDIT_QUOTE, _("Add quotes"));
200            SetDlgItemText (dlg, IDOK, _("&Close"));
201    
202          load_clipboard (dlg);          load_clipboard (dlg);
203          center_window (dlg, NULL);          center_window (dlg, NULL);
204          SetForegroundWindow (dlg);          SetForegroundWindow (dlg);
205          return TRUE;          return TRUE;
206                    
207        case WM_HELP:
208            html_help_dispatch (lparam, "winpt.chm::winpt_texts.txt", help_arr);
209            break;
210    
211      case WM_SYSCOMMAND:      case WM_SYSCOMMAND:
212          if (LOWORD (wparam) == SC_CLOSE)          if (LOWORD (wparam) == SC_CLOSE)
213              EndDialog (dlg, TRUE);              EndDialog (dlg, TRUE);
# Line 229  clip_edit_dlg_proc (HWND dlg, UINT msg, Line 249  clip_edit_dlg_proc (HWND dlg, UINT msg,
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! */                  /* XXX: for some files the code produces a crash! */
252                  PostMessage (dlg, WM_COMMAND, MAKEWPARAM(IDC_CLIPEDIT_SEND, 0), NULL);                  PostMessage (dlg, WM_COMMAND, MAKEWPARAM(IDC_CLIPEDIT_SEND, 0), 0);
253              }              }
254              return TRUE;              return TRUE;
255                            
# Line 242  clip_edit_dlg_proc (HWND dlg, UINT msg, Line 262  clip_edit_dlg_proc (HWND dlg, UINT msg,
262            
263      return FALSE;      return FALSE;
264  }  }
   

Legend:
Removed from v.47  
changed lines
  Added in v.174

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26