You know how it is - you start work on one project and halfway through, you find one or two side-projects crop up that have to be solved before you can continue on the original project.

This is one such project with the added twist that it too started its life as a side-project. Here's what happened:

<Cue wavy screen effect>

I can only imagine that the planets must have been in (mis-)alignment or something, because at one point a few months ago, I was suddenly fielding emails on four or five separate articles I had previously submitted to CodeProject, some asking for features and others for bug fixes.

Foolishly or otherwise, I largely agreed with all the points raised, and subsequently found myself with fourteen or fifteen separate issues to resolve.

The situation was also made worse because I was trying to use CodeProject to keep track of all the things I had agreed to do, meaning that I had to continuously trawl the comments section of each article to remind myself of what I was supposed to be working on.

It even got to the stage where I was worrying that I'd fail to deliver on something - silly I know, but there you are!

Keeping a list on paper was a definite step in the right direction, but since I do all my coding on the same machine, it seemed somewhat inelegant, and anyway, we all know what happens to crucial bits of paper left lying around on desks and such.

The next step was to hunt around on the web for a tool to meet the following requirements:

Simple interface

Support for hierarchical data

Numbered items/subitems

Open file format

Freeware

Simple, huh! not!

I will admit that I did not spend weeks searching, but I am still surprised at the general lack of software matching my needs.

On reflection, I think that the reason may be simple: people are so used to commercial software being 'feature-rich' that when they come to design software themselves, they (not unreasonably) think they too need to cram as much in as possible, often leading to software where a lot of essential functionality is hidden away in the menu bar.

So, surprise, surprise, I decided to write something myself.

However, it's fair to say that I did not originally intend to post it on CodeProject and am only really doing so because I had a heap of fun solving some very interesting problems and these are what I think make it worth it.

Using the Software

There's really very little I need to say here since every feature/function is explicitly visible in the interface.

Nevertheless, the following list of basic capabilities and omissions may go someway to answering any questions that arise:

Files are stored in XML format with .xml file extension.

Trying to load a non-tasklist file will generally fail (unless you read the code to see how to circumvent it).

The number of items/subitems is limited only by memory (although performance may be the deciding factor before you exhaust memory).

Marking a parent item as 'done' will also gray-out child items, but they are not disabled or automatically marked as 'done'.

An ellipsis (...) indicates that an item has sub-items.

All items can be expanded or collapsed (by double-clicking).

Top-level items and sub-items are created using different toolbar buttons.

There are task-specific context-menus.

The previously open tasklists are re-opened on startup.

The tasklist is automatically saved when closing the software or minimizing it to the system tray.

The priority of a task is shown as a grayscale box to the left of the item.

Points of Interest

Here's where we come to the side-projects I was talking about, the first two of which I intend to work up into follow-up articles.

They are:

The 'ordered' tree control, which incorporates a non-client gutter for displaying the item numbers.

The idea stemmed from research I did into alternative designs for a tree-list control, which did not solve it by creating a hybrid control incorporating a tree and a list.

The hybrid control seems such an obvious solution that I suspect few people have stopped to question it, but it has still always struck me as looking far too much like hard work to be truly elegant ('square pegs' and 'round holes' spring to mind).

One possible idea is to implement the 'list' portion entirely in the non-client area of the tree. I.e., shift the right hand client edge to the left and then render the list portion in the resulting non-client area.

Whilst I've yet to get round to building a proof of concept, it was nevertheless this ongoing mental debate which prompted me to try to solve the requirement for numbered items and subitems by rendering the item/subitem numbers in the non-client area.

Without going into too much detail (as this will subsequently be an article of its own), this is how I got it to work:

Handle TVM_INSERTITEM and TVM_DELETEITEM to know exactly when items are added and removed.

In these handlers recalculate the width of the gutter required to display the widest 'dotted' item/subitem number. (Note: this is not necessarily simply the deepest subitem.)

Handle WM_NCCALCSIZE when it does, and offset the left border by the required gutter width.

Handle WM_NCPAINT for painting the numbers.

