FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

listview and a stange beep

 
Post new topic   Reply to topic     Forum Index -> DFL
View previous topic :: View next topic  
Author Message
tsalm



Joined: 18 Feb 2008
Posts: 26
Location: France

PostPosted: Fri Dec 26, 2008 10:23 am    Post subject: listview and a stange beep Reply with quote

Merry christmas everybody.

I've porting the "listviewdirsort" example for using Tango (the code is below)
But when I select a row, my PC's bell beep.
If anyone have a idea of how to shut up it Wink
Thanks in advance.

TSalm


Code:
// To compile:
//    dfl -gui listviewdirsort

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

private import dfl.all;

version(Tango)
     { import tango.io.FilePath , tango.text.convert.Integer , tango.text.convert.Format ;   }
else { import std.conv, std.file; }


class ListViewDirSort: dfl.form.Form
{
   // Do not modify or move this block of variables.
   //~Entice Designer variables begin here.
   dfl.listview.ListView dirlist;
   //~Entice Designer variables end here.
   
   
   this()
   {
      initializeListViewDirSort();
      
      dirlist.sorter = &filenamesorter;
      
      dirlist.columnClick ~= &dirlist_columnClick;
      
      ColumnHeader ch;
      
      ch = new ColumnHeader();
      ch.text = "Name";
      ch.width = 200;
      dirlist.columns.add(ch);
      
      ch = new ColumnHeader();
      ch.text = "Size";
      ch.width = 60;
      dirlist.columns.add(ch);
      
version(Tango)
{
                FilePath(".").toList((FilePath de,bool b)
                                     {
                        char[] s = de.file;
                     if(s.length >= 2 && s[0 .. 2] == ".\\")
               s = s[2 .. s.length];
                    dirlist.addRow(s, itoa(new char[100] , de.fileSize));
                    return true; // Continue.                                       
                                     });
} else {
      toList(".",
         (DirEntry* de)
         {
            char[] s = de.name;
            if(s.length >= 2 && s[0 .. 2] == ".\\")
               s = s[2 .. s.length];
            dirlist.addRow(s, std.string.toString(de.size));
            return true; // Continue.
         });
}
   }
   
   
   private void dirlist_columnClick(ListView sender, ColumnClickEventArgs ea)
   {
      switch(ea.column)
      {
         case 0: // File name.
            dirlist.sorter = &filenamesorter;
            break;
         
         case 1: // File size.
            dirlist.sorter = &filesizesorter;
            break;
         
         default:
            assert(0);
      }
   }
   
   
   private int filenamesorter(ListViewItem a, ListViewItem b)
   {
      return a.opCmp(b);
   }
   
   
   private int filesizesorter(ListViewItem a, ListViewItem b)
   {
      return toInt(a.subItems[0].toString()) - toInt(b.subItems[0].toString());
   }
   
   
   private void initializeListViewDirSort()
   {
      // Do not manually modify this function.
      //~Entice Designer 0.8.2.1 code begins here.
      //~DFL Form
      text = "Current Directory";
      clientSize = dfl.drawing.Size(292, 273);
      //~DFL dfl.listview.ListView=dirlist
      dirlist = new dfl.listview.ListView();
      dirlist.name = "dirlist";
      dirlist.dock = dfl.control.DockStyle.FILL;
      dirlist.view = dfl.base.View.DETAILS;
      dirlist.bounds = Rect(0, 0, 292, 273);
      dirlist.parent = this;
      //~Entice Designer 0.8.2.1 code ends here.
   }
}


int main()
{
   int result = 0;
   
   try
   {
      // Application initialization code here.
      
      Application.run(new ListViewDirSort());
   }
   catch(Object o)
   {
      msgBox(o.toString(), "Fatal Error", MsgBoxButtons.OK, MsgBoxIcon.ERROR);
      
      result = 1;
   }
   
   return result;
}

Back to top
View user's profile Send private message
HeiHon



Joined: 09 Aug 2008
Posts: 10

PostPosted: Sat Dec 27, 2008 10:32 am    Post subject: Re: listview and a stange beep Reply with quote

