0

I have an app that reads a file with tabular data, and containing names of 2 images relating to the data (RGB and CIR)

I display the RGB in a Windows form app, using the following so the user see textual data and the RGB image

 SnippetDisplayOut.Image = Image.FromFile(RGB_Snippetname, True)

Then I display a second image on a separate screen so the user can compare the RGB and CIR images Using the following. It passes the complete image name to the default application associated with the file extension.

 Try
        Dim myProcess As Process = Process.Start(CIR_Snippetname)
               Catch ex As Exception
        MsgBox(CIR_Snippetname & " Not Found")
    End Try

The user then categorizes the image and the program displays the next RGB image and CIR image.

This works, but is a bit klugdy - I have not figured how to terminate the CIR image display, so the user has to manually terminate the group after too many pile up.

In addition, it would be nice to be able to direct the CIR image display to a screen separate from the windows forms display.

I have tried adding the MyHandle = myProcess.Handle as follows but this displays the CIR image and then says it cannot find the image

Dim myProcess As Process = Process.Start(CIR_Snippetname) MyHandle = myProcess.Handle

and when I tried to use the following to close the image, I get a process not found error.

Try Dim myProcess As Process = Process.GetProcessById(MyHandle) myProcess.Close() Catch ex As Exception MsgBox("Process Not Found") End Try

Rfrank
  • 51
  • 5
  • `Process.Id` and `Process.Handle` are not the same thing. You probably have `Option Strict Off`. Store the `myProcess` object (in a Field) and call `myProcess.CloseMainWindow()` when you're done with it. In relation to the Screens positions/coordinates, see the notes [here](https://stackoverflow.com/a/53026765/7444103). – Jimi Jan 23 '20 at 21:30
  • Thanks - I have set strict on and fixed the complaints. – Rfrank Jan 23 '20 at 23:00
  • I have added Try ProcID = Process.GetCurrentProcess.Id Dim text1 As String = ProcID.ToString MsgBox(text1) 'ProcID.CloseMainWindow() Catch ex As Exception MsgBox("Process Not Found") End Try So I can see the process id - but it is the main application, not the image display – Rfrank Jan 23 '20 at 23:01
  • Here is my code to start the image display - I do this after I have displayed the RGB image, and the closemainwindow is executed at the start of the subroutine - so the first time it will have an error so the catch will be a next statement Dim myProcess As Process = Process.Start(CIR_Snippetname) ProcID = myProcess.Id – Rfrank Jan 23 '20 at 23:05
  • I tried Dim p As Process p = New Process() p.StartInfo.FileName = CIR_Snippetname p.Start() and p.Kill() to terminate - but got a no process associiated with tiis object, although both pictures came up th first time as expected – Rfrank Jan 24 '20 at 00:04

0 Answers0