Programming with windows api (windows.h)
John Chapman
johnch_atms at hotmail.com
Mon Dec 17 10:19:31 PST 2012
On Monday, 17 December 2012 at 16:21:09 UTC, monarch_dodra wrote:
> I'm a bit confused about how to interface with windows.h.
>
> All I'm trying to do is retrieve some text from my clipboard to
> print it.
Something like this:
HWND hwnd = ... // your window handle (or null)
if (OpenClipboard(hwnd)) {
HGLOBAL data = GetClipboardData(CF_TEXT);
if (data) {
auto text = cast(wchar*)GlobalLock(data);
writeln(to!string(text[0 .. wcslen(text)]));
GlobalUnlock(data);
}
}
You'll have to define GlobalLock/GlobalUnlock, and values for the
various clipboard formats (CF_TEXT and co) are documented here:
http://msdn.microsoft.com/en-gb/library/windows/desktop/ff729168%28v=vs.85%29.aspx
> I'm hitting a wall at "CF_TEXT" though: That's an enum.
enum : uint {
CF_TEXT = 1,
CF_BITMAP = 2, // and so on
}
More information about the Digitalmars-d-learn
mailing list