hammerman Posted January 29, 2004 Posted January 29, 2004 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? Quote
MustangJoe Posted January 29, 2004 Posted January 29, 2004 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. Quote
Administrators PlausiblyDamp Posted January 29, 2004 Administrators Posted January 29, 2004 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() Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
hammerman Posted January 30, 2004 Author Posted January 30, 2004 Works Like a Champ! Thanks much for the feedback! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.