The R Project SVN R

Rev

Rev 5458 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5458 Rev 9211
Line 55... Line 55...
55
    }
55
    }
56
    SetClipboardData(CF_BITMAP, hbmpNew);
56
    SetClipboardData(CF_BITMAP, hbmpNew);
57
    CloseClipboard();
57
    CloseClipboard();
58
    return;
58
    return;
59
}
59
}
-
 
60
 
-
 
61
int copystringtoclipboard(char *str)
-
 
62
{
-
 
63
    HGLOBAL hglb;
-
 
64
    char *s;
-
 
65
    int ll = strlen(str) + 1;
-
 
66
 
-
 
67
    if (!(hglb = GlobalAlloc(GHND, ll))){
-
 
68
        R_ShowMessage("Insufficient memory: cell not copied to the clipboard");
-
 
69
	return 1;
-
 
70
    }
-
 
71
    if (!(s = (char *)GlobalLock(hglb))){
-
 
72
        R_ShowMessage("Insufficient memory: cell not copied to the clipboard");
-
 
73
	return 1;
-
 
74
    }
-
 
75
    strcpy(s, str);
-
 
76
    GlobalUnlock(hglb);
-
 
77
    if (!OpenClipboard(NULL) || !EmptyClipboard()) {
-
 
78
        R_ShowMessage("Unable to open the clipboard");
-
 
79
        GlobalFree(hglb);
-
 
80
        return 1;
-
 
81
    }
-
 
82
    SetClipboardData(CF_TEXT, hglb);
-
 
83
    CloseClipboard();
-
 
84
    return 0;
-
 
85
}
-
 
86
 
-
 
87
int getstringfromclipboard(char * str, int n)
-
 
88
{
-
 
89
    HGLOBAL hglb;
-
 
90
    char *pc;
-
 
91
 
-
 
92
    if ( OpenClipboard(NULL) &&
-
 
93
         (hglb = GetClipboardData(CF_TEXT)) &&
-
 
94
         (pc = (char *)GlobalLock(hglb))) {
-
 
95
	strncpy(str, pc, n);
-
 
96
	str[n+1] = '\0';
-
 
97
        GlobalUnlock(hglb);
-
 
98
	CloseClipboard();
-
 
99
	return 0;
-
 
100
    } else return 1;
-
 
101
}
-
 
102
 
-
 
103
int clipboardhastext()
-
 
104
{
-
 
105
    return (int) IsClipboardFormatAvailable(CF_TEXT);
-
 
106
}