/* GUIBEGIN WINDOW , 65, 123, 400, 200, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK, , RxClip DRAWCLIPBOARD notification FONT 8, 400, MS Shell Dlg PUSH 1, 4, 69, 22, TABSTOP, , Text1, , Send text 1 PUSH 81, 4, 69, 22, TABSTOP, , Text2, , Send text 2 DEND GUIEND */ /* Demonstrates exchanging data via the clipboard. Run two copies of * this script simultaneously. Click on the button in one window, and * the other script's window reports that. */ /* Register rxclip add-on */ LIBRARY rexxgui, rxclip, rxconsole ClipErr = "SYNTAX" ClipHeading = 1 GuiErr = "SYNTAX" GuiHeading = 1 GuiCreateWindow('NORMAL') /* Put a console window inside our main window, where we'll * display any data copied to the clipboard. */ GuiGetCtlPlacement(, , , "Width", "Height") ConCreate(, GuiWindow, "CHILD", 0, 60, Width, Height - 60) /* Register our own custom format */ myformat = ClipNewFormat('MY_FORMAT') /* See notes below */ DataCopied = 1 /* Let our main window's WM_DRAWCLIPBOARD event handler be * called whenever data is copied to the clipboard. */ WindowHandle = GuiInfo("HANDLE", GuiWindow) NextWindow = ClipInform(WindowHandle) Again: DO FOREVER GuiGetMsg() CATCH SYNTAX CONDITION() SIGNAL Again CATCH HALT FINALLY GuiDestroyWindow() END RETURN /* Called whenever some data is copied to the clipboard */ WM_DRAWCLIPBOARD: DO /* Is this someone else's data? */ IF DataCopied \== 1 THEN DO /* Do we have some data in our custom format? */ IF ClipAvailable(myformat) THEN DO /* Yes. Fetch and display that data */ ClipGet("MyVar.", myformat) DO i = 1 to MyVar.0 SAY MyVar.i END END END FINALLY DataCopied = 0 ClipInformEnd(NextWindow) END RETURN "" /* Called when the "Send Text 1" button clicked */ WM_CLICK_Text1: /* Set a variable we'll check in WM_DRAWCLIPBOARD. We * don't want to be informed when this script has copied * data to the clipboard. We want to know only when another * running copy of this script copies data. So, we'll set * set this variable before we copy data to the clipboard. * In this way, when our WM_DRAWCLIPBOARD event handler is * called, it will know that happened because of our ClipSet below. */ DataCopied = 1 /* Copy "Text 1" to the clipboard in my own custom format */ MyVar.1 = "Text 1" DROP MyVar.2 ClipSet("MyVar.", myformat) RETURN /* Called when the "Send Text 2" button clicked */ WM_CLICK_Text2: DataCopied = 1 MyVar.1 = "Text 2" DROP MyVar.2 ClipSet("MyVar.", myformat) RETURN