<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[ViEmu Forums - vs2008: Macro Document.Selection failed with ViemuVS 2.5.4 installed]]></title>
		<link>http://www.viemu.com/forum/viewtopic.php?id=5240</link>
		<description><![CDATA[The most recent posts in vs2008: Macro Document.Selection failed with ViemuVS 2.5.4 installed.]]></description>
		<lastBuildDate>Thu, 24 Feb 2011 02:39:23 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: vs2008: Macro Document.Selection failed with ViemuVS 2.5.4 installed]]></title>
			<link>http://www.viemu.com/forum/viewtopic.php?pid=8511#p8511</link>
			<description><![CDATA[<p>i just uninstalled vax 1842 and the problem is gone. no problem with either vimemu/vax installed but reproduced with both of them installed</p><p>it looks like viemu/vax conflict with each other and cause macro issue. much like the twice esc problem</p><p>i hope that vax/viemu developers team will cooperate better with each other</p>]]></description>
			<author><![CDATA[dummy@example.com (mOo)]]></author>
			<pubDate>Thu, 24 Feb 2011 02:39:23 +0000</pubDate>
			<guid>http://www.viemu.com/forum/viewtopic.php?pid=8511#p8511</guid>
		</item>
		<item>
			<title><![CDATA[vs2008: Macro Document.Selection failed with ViemuVS 2.5.4 installed]]></title>
			<link>http://www.viemu.com/forum/viewtopic.php?pid=8510#p8510</link>
			<description><![CDATA[<p>the following code is written by me to save cursor state on close and restore it on open<br />it used to work with ViEmuVS-2.2.9 but now when 2.5.4 installed it&#039;s broken<br />when i debug it in Macro IDE, i found that with in function OnDocumentClosing, selection == Nothing, broken by Viemu 2.5.4, why?<br />no such problem with viemu uninstalled or with 2.2.9</p><div class="codebox"><pre><code>Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics

Public Class IniFile
    &#039; API functions
    Private Declare Ansi Function GetPrivateProfileString _
    Lib &quot;kernel32.dll&quot; Alias &quot;GetPrivateProfileStringA&quot; _
    (ByVal lpApplicationName As String, _
    ByVal lpKeyName As String, ByVal lpDefault As String, _
    ByVal lpReturnedString As System.Text.StringBuilder, _
    ByVal nSize As Integer, ByVal lpFileName As String) _
    As Integer
    Private Declare Ansi Function WritePrivateProfileString _
    Lib &quot;kernel32.dll&quot; Alias &quot;WritePrivateProfileStringA&quot; _
    (ByVal lpApplicationName As String, _
    ByVal lpKeyName As String, ByVal lpString As String, _
    ByVal lpFileName As String) As Integer
    Private Declare Ansi Function GetPrivateProfileInt _
    Lib &quot;kernel32.dll&quot; Alias &quot;GetPrivateProfileIntA&quot; _
    (ByVal lpApplicationName As String, _
    ByVal lpKeyName As String, ByVal nDefault As Integer, _
    ByVal lpFileName As String) As Integer
    Private Declare Ansi Function FlushPrivateProfileString _
    Lib &quot;kernel32.dll&quot; Alias &quot;WritePrivateProfileStringA&quot; _
    (ByVal lpApplicationName As Integer, _
    ByVal lpKeyName As Integer, ByVal lpString As Integer, _
    ByVal lpFileName As String) As Integer
    Dim strFilename As String

    &#039; Constructor, accepting a filename
    Public Sub New(ByVal Filename As String)
        strFilename = Filename
    End Sub

    &#039; Read-only filename property
    ReadOnly Property FileName() As String
        Get
            Return strFilename
        End Get
    End Property

    Public Function GetString(ByVal Section As String, _
    ByVal Key As String, ByVal [Default] As String) As String
        &#039; Returns a string from your INI file
        Dim intCharCount As Integer
        Dim objResult As New System.Text.StringBuilder(256)
        intCharCount = GetPrivateProfileString(Section, Key, _
        [Default], objResult, objResult.Capacity, strFilename)
        If intCharCount &gt; 0 Then GetString = _
        Left(objResult.ToString, intCharCount)
    End Function

    Public Function GetInteger(ByVal Section As String, _
    ByVal Key As String, ByVal [Default] As Integer) As Integer
        &#039; Returns an integer from your INI file
        Return GetPrivateProfileInt(Section, Key, _
        [Default], strFilename)
    End Function

    Public Function GetBoolean(ByVal Section As String, _
    ByVal Key As String, ByVal [Default] As Boolean) As Boolean
        &#039; Returns a boolean from your INI file
        Return (GetPrivateProfileInt(Section, Key, _
        CInt([Default]), strFilename) = 1)
    End Function

    Public Sub WriteString(ByVal Section As String, _
    ByVal Key As String, ByVal Value As String)
        &#039; Writes a string to your INI file
        WritePrivateProfileString(Section, Key, Value, strFilename)
        Flush()
    End Sub

    Public Sub WriteInteger(ByVal Section As String, _
    ByVal Key As String, ByVal Value As Integer)
        &#039; Writes an integer to your INI file
        WriteString(Section, Key, CStr(Value))
        Flush()
    End Sub

    Public Sub WriteBoolean(ByVal Section As String, _
    ByVal Key As String, ByVal Value As Boolean)
        &#039; Writes a boolean to your INI file
        WriteString(Section, Key, CStr(CInt(Value)))
        Flush()
    End Sub

    Private Sub Flush()
        &#039; Stores all the cached changes to your INI file
        FlushPrivateProfileString(0, 0, 0, strFilename)
    End Sub

End Class

Public Module EnvironmentEvents

#Region &quot;Automatically generated code, do not modify&quot;
    &#039;Automatically generated code, do not modify
    &#039;Event Sources Begin
    &lt;System.ContextStaticAttribute()&gt; Public WithEvents DTEEvents As EnvDTE.DTEEvents
    &lt;System.ContextStaticAttribute()&gt; Public WithEvents DocumentEvents As EnvDTE.DocumentEvents
    &lt;System.ContextStaticAttribute()&gt; Public WithEvents WindowEvents As EnvDTE.WindowEvents
    &lt;System.ContextStaticAttribute()&gt; Public WithEvents TaskListEvents As EnvDTE.TaskListEvents
    &lt;System.ContextStaticAttribute()&gt; Public WithEvents FindEvents As EnvDTE.FindEvents
    &lt;System.ContextStaticAttribute()&gt; Public WithEvents OutputWindowEvents As EnvDTE.OutputWindowEvents
    &lt;System.ContextStaticAttribute()&gt; Public WithEvents SelectionEvents As EnvDTE.SelectionEvents
    &lt;System.ContextStaticAttribute()&gt; Public WithEvents BuildEvents As EnvDTE.BuildEvents
    &lt;System.ContextStaticAttribute()&gt; Public WithEvents SolutionEvents As EnvDTE.SolutionEvents
    &lt;System.ContextStaticAttribute()&gt; Public WithEvents SolutionItemsEvents As EnvDTE.ProjectItemsEvents
    &lt;System.ContextStaticAttribute()&gt; Public WithEvents MiscFilesEvents As EnvDTE.ProjectItemsEvents
    &lt;System.ContextStaticAttribute()&gt; Public WithEvents DebuggerEvents As EnvDTE.DebuggerEvents
    &lt;System.ContextStaticAttribute()&gt; Public WithEvents ProjectsEvents As EnvDTE.ProjectsEvents
    &lt;System.ContextStaticAttribute()&gt; Public WithEvents TextDocumentKeyPressEvents As EnvDTE80.TextDocumentKeyPressEvents
    &lt;System.ContextStaticAttribute()&gt; Public WithEvents CodeModelEvents As EnvDTE80.CodeModelEvents
    &lt;System.ContextStaticAttribute()&gt; Public WithEvents DebuggerProcessEvents As EnvDTE80.DebuggerProcessEvents
    &lt;System.ContextStaticAttribute()&gt; Public WithEvents DebuggerExpressionEvaluationEvents As EnvDTE80.DebuggerExpressionEvaluationEvents
    &#039;Event Sources End
    &#039;End of automatically generated code
#End Region

    Public Sub DTEEvents_OnMacrosRuntimeReset() Handles DTEEvents.OnMacrosRuntimeReset
        DocumentEvents = DTE.Events.DocumentEvents
    End Sub

    Public ini As IniFile = New IniFile(Environ(&quot;APPDATA&quot;) &amp; &quot;\VisualStudioSavedCursor.ini&quot;)

    Public Sub OnDocumentOpened(ByVal Document As EnvDTE.Document) Handles DocumentEvents.DocumentOpened
        Dim name As String = Document.FullName
        Dim selection As TextSelection = Document.Selection
        Dim activePoint As EnvDTE.VirtualPoint = selection.ActivePoint
        If activePoint.Line &lt;&gt; 1 Or activePoint.LineCharOffset &lt;&gt; 1 Then
            Return
        End If

        selection.MoveToLineAndOffset(ini.GetInteger(name, &quot;startPoint.Line&quot;, 1), ini.GetInteger(name, &quot;startPoint.Offset&quot;, 1))
        selection.TextPane.TryToShow(selection.ActivePoint.CreateEditPoint, vsPaneShowHow.vsPaneShowTop)
        selection.MoveToLineAndOffset(ini.GetInteger(name, &quot;anchorPoint.Line&quot;, 1), ini.GetInteger(name, &quot;anchorPoint.Offset&quot;, 1))
        selection.MoveToLineAndOffset(ini.GetInteger(name, &quot;activePoint.Line&quot;, 1), ini.GetInteger(name, &quot;activePoint.Offset&quot;, 1), True)
    End Sub

    Public Sub OnDocumentClosing(ByVal Document As EnvDTE.Document) Handles DocumentEvents.DocumentClosing
        Dim name As String = Document.FullName
        Dim selection As TextSelection = Document.Selection
        &#039; selection = Nothing, broken by Viemu 2.5.4 ?

        Dim startPoint As EnvDTE.TextPoint = selection.TextPane.StartPoint
        Dim anchorPoint As EnvDTE.VirtualPoint = selection.AnchorPoint
        Dim activePoint As EnvDTE.VirtualPoint = selection.ActivePoint

        ini.WriteInteger(name, &quot;startPoint.Line&quot;, startPoint.Line)
        ini.WriteInteger(name, &quot;startPoint.Offset&quot;, startPoint.LineCharOffset)
        ini.WriteInteger(name, &quot;anchorPoint.Line&quot;, anchorPoint.Line)
        ini.WriteInteger(name, &quot;anchorPoint.Offset&quot;, anchorPoint.LineCharOffset)
        ini.WriteInteger(name, &quot;activePoint.Line&quot;, activePoint.Line)
        ini.WriteInteger(name, &quot;activePoint.Offset&quot;, activePoint.LineCharOffset)
    End Sub
End Module</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (mOo)]]></author>
			<pubDate>Thu, 24 Feb 2011 02:30:31 +0000</pubDate>
			<guid>http://www.viemu.com/forum/viewtopic.php?pid=8510#p8510</guid>
		</item>
	</channel>
</rss>
