Visual Studio has a great feature to speed entry of frequently typed lines of code called Code Snippets. It works by typing a few chars and pressing tab (C++) or tab-tab (C#). For C# my favorites are 'cw' for adding 'Console.WriteLine' and 'mbox' for adding 'MessageBox.Show'. Visual C++ lacks a similar snippet for adding AfxMessageBox--until now.
To add this as a new snippet, save the XML below as a file with extension *.snippet and open the Visual Studio Snippet manager. (Searching "Code Snippets Manager" from the search box is an easy way to find it.) Then import the snippet under Visual C++/My Code Snippets. Enjoy the increased productivity!
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>AfxMessageBox</Title>
<Author>nzmCoder</Author>
<Description>A pop-up message box.</Description>
<Shortcut>mbox</Shortcut>
</Header>
<Snippet>
<Code Language="CPP">
<![CDATA[AfxMessageBox("$Text$",
MB_ICONINFORMATION, 0);]]>
</Code>
<Declarations>
<Literal>
<ID>Text</ID>
<ToolTip>Your message here.</ToolTip>
<Default>Message Text</Default>
</Literal>
</Declarations>
</Snippet>
</CodeSnippet>
</CodeSnippets>
To add this as a new snippet, save the XML below as a file with extension *.snippet and open the Visual Studio Snippet manager. (Searching "Code Snippets Manager" from the search box is an easy way to find it.) Then import the snippet under Visual C++/My Code Snippets. Enjoy the increased productivity!
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>AfxMessageBox</Title>
<Author>nzmCoder</Author>
<Description>A pop-up message box.</Description>
<Shortcut>mbox</Shortcut>
</Header>
<Snippet>
<Code Language="CPP">
<![CDATA[AfxMessageBox("$Text$",
MB_ICONINFORMATION, 0);]]>
</Code>
<Declarations>
<Literal>
<ID>Text</ID>
<ToolTip>Your message here.</ToolTip>
<Default>Message Text</Default>
</Literal>
</Declarations>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Comments
Post a Comment