Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

DFL Controls

Part of DflCategory

Description

Shows how to create various controls using the DFL GUI library for Windows.

Example

import dfl.all;


int main()
{
    Form myForm;
    Label myLabel;
    Button myButton, btnExit;
    TextBox myTextBox;
    CheckBox myChkBox;


    void fileExitClick(Object sender, EventArgs ea)
    {
        Application.exitThread();
    }
        
        
    void myButtonClick(Object sender, EventArgs ea)
    {
        MessageBox.show("Congratulations! You clicked the Button.", "My Example Program");
    }
        

    myForm = new Form;
    myForm.text = "DFL Example";
    
    myButton = new Button;
    myButton.text = "Button";
    myButton.size = Size(100, 25);
    myButton.parent = myForm;    
    myButton.click ~= &myButtonClick;

    myTextBox = new TextBox;
    myTextBox.text = "TextBox";
    myTextBox.size = Size(100, 25);
    myTextBox.left = 150;
    myTextBox.parent = myForm;
        
    myLabel = new Label;
    myLabel.text = "Label";
    myLabel.size = Size(100, 14);
    myLabel.top = 50;
    myLabel.parent = myForm;
        
    myChkBox = new CheckBox;
    myChkBox.text = "CheckBox";
    myChkBox.size = Size(100, 20);
    myChkBox.top = 80;
    myChkBox.parent = myForm;

    btnExit = new Button;
    btnExit.text = "Exit";
    btnExit.top = 150;
    btnExit.size = Size(100, 25);
    btnExit.parent = myForm;    
    btnExit.click ~= &fileExitClick;    

    Application.run(myForm);
    
    return 0;
}

Sample Batch File

@echo off
dmd controls.d -L/exet:nt/su:windows:4.0 ..\dfl.lib -I..
controls.exe
pause

Tested Versions

I've tested it with DFL 0.4 and DMD 0.104.

In order to compile this code with more recent DFL versions, you'll need to change "MessageBox.show" to "msgBox".