I have used StackOverFLow a few times to steal snippets. This time I have a question since my thievery skills seem to have diminished. I'm using VB.NET.
I have a NoteButton in MyApp. The first time NoteButton is clicked Notepad starts with a particular text file. On subsequent clicks of NoteButton - if NotePad and the file are open then activate Notepad.
If NotePad has been minimized how do I change the WindowState / AppWinstyle to "normal" and bring it to the foreground?
Here is what I have...
On Error GoTo EHandler
Dim TheDirectory = MyApp.My.Application.Info.DirectoryPath
If IsRunningExe("notepad.exe") Then 'Check if notepad is already running
On Error Resume Next
AppActivate("MyList.txt - Notepad")
If Err.Number <> 0 Then
Err.Clear()
Process.Start("notepad.exe", TheDirectory & "\MyList.txt")
End If
'I need to restore a minimized Notepad to "Normal" state and in the foreground
here.
Exit Sub
End If
Process.Start("notepad.exe", TheDirectory & "\MyList.txt")
Exit Sub
EHandler:
MsgBox("There was an error opening the text file.", vbOKOnly + vbInformation)
Thanks for your time,
Greg