欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

在DFL中如何做一个对话框呢? 博客分类: D语言

程序员文章站 2024-02-22 19:14:52
...
原本以为做个对话框应该很简单,但是好像并不简单,以下是代码,编译没有问题,就是不能弹出对话框,看来java程序在我的脑子中根深蒂固了,在DFL上这样的模式估计不行。

需求很简单,就是一个弹出对话框,上面有几个文本框,可以输入一些数据。


module dfl.AgendaDialog;

import dfl.all;

class AgendaDialog: CommonDialog
{
    Panel panelAgenda;
    Label labelAgenda;
    Label labelDate;
    Label labelTimeFrom;

    TextBox textBoxDate;
    TextBox textBoxTimeFrom;
    TextBox textBoxTimeTo;

    RichTextBox richTextBoxAgenda;

    this()
    {
        //Application.ppin(cast(void*)this);//有这句话编译都过不去
        initializeMyPanel();
    }

    public override void reset()
    {
    }

    public override DialogResult showDialog()
    {
        msgBox("befor show dialog, no para! ", "Info", MsgBoxButtons.OK, MsgBoxIcon.INFORMATION);

        return runDialog(GetActiveWindow()) ? DialogResult.OK : DialogResult.CANCEL;
    }

    public override DialogResult showDialog(IWindow owner)
    {
        msgBox("befor show dialog, has para IWindow!", "Info", MsgBoxButtons.OK, MsgBoxIcon.INFORMATION);

        return runDialog(owner ? owner.handle : GetActiveWindow()) ? DialogResult.OK : DialogResult.CANCEL;
    }

    public override bool runDialog(HWND owner)
    {
        return true;
    }

    private void initializeMyPanel()
    {
        panelAgenda = new Panel();
        panelAgenda.name = "MyPanel";
        panelAgenda.bounds = dfl.all.Rect(0, 0, 376, 248);

        labelDate = new Label();
        labelDate.name = "labelDate";
        labelDate.text = "日期";
        labelDate.textAlign = dfl.all.ContentAlignment.MIDDLE_RIGHT;
        labelDate.bounds = dfl.all.Rect(8, 16, 44, 23);
        labelDate.parent = panelAgenda;

        textBoxDate = new TextBox();
        textBoxDate.name = "textBoxDate";
        textBoxDate.text = "textBoxDate";
        textBoxDate.bounds = dfl.all.Rect(64, 16, 296, 23);
        textBoxDate.parent = panelAgenda;

        textBoxTimeFrom = new TextBox();
        textBoxTimeFrom.name = "textBoxTimeFrom";
        textBoxTimeFrom.text = "textBoxTimeFrom";
        textBoxTimeFrom.bounds = dfl.all.Rect(64, 56, 120, 23);
        textBoxTimeFrom.parent = panelAgenda;

        labelTimeFrom = new Label();
        labelTimeFrom.name = "labelTimeFrom";
        labelTimeFrom.text = "时间";
        labelTimeFrom.textAlign = dfl.all.ContentAlignment.MIDDLE_RIGHT;
        labelTimeFrom.bounds = dfl.all.Rect(8, 56, 44, 23);
        labelTimeFrom.parent = panelAgenda;

        textBoxTimeTo = new TextBox();
        textBoxTimeTo.name = "textBoxTimeTo";
        textBoxTimeTo.text = "textBoxTimeTo";
        textBoxTimeTo.bounds = dfl.all.Rect(240, 56, 120, 23);
        textBoxTimeTo.parent = panelAgenda;

        labelAgenda = new Label();
        labelAgenda.name = "labelAgenda";
        labelAgenda.text = "事件";
        labelAgenda.textAlign = dfl.all.ContentAlignment.MIDDLE_RIGHT;
        labelAgenda.bounds = dfl.all.Rect(8, 96, 44, 23);
        labelAgenda.parent = panelAgenda;

        richTextBoxAgenda = new RichTextBox();
        richTextBoxAgenda.name = "richTextBoxAgenda";
        richTextBoxAgenda.scrollBars = dfl.all.RichTextBoxScrollBars.VERTICAL;
        richTextBoxAgenda.bounds = dfl.all.Rect(64, 96, 296, 144);
        richTextBoxAgenda.parent = panelAgenda;
    }
}