Guidance
指路人
g.yi.org
Software / Reginald / Examples / clipexchange.rex

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
/*
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
掌柜推荐
 
 
¥900.00 ·
 
 
¥880.00 ·
 
 
¥497.00 ·
 
 
¥380.00 ·
 
 
¥980.00 ·
 
 
¥1,080.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-06-18 23:34:54