From: Michael Slater Date: 2003-08-31T20:40:10+09:00 Subject: Re: FXRuby and clipboard contents > > text = FXfoobarWindowsStuff.clipboard.get # or whatever > > FXfoobarWindowsStuff.clipboard.copy("Hello!") # "Hello!" into clipbd > > > Yep, that's exactly what I'd like to do. To roll your own Ruby extension in C -- If you are just talking about cut and pasting "plain text" (i.e. Windows clipboard format CF_TEXT), then it should be relatively straightforward. To get data, you'll need some low-level code to open the clipboard, get the handle to the clipboard data you want in the format you want, copy the data as a string, unlock the handle, and close the clipboard. The FOX C++ source code will show you the basic game plan. In the FOX world -- In the underlying FOX C++ code, there are the below FXApp methods: clipboardSetData clipboardGetData clipboardGetTypes For example, from fxpriv.cpp -- void FXApp::clipboardGetData(const FXWindow* window,FXDragType type,FXuchar*& data,FXuint& size){ data=NULL; size=0; if(IsClipboardFormatAvailable(type)){ if(OpenClipboard((HWND)window->id())){ HANDLE hClipMemory=GetClipboardData(type); if(hClipMemory){ size=(FXuint)GlobalSize(hClipMemory); if(FXMALLOC(&data,FXuchar,size)){ void *pClipMemory=GlobalLock(hClipMemory); FXASSERT(pClipMemory); memcpy((void*)data,pClipMemory,size); GlobalUnlock(hClipMemory); CloseClipboard(); FXTRACE((100,"Window %d requested CLIPBOARD DATA of type %d from remote; got %d bytes\n",window->id(),type,size)); } } } } } In the FXRuby world -- Reading the online API documentation (www.fxruby.org), it looks like FXRuby's implementation of FXApp doesn't include the clipboard methods from FOX C++. In the FXRuby distribution, the textedit.rb sample does support Copy and Paste, both to and from the Windows clipboard. So there definitely is some sort of FXText-based (and possibly FXWindow-based) cut/copy/paste clipboard support in the current FXRuby. I'd look into the methods onClipboardRequest, onClipboardGained, and onClipboardLost (and what events they are associated with) to gain further understanding. The methods are referenced in the SWIG wrapper FXText.i and FXWindow.i. Lyle Johnson of FXRuby (a rather amazing effort, by the way) would be the one to talk to about getting the proper methods and other little pieces you need added from the base FOX toolkit into FXRuby. I'm afraid I can't help much as I'm already lost in the jungle of SWIGly code ;-) --ms