This is necessarily an over-simplification, but it captures the essence of the solution, and all that essentially remains is lots of fiddling about to ensure the non-client area gets redrawn at the the right times to stay synchronized with the client area.

Embedding .RC control definition data directly in a .cpp file to break the dependency on binary resources (a.k.a. 'Runtime Dialogs').

This is an idea that has been floating about for quite some time and which has only recently gelled into a workable solution.

The problem, put simply, is that if you want to take advantage of the resource editor in Visual Studio (and who doesn't), then you very quickly find yourself stuck with having to load dialog templates from resources compiled into the binary file.

This further means that if you want to make use of a dialog across multiple projects, then either you need to copy and paste the dialog template between project .RC files, or you need to build the dialog into a DLL from which it can be accessed.

'Runtime Dialogs' (a snappy title I coined myself) is a solution that neatly sidesteps both the nuisance of copying dialog resources between resource files and the extra work (and maintenance) involved in packaging dialogs in DLLs.

And it works like this:

First, you design your dialog template in the resource editor, create a CDialog derived class using class wizard, and wire up all the controls just as you normally would.

Next, you #include "runtimedlg.h" and change all instances of CDialog to CRuntimeDlg.

Then, you cut and paste the control definition section from the appropriate section in the .RC file and embed it directly in the dialog's .cpp file as a static string (with a bit of tweaking to handle double quotes and such like).

Finally, in the constructor of your dialog, you simply call CRuntimeDlg::AddRCControls(...) passing the control definitions as a string.

And CRuntimeDlg takes care of the rest including, if required, auto-sizing the dialog to suit the control layout.

I'm certainly not suggesting that this is a 'win-win' solution for all situations but it certainly has merits in its closer coupling of dialog template to dialog code which makes sharing dialogs across multiple projects a breeze.

P.S.: In case it's not clear here, I used CRuntimeDlg to create CToDoCtrl which encapsulates the ordered tree together with the priority, date and comments controls as a single simple-to-instantiate control.

This is possibly the most satisfying aspect of the whole project because it was completely unexpected.

What I mean is that, until recently, my knowledge of DOM and XMLDOM was virtually non-existent, as it's only since I've become more interested in the presentation of AbstractSpoon that I've been forced to get to grips with the various implementations of DOM and XMLDOM out there.

I'm pleased to say that the code on my site works under IE 6.0, Netscape 7.1, and Mozilla, although custom code was required to achieve this.

Generic MFC Classes that may prove Useful to You

The following table lists a wide range of utility classes written for this project. They can all be included in any MFC project provided you include any class dependencies too. Feel free to ask any questions relating to these specific classes and how to use them.

Adds support for recognizing urls, clicking them and setting custom url callbacks

CWinClasses

Encapsulates the ::GetClassName Win32 functions

CXmlFile, CXmlItem

Non-Unicode class for reading and writing xml files

CXmlFileEx

Adds encryption capabilities to CXmlFile

CXmlFile, IEncryption

* CSubclassWnd was originally written by Paul DiLascia for MSJ magazine. The version I use has been heavily extended to suit my specific needs. The classes that depend on it here need this extended version.

Further Work

Whilst this tool was originally intended for my personal use only, it is now a 'community' project, so if you find it useful and want to make suggestions for enhancements or bug fixes, then post below.

History

7.1.3 (20 May 2017)

Fixed positioning of recreated recurring tasks when filter is active

Fixed inconsistent visibility of tasklist tab bar scroll buttons

Replaced new line characters with spaces when rendering 'inline comments'

Doesn't seem to be this way. This was my intention, to save (without noticing the check in state) but once I tried to check out, I got the message that the tasklist was being used by another app. And from that on, a pop-up every 2 seconds lets me know the tasklist has been checked out (but it's not the case).
So I can't say I've seen the save button active while the tasklist is checked in. The problem seems to be related solely to the check-out action.