tsalm wrote:

But when I select a row, my PC's bell beep.


I tried your code and the modified version below with dmd 1.037 / dfl 0.9.8 / tango 0.99.7 r 4150 / dsss 0.78 / Windows Vista SP1 and XP Home SP3 and everything seems to be OK - no strange beeps.

Code:

// To compile:
//    dfl -gui listviewdirsort
// or using dsss e.g.
//  dsss build -release -O -L/exet:nt/su:windows:5.0 listviewdirsort.d

/*
   Generated by Entice Designer
   Entice Designer written by Christopher E. Miller
   www.dprogramming.com/entice.php
*/
module listviewdirsort;

private import dfl.all;

version(Tango)
{
    import tango.io.FilePath;
    import Integer = tango.text.convert.Integer;
}
else
{
    import std.conv, std.file;
}


class ListViewDirSort: dfl.form.Form
{
    // Do not modify or move this block of variables.
    //~Entice Designer variables begin here.
    dfl.listview.ListView dirlist;
    //~Entice Designer variables end here.


    this()
    {
        initializeListViewDirSort();

        dirlist.sorter = &filenamesorter;

        dirlist.columnClick ~= &dirlist_columnClick;

        ColumnHeader ch;

        ch = new ColumnHeader();
        ch.text = "Name";
        ch.width = 200;
        dirlist.columns.add(ch);

        ch = new ColumnHeader();
        ch.text = "Size";
        ch.width = 60;
        ch.textAlign = HorizontalAlignment.RIGHT;
        dirlist.columns.add(ch);

        version(Tango)
        {
            FilePath(".").toList((FilePath de, bool isDir)
                {
                    if(isDir)
                        return true;
                    char[] s = de.file;
                    if(s.length >= 2 && s[0 .. 2] == ".\\")
                        s = s[2 .. s.length];
                    dirlist.addRow(s, Integer.toString(de.fileSize));
                    return true; // Continue.                                       
                }
            );
        }
        else
        {
            toList(".", (DirEntry* de)
                {
                    char[] s = de.name;
                    if(s.length >= 2 && s[0 .. 2] == ".\\")
                        s = s[2 .. s.length];
                    dirlist.addRow(s, std.string.toString(de.size));
                    return true; // Continue.
                }
            );
        }

    }
   
   
    private void dirlist_columnClick(ListView sender, ColumnClickEventArgs ea)
    {
        switch(ea.column)
        {
            case 0: // File name.
            dirlist.sorter = &filenamesorter;
            break;

            case 1: // File size.
            dirlist.sorter = &filesizesorter;
            break;

            default:
            assert(0);
        }
    }
   
   
    private int filenamesorter(ListViewItem a, ListViewItem b)
    {
        return a.opCmp(b);
    }


    private int filesizesorter(ListViewItem a, ListViewItem b)
    {
        return Integer.toInt(a.subItems[0].toString()) - Integer.toInt(b.subItems[0].toString());
    }
   
   
    private void initializeListViewDirSort()
    {
        // Do not manually modify this function.
        //~Entice Designer 0.8.6pre4 code begins here.
        //~DFL Form
        text = "Current Directory";
        clientSize = dfl.all.Size(292, 273);
        //~DFL dfl.listview.ListView=dirlist
        dirlist = new dfl.listview.ListView();
        dirlist.name = "dirlist";
        dirlist.dock = dfl.all.DockStyle.FILL;
        dirlist.fullRowSelect = true;
        dirlist.gridLines = true;
        dirlist.view = dfl.all.View.DETAILS;
        dirlist.bounds = dfl.all.Rect(0, 0, 292, 273);
        dirlist.parent = this;
        //~Entice Designer 0.8.6pre4 code ends here.
    }
}


int main()
{
    int result = 0;

    try
    {
        // Application initialization code here.
        Application.enableVisualStyles();
        Application.run(new ListViewDirSort());
    }
    catch(Object o)
    {
        msgBox(o.toString(), "Fatal Error", MsgBoxButtons.OK, MsgBoxIcon.ERROR);

        result = 1;
    }

    return result;
}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DFL All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group