copy and paste in program

Joel Christensen joelcnz at gmail.com
Mon Sep 12 02:02:58 PDT 2011


I mean, I can't copy text from my program to the clipboard.

- Joelcnz

On 12-Sep-11 3:50 PM, Joel Christensen wrote:
> Thanks Jimmy. Your example worked. Or though I haven't managed to get
> the other way to work.
>
> [code]
> import std.stdio;
> //import core.stdc.string;
> import std.c.string;
> import std.string;
> import std.conv;
>
> extern(Windows) {
> bool OpenClipboard(void*);
> void* GetClipboardData(uint);
> void* SetClipboardData(uint, void*);
> }
>
> void main() {
> if (OpenClipboard(null)) {
> auto cstr = cast(char*)GetClipboardData( 1 );
> if (cstr)
> writeln(to!string(cast(char*)cstr[0..strlen(cstr)]));
>
> SetClipboardData( 1, cast(char*)toStringz( "data set" ) );
> }
> }
> [/code]



More information about the Digitalmars-d-learn mailing list