剪切板数据类型判断

admin2021-10-28  2.5K+

import win.ui;
/*DSG{{*/
var winform = win.form(text="文本_图片_文件剪辑板例子";right=572;bottom=321)
winform.add(
button3={cls="button";text="判断剪切板数据类型";left=17;top=274;right=140;bottom=306;z=3};
edit={cls="edit";left=294;top=15;right=553;bottom=254;autohscroll=false;edge=1;multiline=1;z=2};
picturebox={cls="picturebox";left=17;top=15;right=258;bottom=254;border=1;z=1}
)
/*}}*/

import win.clip;
import gdip;
import console;

// 剪切板数据类型
global.clipContentType = -1;

winform.button3.oncommand = function(id,event){

	import win.clip.file;
	winform.edit.text = ""
		// 复制文件 复制图片查看器中的图片
		var clipFileList = win.clip.file.read();
		if (#clipFileList > 0) {
			//console.dump(clipFileList)
	    	global.clipContentType = 3;
	    	//winform.msgbox(tostring(global.clipContentType))
	    	winform.edit.dump(clipFileList);
	    	winform.msgbox("剪切板复制的是文件");
	    	return;
		}
	
    	// 复制网页或word中的图片
    	var hBmp = win.clip.readBitmap();
		if (hBmp) {
			global.clipContentType = 2;
			winform.picturebox.setBitmap((hBmp));
	    	::DeleteObject(hBmp);
	    	//winform.msgbox(tostring(global.clipContentType));
	    	//var hBmp = win.clip.readBitmap()
	        
	    	winform.msgbox("剪切板复制的是图片");
	    	return;
		}
    	
    	// 复制文字
		var txt = win.clip.read();
		if (#txt > 0) {
	    	global.clipContentType = 1;
	    	//winform.msgbox(tostring(global.clipContentType))
	    	winform.edit.print(txt);
	    	winform.msgbox("剪切板复制的是文字");
	    	return;
		}
		global.clipContentType = -1;
}

winform.edit.oncommand = function(id,event){
	
}

winform.show();
win.loopMessage();
return winform;
转载请注明原文地址: https://aardio.net/read-254.html
最新回复(0)
aardio问答
aardio编程语言