Friday, June 27, 2008

Locate current opened file in solution explorer

To locate current opened file in solution explorer you can use this macro:


Sub LocateInSolutionExplorer()
DTE.ExecuteCommand("View.TrackActivityinSolutionExplorer")
DTE.ExecuteCommand("View.TrackActivityinSolutionExplorer")
End Sub

Tuesday, June 24, 2008

Convert std::string to std::wstring

// std::string -> std::wstring
std::string s("string");
std::wstring ws;
ws.assign(s.begin(), s.end());

// std::wstring -> std::string
std::wstring ws(L"wstring");
std::string s;
s.assign(ws.begin(), ws.end());

Monday, June 16, 2008

Add custom library or form in Visual Studio Macros

  1. Create custom class library in language that you prefer.
  2. In Build events Post build events add: copy "$(TargetPath)" "$(DevEnvDir)PublicAssemblies\"
  3. In macro from where you whant to use your custom library add reference to your class library
  4. You are now free to use your custom library in your macro

Tuesday, June 10, 2008

Find commented peace of code

In the process of re factoring of your code you may wish to delete commented peaces of code. You can use this regular expression to find potential trash in your code

((//.*\n)(//.*\n)+)(\/\*(.\n)#\*\/)