Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

hello.. question I'm opening a pdf document in one of my forms via shell command (was told this is the best way)

 

Dim regClasses As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.ClassesRoot

Dim regWord As Microsoft.Win32.RegistryKey = regClasses.OpenSubKey("AcroExch.Document").OpenSubKey("shell").OpenSubKey("open").OpenSubKey("command")

Dim adobeReaderPrintCommand As String = regWord.GetValue("").ToString()

Dim fileInfo As New IO.FileInfo(pdfName)

adobeReaderPrintCommand = Replace(adobeReaderPrintCommand, "%1", fileInfo.FullName())

Shell(adobeReaderPrintCommand)

 

this works just fine and the pdf displays - question when it runs the adobe reader is hiddne behind my applicatin (which has focus) how can I switch focus to the adobe reader or bring it to the front?

Posted
It might not necessarily be true in all cases, but you could always just use me.sendtoback() to put your application behind the Adobe Reader program. This is merely assuming that there will only be 2 windows open, your application, and the Adobe Reader. I'm not sure if the Reader's z-level will take precedence over anything else, since it was opened from your application, but it's just a quick workaround I guess.
  • Administrators
Posted

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
	Dim regClasses As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.ClassesRoot
	Dim regWord As Microsoft.Win32.RegistryKey = regClasses.OpenSubKey("AcroExch.Document").OpenSubKey("shell").OpenSubKey("open").OpenSubKey("command")
	Dim adobeReaderPrintCommand As String = regWord.GetValue("").ToString()

	Dim pi As New ProcessStartInfo
	pi.Arguments = "c:\test.pdf"
	pi.FileName = adobeReaderPrintCommand.Replace("""%1""", "").Trim

	Dim p As New Process
	p.StartInfo = pi
	p.Start()

End Sub

worked on mine, although if ADOBE is the default handler then the following may be asier

	Dim pi As New ProcessStartInfo
	pi.FileName = "c:\test.pdf"

	Dim p As New Process
	p.StartInfo = pi
	p.Start()

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...