在 Visual C++ 中创建一个舒适的待办事项列表。






1.30/5 (10投票s)
2001年5月29日
3分钟阅读

141551
通过本教程,您将能够创建一个待办事项文件,它可以写入日期并标记已完成的任务。所有这些都使用宏。

协议条款: 通过使用本文,您同意以下条款
| ||
首先,关于图片。 你看到的断点,在这个任务列表中意味着一个待办事项。第一个日期是你将任务添加到待办事项的日期,第二个日期是你完成任务的日期。 在我们开始之前,您必须选择您的待办事项文件。只需创建一个空的文本文件,在程序中我会将其称为[文件名],请记住将其替换为您的文件名。文件的路径将在教程中显示为[路径],您也必须将其替换为您的路径。 [文件名]的一个例子是:Todo.txt [路径]的一个例子是:C:\Todo.txt 现在让我们开始做正事吧。 转到您的宏文件 (.dsm) 并添加以下子程序 <CODE> Sub OpenTodoList() 'DESCRIPTION: Opens the todo. Documents.Open "[path]", "Text" End Sub Remember to replace the path with the path to your text file just like in the example当您运行它时,宏将打开您将用作待办事项文件的文本文件。 如果您愿意,现在可以在“Visual C++”的工具栏上创建一个按钮来运行此宏。 现在让我们进行第二个宏,再次转到宏文件并添加以下子程序 <CODE> Sub WriteDate() 'DESCRIPTION: Writes the date, duh. ShortName=ActiveDocument.Name If ShortName="[filename]" Then Line = ActiveDocument.Selection.CurrentLine Column = ActiveDocument.Selection.CurrentColumn 'Finding the bottom ActiveDocument.Selection.SelectAll Bottom = ActiveDocument.Selection.BottomLine ActiveDocument.Selection.GoToLine Line 'Find the place for the date Do ActiveDocument.Selection.LineDown ActiveDocument.Selection.StartOfLine ActiveDocument.Selection.CharRight dsExtend Loop Until ActiveDocument.Selection = "*" ActiveDocument.Selection.LineUp ActiveDocument.Selection.EndOfLine ActiveDocument.Selection = " (" & CStr(Date) & ")" 'Find the place to do the BreakPoint ActiveDocument.Selection.LineDown Do ActiveDocument.Selection.LineUp ActiveDocument.Selection.StartOfLine ActiveDocument.Selection.CharRight dsExtend Loop Until ActiveDocument.Selection = "*" ExecuteCommand "DebugToggleBreakpoint" 'Moving back ActiveDocument.Selection.GoToLine Line ActiveDocument.Selection.CharRight dsMove, Column Else ExecuteCommand "DebugToggleBreakpoint" End If Remember to replace the path with the path to your text file just like in the example这是程序中重要的宏,它将为您的程序模拟常规断点,但是,对于您的待办事项文件,它将以一种特殊的方式工作。 要继续,请转到 Visual C++ 自定义设置并将键 F9 分配给该宏(在本教程中为 WriteDate)。现在尝试在您的程序中使用 F9,您会发现它像往常一样工作(只是为了确保)。 如果您希望它按计划工作,则待办事项文件中任务的格式必须采用特定格式 - 每个任务必须以“*”字符开头。 - 任务可以超过一行,“*”字符表示新任务的开始。 - 任务之间不应有空格行(如图所示)。 - 宏的最后一行应该是任何以“*”开头的行。在我的图片中是:“*************** 任务结束 *************”。 在您编写完任务后,通过将标记放在任务上的任何位置并按 F9 将其标记为待办事项。该任务将被标记为断点标记,并且开始日期将出现在任务的末尾。 完成任务后,将标记移动到那里并再次按 F9。断点标记将被删除,结束日期将被添加到任务的末尾。 提示:您可能希望使完成标记消失。 我希望您发现本教程很有帮助,如果确实如此,请投票支持它。谢谢。 |