News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Recurring favorites

Started by donkey, January 03, 2010, 11:39:10 PM

Previous topic - Next topic

donkey

I had been playing around lately with writing a favorites manager for myself. It comes from having 4 browsers on my system each with their own favorites list. In the end I decided not to take the route of writing software for it but I thought I would post my concept test as it might be interesting to some.

The biggest feature I guess is the ability to load and save a treeview controls structure and items, I've seen a lot of users ask for this but don't think I've ever seen a satisfactory answer. The demo can save nested folders in a treeview up to 64 levels deep and load them from a file fairly quickly. It makes heavy use of recursive functions to do this, reading an item then recursing down through its children and child folders etc..

Also a good part of the demo is the abilty to move items around in the treeview, I've always hated the favorites managers that forced you to use a different window to sort in. so you can add folders and urls as well as move them and delete them in the single control. I haven't bothered with edit functionality since I gave up on the idea before I got that far, though it is exceedingly simple to add.

Lastly, an interesting line at the start of the app shows how to use the %AppData% type environment strings to specify special folders for your path.

At any rate enjoy the demo, source only in the zip file so you'll need the headers and goasm to assemble it.

If you plan on using it you will have to fix up the heap allocations, during a move the allocations for the old items are not freed, this shouldn't be too much trouble though. I've just kind of lost interest in the demo...

<new upload with a small technical change for the upcoming headers, this will not affect assembly with the current headers - there were 2 downloads>
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

dedndave

good idea Edgar
i had thought about writing something to copy fav's between firefox and ie
also nice would be the ability to save ie favicons in a common place
let me play with your app for a bit...   :bg

donkey

Be my guest Dave,

I made a mistake in my post above, it isn't during a move that the allocations need to be freed but during a delete, during a move they need to remain allocated. You should be able reuse the ClearFavorites procedure for that, maybe without any modification at all. I think I'll be using the code for Help2Viewer though, it can use a favorites tab and it seems wrong to waste all of the work with the recursive functions.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

donkey

I decided that it wasn't fair to leave any of the base work undone and I couldn't sleep so I added the fix for de-allocating memory on a delete, it uses ClearFavorites without any modification. I also added a menu item to edit the label, I don't see a reason to edit the url so I left that out. New upload to the first post in this thread.

Dave,

For your favicons its fairly simple to create an image list with the 16x16 icons and use the extra bytes in the FAVENTRY structure to store an index to the image.

Edgar
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Bill Cravener

Quote from: donkey on January 04, 2010, 10:37:44 AM
I decided that it wasn't fair to leave any of the base work undone and I couldn't sleep. . .

Edgar

Edgar, the older I get the more nights I have were I can't get to sleep. I usually get out of bed down a couple small glasses of good red wine and I'm out in no time. Now I'm not suggesting that you take up drinking like me buddy. :bg
My MASM32 Examples.

"Prejudice does not arise from low intelligence it arises from conservative ideals to which people of low intelligence are drawn." ~ Isaidthat

donkey

Quote from: Bill Cravener on January 04, 2010, 02:15:30 PMEdgar, the older I get the more nights I have were I can't get to sleep. I usually get out of bed down a couple small glasses of good red wine and I'm out in no time. Now I'm not suggesting that you take up drinking like me buddy. :bg

Had a healthy shot of Jamaican rum in a hot toddy and managed a few hours sleep, nothing like alcohol to make the world a better place :)
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Bill Cravener

Quote from: donkey on January 04, 2010, 02:36:39 PM
Had a healthy shot of Jamaican rum in a hot toddy and managed a few hours sleep, nothing like alcohol to make the world a better place :)

Amen brother! :bg
My MASM32 Examples.

"Prejudice does not arise from low intelligence it arises from conservative ideals to which people of low intelligence are drawn." ~ Isaidthat

dedndave

you guys are making me thirsty and it's too early for a beer   :P

Bill Cravener

Well its the afternoon here there is snow everywhere and I'm off work for a couple more weeks so I just may start a bit early. If I start slurring my words let me know and I'll go lay down. :bg
My MASM32 Examples.

"Prejudice does not arise from low intelligence it arises from conservative ideals to which people of low intelligence are drawn." ~ Isaidthat

donkey

Over in another thread I had talked a bit about situations where it might be better to subclass a control and have it perform its functionality outside of the main message loop. The main reason for this is if you want the control to be reusable and don't want to deal with adding a bunch of dependent code to your main loop or global variables to your application. As an experiment I decided to try it with the favorites control. The most difficult part is the dragging of items within the treeview, this is normally handled through a WM_NOTIFY notification and that can't be sloshed off to a subclass. In order to move the dragging routine I had to decide when an item was being dragged and flag a couple of states in order to track and control it. I think I accomplished this pretty well. Global variables are another issue, the control only has one slot (GWL_USERDATA) to use, cbWndExtra is used by Windows for the control so that's verbotten. As a solution I create a small memory buffer and use GWL_USERDATA to store a pointer to it, after that its just an addressing problem. I used labels to substitute for the addressing so things would be a bit clearer. The end result is a control that requires only an initialization, a call to load the favorites file and a call to save it, everything else is handled in the control itself. The source is available in this post.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable