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
}

Reply via email to