`
betty_betty2008
  • 浏览: 24703 次
  • 性别: Icon_minigender_1
  • 来自: 东莞
最近访客 更多访客>>
社区版块
存档分类
最新评论

截屏、闪屏(Timer)、输入窗口--DFL for D2.053

    博客分类:
  • D
阅读更多
这个小练习用D2.053+DFL完成了以下功能:
1.截屏(Chris的例子);
2.用截屏做闪屏,Timer(用Chris的例子);
3.数据库登陆窗口(数据库连接部分暂没做);
4.输入窗口模块module inputbox,从窗口输入中获得一个字符串和一个整数可以这样:
string input=inputBox.getString("用户自定义提示","用户自定义默认值");
int anInt=inputBox.getInt("","");

省略参数则使用默认参数值。
对类型转换未进行错误检查。
5.菜单的创建(Chris的例子)
6.Chris的MemoryGraphic例子收录(只是试了一下);


主程序:
passwordform.d
/*
	Generated by Entice Designer
	Entice Designer written by Christopher E. Miller
	www.dprogramming.com/entice.php
*/

import dfl.all;

import dfl.internal.winapi;
import std.string;
import std.c.string;
import std.conv;
import std.stdio;

import inputbox;
import splashform;

//extern(Windows) BOOL FindWindowEx
class PasswordForm: dfl.form.Form
{
	// Do not modify or move this block of variables.
	//~Entice Designer variables begin here.
	dfl.label.Label label1;
	dfl.textbox.TextBox textBox1;
	dfl.label.Label label2;
	dfl.textbox.TextBox textBox2;
	dfl.button.Button btnOK;
	dfl.button.Button btnCancel;
	dfl.button.Button btnGetInput;
	//~Entice Designer variables end here.
	
	
	this()
	{
		initializePasswordForm();
		
		//@  Other PasswordForm initialization code here.
		
	}
	
	
	private void initializePasswordForm()
	{
		// Do not manually modify this function.
		//~Entice Designer 0.8.5.02 code begins here.
		//~DFL Form
		formBorderStyle = dfl.all.FormBorderStyle.FIXED_SINGLE;
		startPosition = dfl.all.FormStartPosition.CENTER_SCREEN;
		text = "Password Form";
		clientSize = dfl.all.Size(314, 188);
		//~DFL dfl.label.Label=label1
		label1 = new dfl.label.Label();
		label1.name = "label1";
		label1.text = "用户名:";
		label1.bounds = dfl.all.Rect(16, 48, 56, 16);
		label1.parent = this;
		//~DFL dfl.textbox.TextBox=textBox1
		textBox1 = new dfl.textbox.TextBox();
		textBox1.name = "textBox1";
		textBox1.bounds = dfl.all.Rect(88, 40, 144, 24);
		textBox1.parent = this;
		//~DFL dfl.label.Label=label2
		label2 = new dfl.label.Label();
		label2.name = "label2";
		label2.text = "密码:";
		label2.bounds = dfl.all.Rect(16, 88, 64, 16);
		label2.parent = this;
		//~DFL dfl.textbox.TextBox=textBox2
		textBox2 = new dfl.textbox.TextBox();
		textBox2.name = "textBox2";
		textBox2.bounds = dfl.all.Rect(88, 80, 144, 24);
		textBox2.parent = this;
		//~DFL dfl.button.Button=btnOK
		btnOK = new dfl.button.Button();
		btnOK.name = "btnOK";
		btnOK.text = "(&O)登陆";
		btnOK.bounds = dfl.all.Rect(56, 120, 88, 24);
		btnOK.parent = this;
		//~DFL dfl.button.Button=btnCancel
		btnCancel = new dfl.button.Button();
		btnCancel.name = "btnCancel";
		btnCancel.text = "(&C)取消";
		btnCancel.bounds = dfl.all.Rect(176, 120, 88, 24);
		btnCancel.parent = this;
		//~DFL dfl.button.Button=btnGetInput
		btnGetInput = new Button;
		btnGetInput.name = "btnGetInput";
		btnGetInput.text = "...";
		btnGetInput.bounds = dfl.all.Rect(248, 40, 40, 24);
		btnGetInput.parent = this;
		//~Entice Designer 0.8.5.02 code ends here.
		this.acceptButton=btnOK;
		this.cancelButton=btnCancel;
		
		btnCancel.click~=&onCancel;
		btnOK.click~=&onOK;
		
		
		//textBox2.passwordChar='*';
		this.centerToParent;
		
		auto menu=new MainMenu;
		this.menu=menu;
		
		auto currentMenu=new MenuItem("(&F)文件");
		menu.menuItems.add(currentMenu);
		
		auto currentItem=new MenuItem("(&N)新建");
		currentMenu.menuItems.add(currentItem);
		
		currentItem=new MenuItem("Recent");
		currentMenu.menuItems.add(currentItem);
		
		currentMenu=currentItem;
		
		currentItem=new MenuItem("File");
		currentMenu.menuItems.add(currentItem);
		
		currentItem=new MenuItem("Project");
		currentMenu.menuItems.add(currentItem);
		
		currentMenu=cast(MenuItem)currentMenu.parent;
		
		currentItem=new MenuItem;
		currentItem.barBreak=true;
		currentMenu.menuItems.add(currentItem);
		
		currentItem=new MenuItem("E&xit");
		currentMenu.menuItems.add(currentItem);
		
		currentItem=new MenuItem("Side Option");
		currentItem.breakItem=true;
		currentItem.checked=true;
		currentMenu.menuItems.add(currentItem);
		
		btnGetInput.click~=&getInputClick;
		this.acceptButton=btnOK;
		this.cancelButton=btnCancel;
		
	}
	protected void getInputClick(Object sender,EventArgs e)
	{
		string text1Value=textBox1.text;
		string text2Value=textBox2.text;
		
		string income=inputBox.getString;
		
		textBox1.text=(income.length>0)?income:text1Value;
		
		
		
		int temp=inputBox.getInt;
		if(temp!=int.min)
			textBox2.text=to!string(temp);
		else
			textBox2.text=text2Value;
		
	}
	protected void onCancel(Object sender,EventArgs e)
	{
		
		close;
	}
	protected void onOK(Object sender,EventArgs e)
	{
		close;
	}
	
}


class GraphTest: Form
{

    
    this()
    {
        text = "MemoryGraphics";        
                
        Panel panGraphic = new MemDrawer(2000,2000);
        panGraphic.backColor = Color(0,0,0);
        
        panGraphic.dock( DockStyle.FILL );
        this.controls.add(panGraphic);
    }
}

class MemDrawer:Panel
{
    private MemoryGraphics memGraph;
    
    this(int w,int h)
    {        
        memGraph = new MemoryGraphics(w,h);
        
        ubyte r = 0 ;
        for (int i=0;i<w;i++)
        {
            r += 10;
            if (r>255) r=0;
            memGraph.drawLine(new Pen(Color(r,255,255)), i,0,i,h);
        }
    }
    
    protected override void onPaint(PaintEventArgs ea)
    {
        memGraph.copyTo(createGraphics,0,0,memGraph.width,memGraph.height);
    }
}


 
class MyForm : Form {
    Button btn;
    SimplePictureBox pb;
    
    this() {
        initializeMyForm();
    }
    private void initializeMyForm() {
        text = "My Form";
        clientSize = Size(292, 273);

        btn = new Button();
        btn.parent(this);
        btn.text("Click ME");
        btn.dock(DockStyle.TOP);
        btn.click ~= &btn_click;
        
        pb = new SimplePictureBox();
        pb.parent(this);
        pb.sizeMode=PictureBoxSizeMode.STRETCH_IMAGE;
        pb.dock(DockStyle.FILL);
        
    }
    private void btn_click(Control sender, EventArgs ea) {
        HWND hWnd = FindWindowExA(cast(HWND)0, cast(HWND)0, null, toStringz("0")); //or 0 for desktop...
        //writefln("HWND = %d", hWnd);
        Graphics g = MemoryGraphics.fromHwnd(hWnd);
        MemoryGraphics mg = new MemoryGraphics(1280,1024);
        g.copyTo(mg, 0,0,1280,1024);
        Bitmap bmp = mg.toBitmap(mg);
        pb.image(bmp);
    }


}



int main()
{
	int result = 0;
	
	try
	{
		Application.enableVisualStyles();
		
		//@  Other application initialization code here.
		
		
		SplashForm splash=new SplashForm;
		Application.run(splash);
		
		
		
		Application.run(new PasswordForm);
		
	}
	catch(Exception o)
	{
		msgBox(o.toString(), "Fatal Error", MsgBoxButtons.OK, MsgBoxIcon.ERROR);
		
		result = 1;
	}
	
	return result;
}


inputbox.d
/*
	Generated by Entice Designer
	Entice Designer written by Christopher E. Miller
	www.dprogramming.com/entice.php
*/

import dfl.all;
import std.string;
import std.conv;


class InputBox: dfl.form.Form
{
	// Do not modify or move this block of variables.
	//~Entice Designer variables begin here.
	dfl.label.Label promptLabel;
	dfl.textbox.TextBox txtInput;
	dfl.button.Button btnOK;
	dfl.button.Button btnCancel;
	//~Entice Designer variables end here.
	
	private string value;
	int dlgResult;
	this()
	{
		initializeInputBox();
		
		//@  Other InputBox initialization code here.
		
		
		
	}
	
		
	
	private void initializeInputBox()
	{
		// Do not manually modify this function.
		//~Entice Designer 0.8.5.02 code begins here.
		//~DFL Form
		formBorderStyle = dfl.all.FormBorderStyle.FIXED_SINGLE;
		startPosition = dfl.all.FormStartPosition.CENTER_PARENT;
		text = "Input Box";
		clientSize = dfl.all.Size(322, 164);
		//~DFL dfl.label.Label=promptLabel
		promptLabel = new dfl.label.Label();
		promptLabel.name = "promptLabel";
		promptLabel.font = new dfl.all.Font("Microsoft Sans Serif", 16f, cast(dfl.all.FontStyle)(dfl.all.FontStyle.BOLD | dfl.all.FontStyle.ITALIC));
		promptLabel.foreColor = dfl.all.Color(0, 0, 255);
		promptLabel.text = "请输入一个整数:";
		promptLabel.bounds = dfl.all.Rect(24, 16, 272, 32);
		promptLabel.parent = this;
		//~DFL dfl.textbox.TextBox=txtInput
		txtInput = new dfl.textbox.TextBox();
		txtInput.name = "txtInput";
		txtInput.text = "0";
		txtInput.bounds = dfl.all.Rect(24, 64, 200, 24);
		txtInput.parent = this;
		//~DFL dfl.button.Button=btnOK
		btnOK = new dfl.button.Button();
		btnOK.name = "btnOK";
		btnOK.text = "(&O)确定";
		btnOK.bounds = dfl.all.Rect(24, 120, 96, 24);
		btnOK.parent = this;
		//~DFL dfl.button.Button=btnCancel
		btnCancel = new dfl.button.Button();
		btnCancel.name = "btnCancel";
		btnCancel.text = "(&C)取消";
		btnCancel.bounds = dfl.all.Rect(216, 120, 88, 24);
		btnCancel.parent = this;
		//~Entice Designer 0.8.5.02 code ends here.
		
		this.acceptButton=btnOK;
		this.cancelButton=btnCancel;
		
		txtInput.focus;
		
		btnOK.click~=&okClick;
		btnCancel.click~=&cancelClick;
	}
	protected void okClick(Object sender,EventArgs e)
	{
		dlgResult=1;
		close;
	}
	protected void cancelClick(Object sender,EventArgs e)
	{
		dlgResult=0;
		close;
	}
	
	//actually method getInt is not so useful to somebody who thinks need to handle carefully with  Cancel button 
	//hit as the result is int.min other than 0 or -1 or the like.
	public int getInt(string defaultPrompt="Please enter an integer:",string defaultValue="-999")
	{
		
		promptLabel.text=defaultPrompt;
		txtInput.text=defaultValue;
		//if(this.showDialog()!= DialogResult.CANCEL)
		this.showDialog();
		if(dlgResult==1)
		{
			value=txtInput.text;
			return to!int(value.length?value:"0");
			
		}
		else if(dlgResult==0)
		{
			
			return int.min;
		}
		assert(0);
	}
	
	
	
	public string getString(string defaultPrompt="Please enter a string:",
				string defaultValue="string here")
	{
		
		promptLabel.text=defaultPrompt;
		txtInput.text=defaultValue;
		//Using DialogResult.CANCEL does not work on hit Cancel button first and try a second time later to hit OK.
		//if(this.showDialog()!= DialogResult.CANCEL)
		this.showDialog();
		if(dlgResult==1)
		{
			value=txtInput.text;
			return value;
		}
		else if(dlgResult==0)
		{
			return null;
		}
		
		assert(0);
	}
	
	
	
	
}
public:
static InputBox inputBox;
static this()
{
	
	inputBox=new InputBox;
}
static ~this()
{
	if(inputBox !is null)
		inputBox.dispose;
}


splashform.d
/*
	Generated by Entice Designer
	Entice Designer written by Christopher E. Miller
	www.dprogramming.com/entice.php
*/

import dfl.all;
import dfl.internal.winapi;
import std.c.string;
import std.conv;
import std.string;

class SimplePictureBox: PictureBox
{
        protected override void onPaintBackground(PaintEventArgs ea)
        {
        }


        protected override void createParams(ref CreateParams cp)
        {
                super.createParams(cp);
                //cp.exStyle |= WS_EX_TRANSPARENT;
        }
}

class SplashForm: dfl.form.Form
{
	// Do not modify or move this block of variables.
	//~Entice Designer variables begin here.
	SimplePictureBox pictureBox1;
	//~Entice Designer variables end here.
	
	Timer timer;
	this()
	{
		initializeSplashForm();
		
		//@  Other SplashForm initialization code here.
		startTimer;
	}
	
	protected void startTimer()
	{
		timer=new Timer;
		timer.interval=3000;
		timer.tick~=&ticks;
		timer.start;
		
	}
	protected void ticks(Timer sender,EventArgs e)
	{
		this.close;
	}
	private void initializeSplashForm()
	{
		// Do not manually modify this function.
		//~Entice Designer 0.8.5.02 code begins here.
		//~DFL Form
		formBorderStyle = dfl.all.FormBorderStyle.NONE;
		startPosition = dfl.all.FormStartPosition.CENTER_PARENT;
		text = "Splash Form";
		clientSize = dfl.all.Size(304, 192);
		//~DFL SimplePictureBox:dfl.picturebox.PictureBox=pictureBox1
		pictureBox1 = new SimplePictureBox();
		pictureBox1.name = "pictureBox1";
		pictureBox1.dock = dfl.all.DockStyle.FILL;
		pictureBox1.bounds = dfl.all.Rect(0, 0, 304, 192);
		pictureBox1.parent = this;
		//~Entice Designer 0.8.5.02 code ends here.
		pictureBox1.sizeMode=PictureBoxSizeMode.STRETCH_IMAGE;
		
		//this.onLoad~=&onLoad;
	}
	protected override void onLoad(EventArgs ea)
	{
		super.onLoad(ea);
		HWND hWnd = FindWindowExA(cast(HWND)0, cast(HWND)0, null, toStringz("0")); //or 0 for desktop...
        //writefln("HWND = %d", hWnd);
        Graphics g = MemoryGraphics.fromHwnd(hWnd);
        MemoryGraphics mg = new MemoryGraphics(1280,1024);
        g.copyTo(mg, 0,0,1280,1024);
        Bitmap bmp = mg.toBitmap(mg);
        pictureBox1.image(bmp);
	}
}
分享到:
评论

相关推荐

    腾讯&明略科技-轻互动闪屏广告价值白皮书-2020.7-41页.pdf

    《腾讯&明略科技-轻互动闪屏广告价值白皮书》是2020年7月发布的一份深入探讨轻互动闪屏广告效果的重要文献,共计41页。这份白皮书主要聚焦于现代数字营销领域,特别是移动互联网广告的新趋势——轻互动闪屏广告。...

    腾讯&明略科技-轻互动闪屏广告价值白皮书-2020.7-41页2020精品报告.pdf

    - 介绍轻互动闪屏广告的概念,它是一种新型的广告形式,通常出现在移动应用的启动时,利用短暂的时间窗口展现品牌信息。 - 特点可能包括视觉冲击力强、用户参与度较高、广告效果易于追踪等特点。 2. 广告市场的...

    openssl win64 .exe 安装使用

    2. 运行下载的`.exe`文件,按照安装向导的提示进行操作。通常,你可以选择默认的安装路径,但也可以根据需要自定义。 3. 在安装过程中,会有一步让你选择安装类型。"Static"模式会将所有需要的库静态链接到你的应用...

    安卓天气日历时间选择倒计时相关-有倒计时的闪屏Demo.rar

    在安卓平台上,开发一款带有天气、日历以及时间选择功能并结合倒计时的闪屏应用,是一项常见的任务。这个名为“有倒计时的闪屏Demo.rar”的压缩包文件,提供了一个示例项目,帮助开发者理解如何实现这类功能。由于...

    【循序渐进学.java】从入门到精通.第76讲-满汉楼系统3.实现闪屏.登录.zip

    绝对韩顺平老师的讲解视频!教学文件打包太大,就一个一个的上传了! avi格式的,最好用KMPlayer来播放,下载地址:https://www.kmplayer.com/home 后续还上传,韩顺平老师教学的源代码!

    Android 闪屏加退出提示应用-IT计算机-毕业设计.zip

    在Android应用开发中,"闪屏页"(Splash Screen)和"退出提示"是常见的功能设计,对于提高用户体验和品牌形象有着重要作用。这份"Android 闪屏加退出提示应用"的毕业设计项目,提供了完整的源码,是学习Android编程...

    动画闪屏---启动图片区分中英文环境DEMO

    2. **启动图片**:启动图片是动画闪屏的一种形式,通常是静态的图像,用于在应用程序准备就绪之前填充屏幕。在区分中英文环境的DEMO中,启动图片可能需要根据用户设备的语言设置来选择不同的设计。 3. **国际化...

    安卓开发-闪屏加退出提示应用.zip.zip

    在安卓应用开发中,"闪屏页"(Splash Screen)和"退出提示"是两个常见的功能,它们分别用于提升用户体验和告知用户即将退出应用。闪屏页通常在应用启动时展示,显示品牌信息或者加载应用的主要资源,而退出提示则在...

    VC 窗口闪屏源码.rar

    VC 窗口闪屏源码,闪的时候抓 不到图片,所以大家看不到效果,闪屏相信大多数人都知道吧,这里也就不介绍了,本例源码是修改版,原型来自李建湘的《闪屏图形特技效果的实现》一文中的例子,属于比较简单的那种,高手...

    2-3信息流实验分析实践.pdf

    例如,调整闪屏广告的出现时机,是为了优化用户体验和增加人均活跃天数。但在实际操作中,可能会遇到实验人群与真实策略触达人群的不一致,导致实验效果被稀释。这时,我们需要采用如ITT(意向治疗分析)和CACE...

    PubWinNoAD

    2.修正Win7 下替换锁屏图会闪屏得比较历害 3.修正PubWin 2009 12,13下无法正在闭开机默认广告框 4.预防个别系统环境下去除广告后Pubwin仍死恢复燃的情况 5.修正个别情况报核心组件拦截的情况 6.修正PubWin 2009 12,...

    emesene_1.5-1~getdeb1_all.deb

    Emesene的linux下的msn版本,它使用了较新的MSN协议,因此支持离线消息、闪屏和个性签名

    Android应用源码之闪屏加退出提示应用-IT计算机-毕业设计.zip

    在Android应用开发中,"闪屏页"(Splash Screen)和"退出提示"是常见的功能模块,对于初学者和毕业设计来说,理解并实现这些功能是提升技能的关键步骤。本项目是一个Android应用源码示例,它展示了如何将这两部分...

    课程设计-基于Android studio的购物车app.zip

    启动应用后,用户将首先看到一个闪屏界面,3秒后,系统会检查用户是否已登录。新用户可以通过注册功能轻松创建账户。登录后,用户可以在主界面上对购物车进行各种操作,如增加商品、删除商品、修改商品和查询商品,...

    小新Pro-13AMD屏闪修复工具.exe

    联想小新pro13 amd 版 闪屏修复工具

    藏经阁-UC如何构建国际共赢生态.pdf

    随着时间的推移,UC浏览器的月活跃用户已超过2亿,特别是在印度市场,UCWeb已经成为当地第一的移动浏览器,拥有4亿2千万的月活用户。此外,UCNews在印度的发布标志着其从单纯的工具型应用向内容平台的转型,旨在为...

    Android代码-闪屏加退出提示应用.zip

    在Android开发中,"闪屏加退出提示应用"是一个常见的功能需求,主要用于提升用户体验和增加品牌识别度。闪屏页(Splash Screen)通常在应用程序启动时首先显示,展示品牌形象或者加载必要的数据,而退出提示则在用户...

    闪屏窗口源代码闪屏窗口源代码

    闪屏窗口,通常在应用程序启动时出现,是用户打开软件时首先看到的界面,它能够展示品牌形象、加载信息或者提供一些简单的交互。本资源包含的是关于创建和实现闪屏窗口的源代码,对于想要深入了解或自定义闪屏窗口...

Global site tag (gtag.js) - Google Analytics