Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

New Windows control

Hello,

Recently I started ( first it was just for fun ) a quite intereting project. I have always used windows' list view control with the LVS_REPORT style. But I found it not good enough to satisfy my demands. So I wrote my own control from scratch. It look just like the original, works the same, but has some new features. One of them is hiding a column. I cannot count how many times I needed something like that and just couldn't get any help how to do that from the internet. I also provided a standard dialog for editing column's name, align etc. and a dialog for editing items. If anyone is interested in the project or has any suggestions please write to me, I would be very pleased to anwser any e-mails: lican@wp.pl

My control is using RegisterClass with CS_GLOBALCLASS and CS_PARENTDC so once the DLL with the control is loaded any program can use it and the control draws on the parent DC. It uses it's own class for data storing, has all the advantages and non of the drawbacks of a list view control. For testing I override new and delete functions to check if there are no memory leaks and so far it's doing great. For any details contact me :)

Soon the project will be finished... :D

Comments

  • AsmGuru62AsmGuru62 Posts: 6,519Member
    : Hello,
    :
    : Recently I started ( first it was just for fun ) a quite intereting project. I have always used windows' list view control with the LVS_REPORT style. But I found it not good enough to satisfy my demands. So I wrote my own control from scratch. It look just like the original, works the same, but has some new features. One of them is hiding a column. I cannot count how many times I needed something like that and just couldn't get any help how to do that from the internet. I also provided a standard dialog for editing column's name, align etc. and a dialog for editing items. If anyone is interested in the project or has any suggestions please write to me, I would be very pleased to anwser any e-mails: lican@wp.pl
    :
    : My control is using RegisterClass with CS_GLOBALCLASS and CS_PARENTDC so once the DLL with the control is loaded any program can use it and the control draws on the parent DC. It uses it's own class for data storing, has all the advantages and non of the drawbacks of a list view control. For testing I override new and delete functions to check if there are no memory leaks and so far it's doing great. For any details contact me :)
    :
    : Soon the project will be finished... :D
    :
    [blue]Also, my advice is to test it for large item count. I tried the standard list view on about 40,000 items - looks OK, not very slow... but noticeable.[/blue]
  • LicanLican Posts: 4Member
    : [blue]Also, my advice is to test it for large item count. I tried the standard list view on about 40,000 items - looks OK, not very slow... but noticeable.[/blue]

    I've checked that too :) For 100.000 items it was quite fast on P 400Mhz :P And as for drawing that was checked too. Adding items when a column is sorting is much worse, but I'm working on it. Thanks anyway for your advice :)

  • AsmGuru62AsmGuru62 Posts: 6,519Member
    : : [blue]Also, my advice is to test it for large item count. I tried the standard list view on about 40,000 items - looks OK, not very slow... but noticeable.[/blue]
    :
    : I've checked that too :) For 100.000 items it was quite fast on P 400Mhz :P And as for drawing that was checked too. Adding items when a column is sorting is much worse, but I'm working on it. Thanks anyway for your advice :)
    :
    :
    [blue]Make a mode for adding a lot of items, so you do not draw for every item:
    [code]
    MyListView lv;

    lv.BeginFillItems (); // Apply non-drawing mode

    for (int i=0; i<10000; i++) {
    lv.AddItem (...);
    }

    lv.EndFillItems (); // Apply drawing mode back and refresh in full
    [/code]
    I once had interesting experience: replacing strcmp() with my own code gave me almost 4 times speed up in sorting.
    [/blue]
  • LicanLican Posts: 4Member
    : [blue]Make a mode for adding a lot of items, so you do not draw for every item:
    : [code]
    : MyListView lv;
    :
    : lv.BeginFillItems (); // Apply non-drawing mode
    :
    : for (int i=0; i<10000; i++) {
    : lv.AddItem (...);
    : }
    :
    : lv.EndFillItems (); // Apply drawing mode back and refresh in full
    : [/code]
    : I once had interesting experience: replacing strcmp() with my own code gave me almost 4 times speed up in sorting.
    : [/blue]

    Well, if you're adding items beyond the visible lines the control will not redraw its contents. But this idea is great. I'll try to use that too. Thanks :) As for adding a lot of items the list has a message LLM_SETITEMCOUNT which will reserve extra memory.

    I once read an article that took up the subject of comparing strings. From what I know it's best to compare the first letters and if their equal do anything you need to do. E.g. :

    [code]
    int result=str1[0]-str2[0];
    if( result == 0 )
    return CompareStr(...);
    else
    if( result > 0 )
    return FirstGreater;
    else
    return SecodGreater;
    [/code]

    That saves about 33% time because it doesn't have to use "call" instruction. This method would not work for non-ascii letters, for example in my language ( polish :) this is not enough. But I'm still working on it...
  • AsmGuru62AsmGuru62 Posts: 6,519Member
    : : [blue]Make a mode for adding a lot of items, so you do not draw for every item:
    : : [code]
    : : MyListView lv;
    : :
    : : lv.BeginFillItems (); // Apply non-drawing mode
    : :
    : : for (int i=0; i<10000; i++) {
    : : lv.AddItem (...);
    : : }
    : :
    : : lv.EndFillItems (); // Apply drawing mode back and refresh in full
    : : [/code]
    : : I once had interesting experience: replacing strcmp() with my own code gave me almost 4 times speed up in sorting.
    : : [/blue]
    :
    : Well, if you're adding items beyond the visible lines the control will not redraw its contents. But this idea is great. I'll try to use that too. Thanks :) As for adding a lot of items the list has a message LLM_SETITEMCOUNT which will reserve extra memory.
    :
    : I once read an article that took up the subject of comparing strings. From what I know it's best to compare the first letters and if their equal do anything you need to do. E.g. :
    :
    : [code]
    : int result=str1[0]-str2[0];
    : if( result == 0 )
    : return CompareStr(...);
    : else
    : if( result > 0 )
    : return FirstGreater;
    : else
    : return SecodGreater;
    : [/code]
    :
    : That saves about 33% time because it doesn't have to use "call" instruction. This method would not work for non-ascii letters, for example in my language ( polish :) this is not enough. But I'm still working on it...
    :
    [blue]Great stuff![/blue]
  • LicanLican Posts: 4Member
    : [blue]Great stuff![/blue]

    Thanks! And thank you again!! I included the "no draw" function to disable the drawing, and it disables sorting also so that it would not sort after every extra item. I noticed that adding items is faster if they are added at the end if the list ( no memory moving needed ). I also improved inserting items as if the control is sorting, they do not have to be have any fixed position so they are added at the end... I had to double check the drawing functions. And as usual there were some mistakes :) But everything is under control now. The only thing I hate about writing any code is the GUI ;) It's horrible! But I'm disappointed too ( or maybe very happy :) ) that only one person showed some interest in what I'm doing. Maybe the effort will pay off :D Soon I'll make a help file for the control. The only thing left is to put it into the DLL... Interested?
  • AsmGuru62AsmGuru62 Posts: 6,519Member
    : : [blue]Great stuff![/blue]
    :
    : Thanks! And thank you again!! I included the "no draw" function to disable the drawing, and it disables sorting also so that it would not sort after every extra item. I noticed that adding items is faster if they are added at the end if the list ( no memory moving needed ). I also improved inserting items as if the control is sorting, they do not have to be have any fixed position so they are added at the end... I had to double check the drawing functions. And as usual there were some mistakes :) But everything is under control now. The only thing I hate about writing any code is the GUI ;) It's horrible! But I'm disappointed too ( or maybe very happy :) ) that only one person showed some interest in what I'm doing. Maybe the effort will pay off :D Soon I'll make a help file for the control. The only thing left is to put it into the DLL... Interested?
    :
    [blue]It is easy to put it into DLL. Just register the class as global in DllMain() and unregister in the same function - there are different cases for that.

    I have my own ListView written in ASM, so, basically, I am using mine. But I can try yours, just send me that DLL. (asmguru62@hotmail.com)[/blue]
Sign In or Register to comment.