BTW, on the same topic - source control - another thing that happened to me once was that I left my task list unattended and automatic check-in occurred. During that time the app crashed (or the whole system, can't remember) and there was no saving of my work.
I haven't tested this, but I wonder if auto-save works even if the tasklist is in a check-in state.

I have set things up so the app backs up to another location... but ideally I'd like to keep the "live" TDL file somewhere other than where the functional app files are kept.

I appreciate this is a smallish volume of files, some 8MB currently on my machine. But it'd just be nicer to keep the data separate from the app. Also I'm not sure how much this footprint might grow if one day I manage to understand some of the more advanced features (plugins, etc).

Or perhaps there's a way to make sure that every change to the "live" TDL file results in a backup. I just checked with my latest backed up TDL file and it doesn't contain the latest modification I made to the comments field for a task...

You can store any .tdl file anywhere. I have them all over my system for different reasons, and I'm using three versions of the app on the same system. (Yeah, overkill, I need to trim down.)

From menu>Tools>Preferences,File Actions (more) : you can set where backups are kept and how many are saved. I have mine set for 100 recent backups. (Yeah, more overkill, but I save a lot so I think I cycle through that quickly.)

You'll see from that preference page that you can save backups in a specific folder, a folder relative to each .tdl file, or a file relative to the app.

Note other settings for how often the auto-save kicks in. If you check those settings and you really think something is up with the backup, please report the issue here or in the Google Group, and provide the version# that you're using, specific details of what you're doing, and of the preferences.

Or perhaps there's a way to make sure that every change to the "live" TDL file results in a backup

In addition to what iamstarbuck said, I'll reiterate that backups are only created during a save operation. So if you want to minimise risks of data loss then set your Auto-Save settings to 1 minute. Bearing in mind that for the time it takes to save your tasklist you are prevented from working on the tasklist.

Yes, I have Auto-save set to every 1 minute. The slight niggle, then, is that after making a change you have to keep the app open for (up to) a minute before you can be sure the change has been backed up in your designated data location.

In an ideal world I'd like to be able to configure where the "Resources" directory is kept and/or where the "Tasklists" directory is kept.

The Calculated Due Date is for when you use Preferences to calculate due dates based on various criteria. For example, a Calculated Due Date for a Parent task can be the last date of all sub-task due dates.

See menu > Tools > Preferences > Tasks > Attribute Calculations, especially "Display a task's Due Date as ...". You'll see here that you can toggle between an assigned Due Date, and a Calculated Due Date.

This topic has come up before. This is just a comment - Dan makes his own decisions about what he does with his software.

There are different XML schemas for MM and MMAP data. That complicates a generic import/export mechanism.

There is now a published plugin mechanism for TDL[^] which allows third-parties to create import/exports - it was added Exactly for requests like this. A developer can create this, perhaps you or one of your friends, or if you want this for business purposes you might offer something for someone to create software which serves to improve your own profitability.

ToDoList uses a simple locking mechanism (check out) to allow one person edit-access to the tasklist. When that person has finished editing they release the lock (check in) to allow others to edit the file.

I've been testing and experimenting with the "recurrent task" thing. I just don't understand how you use this feature.

Say I've set some task up as a daily task: "Daily", "Every 1 day"...

Calculate next occurrence: "from due date"...

When I complete this task: either "Create new..." or "Reuse"...

As I understand it, nothing at all will happen unless you initially set the "Due date". So I set it to tomorrow on day D.

Next day (D+1) the task is shown with a red font.

My question is: what am I then meant to do so that it goes back to "black font" on D+1 ... but will then show red again on D+2? (A: with "Create new..." and B: with "Reuse"...).

What is the function of the tick box to the left? Checking this seems to draw a strikethrough and "grey-out" the font: ticking means "task completed", right? So if your setting is "Reuse" what are you meant to do? Tick or not tick?

"Show red.." depends on the settings "Pref - User Interface - Fonts and Colours - Due task colour / due today colour". Take a look there and you will understand the behaviour (and the ways to customize it).

"Tick it" usually says "task complete / strike strough / grey / .."
But a recurrent task behaves depending on "Create new..." or "Reuse"...
- "Create new" lets the original task as "completed", but creates a clone of it with new ID and new calculated due-day.
- "Reuse" sets the just completed task to "uncompleted, but new the next recurrence"

It depends on the importance and the required retrace-ability of the task which option is better for you.