Hi,
 
I am trying to open a website and send it to second monitor from my visual cobol winforms application.
So i have tried "System.Diagnostics.Process::Start" to launch a website, but i am not able to send it to second monitor. By default website gets triggered in primary monitor.
I have read an article that using WinApi.SetWindowPos , i can switch the monitor positions but in visual cobol i do not see this WinApi class.
If this is not supported, is there any other way to fulfill my requirement ?
 
Thank you.
You can call directly to a WinAPI function like you would in native COBOL using the call program syntax.
 program-id. Program1.
 special-names.
     call-convention 74 is winapi.
 working-storage section.
 78 SWP_NOSIZE value h'0001'.
 78 SWP_NOOWNERZORDER value h'0200'.
 01 pp procedure-pointer.
 01 proc type System.Diagnostics.Process.
 01 hwnd type IntPtr.
 01 xpos binary-long.
 01 ypos binary-long.
 procedure division.
     set proc to type System.Diagnostics.Process::Start("notepad.exe")
     invoke proc::WaitForInputIdle()
     set hwnd to proc::MainWindowHandle
     set xpos to 10
     set ypos to 12
     set pp to entry "User32"
     call winapi "SetWindowPos" using by value hwnd
                                      by value 0
                                      by value xpos
                                      by value ypos
                                      by value 0
                                      by value 0
                                      by value SWP_NOSIZE b-or SWP_NOOWNERZORDER
     goback.
 end program.
                
     
                                    
            Hi,
 
I am trying to open a website and send it to second monitor from my visual cobol winforms application.
So i have tried "System.Diagnostics.Process::Start" to launch a website, but i am not able to send it to second monitor. By default website gets triggered in primary monitor.
I have read an article that using WinApi.SetWindowPos , i can switch the monitor positions but in visual cobol i do not see this WinApi class.
If this is not supported, is there any other way to fulfill my requirement ?
 
Thank you.
Hi Ted,
Thanks for the sample code. It works as expected for notepad but when i tried to fire google.com, website was invoked but there was an exception in the next line of code
After launching the website, my app throws an exception "Object reference not set to an instance of an object" at 
invoke proc::WaitForInputIdle()
So i have commented the above line, the same exception was raised at "set hwnd to proc::MainWindowHandle"
I have modified the code as below assuming that the object proc is not set to an instance
           set proc to new System.Diagnostics.Process()
           set proc::StartInfo::FileName to "
http://google.com/search?q=dog pics"
           invoke proc::Start()
But now after invoking the website new exception is raised "No process is associated with this object"
Thanks in advance for your help...
                
     
                                    
            Hi,
 
I am trying to open a website and send it to second monitor from my visual cobol winforms application.
So i have tried "System.Diagnostics.Process::Start" to launch a website, but i am not able to send it to second monitor. By default website gets triggered in primary monitor.
I have read an article that using WinApi.SetWindowPos , i can switch the monitor positions but in visual cobol i do not see this WinApi class.
If this is not supported, is there any other way to fulfill my requirement ?
 
Thank you.
That's strange, when I try it, proc is set to the process of the browser that the URL opened in. I am not sure why it wouldn't work.
As this issue is Windows, .NET specific, you might be able to find an answer on StackOverflow. The answers to the following post might be of some help:
stackoverflow.com/.../process-start-returns-null