Click here to Skip to main content
15,886,806 members
Articles / Desktop Programming / WTL
Article

Creating a comfortable ToDo list in Visual C++.

Rate me:
Please Sign up or sign in to vote.
1.30/5 (11 votes)
26 Dec 20023 min read 140.2K   18   7
Using this tutorial you will be able to create a ToDo file wich writes the dates and marks the done tasks. All this using macros.
Terms of Agreement:   
By using this article, you agree to the following terms:
  1. You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for langauges that allow it) freely and with no charge.
  2. You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws. 
  3. You may link to this article from another website, but ONLY if it is not wrapped in a frame.
  4. You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
First of all about the picture.
What you have used to see as Breakpoint, means in this task list a ToDo task. The first date is the date you added the Task to ToDo, the second date is when you finished the task.

Before we start you have to choose your Todo file. Just create an empty text file, in the program I will refer to it as [filename], remember to replace it with your file name. The path to the file will appear as [path] in the tutorial and so you have to replace it as well with your path.
An example to [filename] is: Todo.txt
An example to [path] is: C:\Todo.txt

Lets start with the real thing now.
Go to your macro file (.dsm) and add the following sub to it:
<CODE><FONT color=#000000>
Sub OpenTodoList()
<FONT color=#008000>'DESCRIPTION: Opens the todo.</FONT>
Documents.Open <FONT color=#0000a0>"[path]"</FONT>, <FONT color=#0000a0>"Text"</FONT>
End Sub
Remember to replace the path with the path to your text file just like in the example
</FONT>
</CODE>
When you run it, the macro will open the text file which you will be using as your ToDo file.
If you wish create now a button on the toolbar of "Visual C++" that will run this macro.

Now lets go for the second macro, again go to the macro file and add the following Sub to it:
<CODE><FONT color=#000000>
Sub WriteDate()
<FONT color=#008000>'DESCRIPTION: Writes the date, duh.</FONT>
ShortName=ActiveDocument.Name
If ShortName=<FONT color=#0000a0>"[filename]"</FONT> Then
Line = ActiveDocument.Selection.CurrentLine
Column = ActiveDocument.Selection.CurrentColumn
<FONT color=#008000>'Finding the bottom</FONT>
ActiveDocument.Selection.SelectAll
Bottom = ActiveDocument.Selection.BottomLine
ActiveDocument.Selection.GoToLine Line
<FONT color=#008000>'Find the place for the date</FONT>
Do
ActiveDocument.Selection.LineDown
ActiveDocument.Selection.StartOfLine
ActiveDocument.Selection.CharRight dsExtend
Loop Until ActiveDocument.Selection = <FONT color=#0000a0>"*"</FONT>
ActiveDocument.Selection.LineUp
ActiveDocument.Selection.EndOfLine
ActiveDocument.Selection = <FONT color=#0000a0>" ("</FONT> & CStr(Date) & <FONT color=#0000a0>")"</FONT>
<FONT color=#008000>'Find the place to do the BreakPoint</FONT>
ActiveDocument.Selection.LineDown
Do
ActiveDocument.Selection.LineUp
ActiveDocument.Selection.StartOfLine
ActiveDocument.Selection.CharRight dsExtend
Loop Until ActiveDocument.Selection = <FONT color=#0000a0>"*"</FONT>
ExecuteCommand <FONT color=#0000a0>"DebugToggleBreakpoint"</FONT>
<FONT color=#008000>'Moving back</FONT>
ActiveDocument.Selection.GoToLine Line
ActiveDocument.Selection.CharRight dsMove, Column
Else
ExecuteCommand <FONT color=#0000a0>"DebugToggleBreakpoint"</FONT>
End If
Remember to replace the path with the path to your text file just like in the example
</FONT>
</CODE>
This is the important macro of the program, it will simulate regular Breakpoint for your programs, however, for your ToDo file it will work in a special way.
To continue go to Visual C++ costumize and assign the key F9 to that macro (WriteDate in this tutorial). Now you try to use F9 in your programs and you'll see that it works as usual (just to make sure).
The format of the tasks in the ToDo file has to be in a specific format if you want it to work as planned:
- Every task has to start with the '*' character.
- Tasks can be longer then one line, the '*' character says when a new task begins.
- There should be no space lines between tasks (As on the picture).
- The last line of the macro should be any line that begins with '*'. In my picture it is: "*************** END OF TASKS *************".

After you write your task, mark it as ToDo by having the marker anywhere on the task and pressing F9. The Task will be marked with the Breakpoint mark and the starting date will appear in the end of the task.
When you finish the task move the marker to there and press F9 again. The Breakpoint mark will be removed and the ending date will be added to the end of the task.

TIP: You might want to cause the finished mark to disappear instead.


I hope that you found this tutorial helping and if you did then please vote for it. Thanks.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Israel Israel
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralOh please! Pin
Aoi Karasu 4-May-10 19:42
professional Aoi Karasu 4-May-10 19:42 
Generalgood god! Pin
Bernhard23-Jan-02 3:36
Bernhard23-Jan-02 3:36 
GeneralNo date written Pin
Erich W. Einfalt29-May-01 13:40
Erich W. Einfalt29-May-01 13:40 
GeneralRe: No date written Pin
Vitaly Belman29-May-01 21:01
Vitaly Belman29-May-01 21:01 
GeneralNo dates written at all Pin
Erich W. Einfalt30-May-01 5:59
Erich W. Einfalt30-May-01 5:59 
GeneralRe: No dates written at all Pin
Vitaly Belman30-May-01 6:09
Vitaly Belman30-May-01 6:09 
GeneralFollow up : Requires Active Project Workspace Pin
Erich W. Einfalt30-May-01 6:58
Erich W. Einfalt30-May-01 6:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.