/[gpgoe]/trunk/src/OEDlgViewer.c
ViewVC logotype

Annotation of /trunk/src/OEDlgViewer.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (hide annotations)
Fri Mar 24 13:36:54 2006 UTC (19 years, 1 month ago) by twoaday
File MIME type: text/plain
File size: 2297 byte(s)
Initial checkin of the GPGOE code.


1 twoaday 1 /* OEDlgViewer.c - OE text viewer
2     * Copyright (C) 2001, 2002, 2003, 2006 Timo Schulz
3     *
4     * This file is part of GPGOE.
5     *
6     * GPGOE is free software; you can redistribute it and/or modify
7     * it under the terms of the GNU Lesser General Public License as published by
8     * the Free Software Foundation; either version 2.1 of the License, or
9     * (at your option) any later version.
10     *
11     * GPGOE is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU Lesser General Public License
17     * along with GPGOE; if not, write to the Free Software Foundation,
18     * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19     */
20    
21     #ifdef HAVE_CONFIG_H
22     #include <config.h>
23     #endif
24     #include <windows.h>
25     #include <assert.h>
26     #include "resource.h"
27     #include "gpgme.h"
28     #include "GPGOE.h"
29    
30    
31     /* Read all text from the dialog item @id and
32     return it as a string. */
33     char*
34     get_item_text (HWND dlg, int id)
35     {
36     char *p;
37     int n;
38    
39     n = SendDlgItemMessage (dlg, id, WM_GETTEXTLENGTH, 0, 0);
40     if (n < 1)
41     return NULL;
42     p = xcalloc (1, n+1);
43     n = GetDlgItemText (dlg, IDC_VIEWER_TEXT, p, n);
44     return p;
45     }
46    
47    
48     /* Text viewer dialog box procedure. */
49     BOOL CALLBACK
50     viewer_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
51     {
52     static viewer_ctx_t viewer;
53     char *p;
54    
55     switch (msg) {
56     case WM_INITDIALOG:
57     viewer = (viewer_ctx_t)lparam;
58     assert (viewer);
59     SetWindowText (dlg, _("Message Viewer"));
60     SetDlgItemText (dlg, IDC_VIEWER_TEXT, viewer->msg);
61     SetForegroundWindow (dlg);
62     SetFocus (GetDlgItem (dlg, IDOK));
63     return FALSE;
64    
65     case WM_SYSCOMMAND:
66     if (LOWORD (wparam) == SC_CLOSE)
67     EndDialog (dlg, 0);
68     return FALSE;
69    
70     case WM_COMMAND:
71     switch (LOWORD (wparam)) {
72     case IDOK:
73     EndDialog (dlg, 0);
74     return TRUE;
75    
76     case IDC_VIEWER_QUOTE:
77     p = get_item_text (dlg, IDC_VIEWER_TEXT);
78     free_if_alloc (p);
79     return TRUE;
80    
81     case IDC_VIEWER_COPY:
82     p = get_item_text (dlg, IDC_VIEWER_TEXT);
83     if (p != NULL)
84     set_clip_text (NULL, p, strlen (p));
85     free_if_alloc (p);
86     return TRUE;
87     }
88     break;
89     }
90     return FALSE;
91     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26