Home All Groups Group Topic Archive Search About

ProcessStart(textfile) focus issue

Author
30 Apr 2010 1:02 AM
mp
just learning dotnet so i write a lot of debug lines to text file so i can
track where errors occur
Private Sub Logentry(ByVal strMsg As String)
   File.AppendAllText("Path to debug file\Debug.txt", strMsg +
Environment.NewLine)
End Sub

the app is a vbnet app running inside autoCad, so it acts like i'm entering
autocad command inside autocad(autocad has focus)
Main app creates worker class that does the work
worker class creates utility class that has general functions used over
various projects
utility class provides logging etc

at end of program run utility class opens the text file to read the debug
log.

in worker class:
Protected Overrides Sub Finalize()
    m_acadDoc = Nothing '<----destroy reference to acad document
    m_acadApp = Nothing'<----destroy reference to acad application
    m_util.OpenDebugLog() '<---ask util class to open debug log file in
notepad
    m_util = Nothing'<----destroy reference to utility class

    MyBase.Finalize()
End Sub


in the utility class:
Sub OpenDebugLog()
  Process.Start(m_DebugFileName)
End Sub



when the file opens in notepad, notepad has focus and keyboard entry goes
into log file.

this didn't use to happen, the file just opened and keyboard focus was still
"in" autocad.

any ideas what i need to do to fix it?

thanks
mark

Author
30 Apr 2010 1:18 AM
Family Tree Mike
On 4/29/2010 9:02 PM, mp wrote:
Show quoteHide quote
> just learning dotnet so i write a lot of debug lines to text file so i can
> track where errors occur
> Private Sub Logentry(ByVal strMsg As String)
>     File.AppendAllText("Path to debug file\Debug.txt", strMsg +
> Environment.NewLine)
> End Sub
>
> the app is a vbnet app running inside autoCad, so it acts like i'm entering
> autocad command inside autocad(autocad has focus)
> Main app creates worker class that does the work
> worker class creates utility class that has general functions used over
> various projects
> utility class provides logging etc
>
> at end of program run utility class opens the text file to read the debug
> log.
>
> in worker class:
> Protected Overrides Sub Finalize()
>      m_acadDoc = Nothing '<----destroy reference to acad document
>      m_acadApp = Nothing'<----destroy reference to acad application
>      m_util.OpenDebugLog() '<---ask util class to open debug log file in
> notepad
>      m_util = Nothing'<----destroy reference to utility class
>
>      MyBase.Finalize()
> End Sub
>
>
> in the utility class:
> Sub OpenDebugLog()
>    Process.Start(m_DebugFileName)
> End Sub
>
>
>
> when the file opens in notepad, notepad has focus and keyboard entry goes
> into log file.
>
> this didn't use to happen, the file just opened and keyboard focus was still
> "in" autocad.
>
> any ideas what i need to do to fix it?
>
> thanks
> mark
>
>

So at some point you changed something and now focus goes to Notepad?

Just a guess, but did you used to pop up a message box after you opened
the text file in notepad?  The act of opening a messagebox would have (I
believe) brought focus back to Autocad.

--
Mike
Author
30 Apr 2010 2:38 PM
mp
Show quote Hide quote
"Family Tree Mike" <FamilyTreeM***@ThisOldHouse.com> wrote in message
news:OWDNdMA6KHA.4116@TK2MSFTNGP02.phx.gbl...
> On 4/29/2010 9:02 PM, mp wrote:
>> when the file opens in notepad, notepad has focus and keyboard entry goes
>> into log file.
>>
>> this didn't use to happen, the file just opened and keyboard focus was
>> still
>> "in" autocad.
>>
>> any ideas what i need to do to fix it?
>>
>> thanks
>> mark
>>
>>
>
> So at some point you changed something and now focus goes to Notepad?
>
> Just a guess, but did you used to pop up a message box after you opened
> the text file in notepad?  The act of opening a messagebox would have (I
> believe) brought focus back to Autocad.
>
> --
> Mike

hmm, i did change several things...that may have been one of them...have to
go back and look.
thanks
mark
Author
30 Apr 2010 7:53 AM
Andrew Morton
mp wrote:
> just learning dotnet so i write a lot of debug lines to text file so
> i can track where errors occur
> Private Sub Logentry(ByVal strMsg As String)
>   File.AppendAllText("Path to debug file\Debug.txt", strMsg +
> Environment.NewLine)
> End Sub

As an aside, the string concatenation operator in VB.NET is "&", not "+".

--
Andrew
Author
30 Apr 2010 12:58 PM
mp
Thanks, been bouncing between c# and vbnet trying to learn dotnet and in c#
i believe it changed to +
was always used to & , coming from vb6...will try to watch that.
thanks
mark

Show quoteHide quote
"Andrew Morton" <a**@in-press.co.uk.invalid> wrote in message
news:83vgklFmv9U1@mid.individual.net...
> mp wrote:
>> just learning dotnet so i write a lot of debug lines to text file so
>> i can track where errors occur
>> Private Sub Logentry(ByVal strMsg As String)
>>   File.AppendAllText("Path to debug file\Debug.txt", strMsg +
>> Environment.NewLine)
>> End Sub
>
> As an aside, the string concatenation operator in VB.NET is "&", not "+".
>
> --
> Andrew
>