Page 1 of 2 1 2 LastLast
Showing results 1 to 10 of 13

Thread: multi monitor configuration lost if monitors switched off

  1. #1
    Join Date
    26.10.2011
    Posts
    6

    Default multi monitor configuration lost if monitors switched off

    We are using multi monitor configuration with 2 monitors 1920x1080 resolution each. The zenon6.ini parameters are set RT_CXMAINFRAME=3839, RT_CYMAINFRAME 1079. On each monitor are shown several frames with buttons, alarm head and plant pictures. After runtime start anything is fine. Now our problem: after switching off the power of the monitors (monitors off over weekend, runtime still continues) all frames and pictures from second monitor are on the first (main) monitor in the background. All attempts to solve this in runtime doesn't work. The only way to get the frames and pictures back to the second monitor is to shutdown and restart the runtime. But this need long time (redundant system) and is not usable for our customer. Do anybody have a better solution for this?
    Many thanks in advance!

  2. #2
    josefm Gast

    Default Re: multi monitor configuration lost if monitors switched off

    Hi wopmsc,

    welcome to the COPA-DATA Forum

    I guess this is a strange behavior but it seems that through turning off the monitor somehow the computer realizes it and then changes the screen resolution.
    As I also often turn off my monitors and never had such issues I'm curious about how they "turn off" the monitor.
    - Even if I unplug the power cable the computer still realizes that there is a second monitor.
    - Do they also change some connections on the monitors?
    - Can you somehow reproduce this behavior?
    - What cable connection are they using? (VGA, DVI, HDMI, DisplayPort, maybe also an adapter)

    It would be very comfortable if you can provide detailed information how we also can reach such a result.


    With best regards
    Last edited by josefm : 7th November 2013 at 11:51

  3. #3
    josefm Gast

    Default Re: multi monitor configuration lost if monitors switched off

    Hello again,

    a colleague of mine just mentioned, that he has the same behavior using his computer.

    The problem is that there are several possibilities that can cause it. (Operating System, Hardware like Graphics Card, Monitor, etc.)

    He mentioned that this always happens when he puts the computer into sleep mode. Then after some seconds his computer screens are changing to standby and when turning on the computer again his resolution settings are changed.

    Maybe you can find out more with these hints and let us take part on the knowledge you gained.


    Best regards

  4. #4
    Join Date
    26.10.2011
    Posts
    6

    Default Re: multi monitor configuration lost if monitors switched off

    Hi josefm,

    thank you for the quick reply.
    We are using Zenon V6.51 SP0 B0 on Win7 Prof. SP1 engl. The graphics card is NVIDIA Quadro NVS 420. Cable connection via DVI. The graphic card has an special connection adapter becaus it's for up to 4 screens max.
    The computers power settings for sleep mode are all 'never' (PC/monitors), the Zenon runtime is always still going on.
    Our customer would like to switch off the monitors over weekends or public holidays (power button at the monitor, no other action).
    At project startup we verified the graphics card with Copadata support.

    I think you're right, there is a change of screen resolution in case of monitors power off/power on. Disconnecting of power cable or power blackout have the same effect.

    Yesterday I found out a strange behaviour. All the time we tought the frames and pictures from second screen are in the background of the first (main) screen after switching the power of the monitor.
    But it seems that frames and pictures are still on the second screen after switching power off/power on, laying in the BACKGROUND of the desktop and can not get visible (to foreground) via functions. Only a restart of runtime get back the right view for the second monitor. First monitor is always ok after power switching.

    With Best Regards

  5. #5
    josefm Gast

    Default Re: multi monitor configuration lost if monitors switched off

    Hi,

    I had a chat with the NVIDIA Support.

    They've suggested to do the following:
    - check the energy options of windows
    --- disable the power Settings
    - does this issue occurs also if they turn off the monitor like for half an hour?
    - does it also affects other applications?
    --- like when running a full screen application on monitor 2

    Maybe if we have answers on that questions we are able to figure out what's the reason.


    With best regards

  6. #6
    Join Date
    26.10.2011
    Posts
    6

    Default Re: multi monitor configuration lost if monitors switched off

    Hi Josefm,

    power settings are all off, monitor and pc will never be switched off.
    Today I'm switched off the monitors for more than a half hour as suggested by NVIDIA. The result is the same as every time, frames and pictures of the second screen are laying in the background of the desktop, can be displayed only by restarting the runtime.
    Only the Zenon runtime is affected from this strange behaviour.

    So I did some more trials. An important fact is that windows of other programs like Zenon Editor, Windows Explorer or Office always be moved from second screen to screen one, the main screen in case of power off/power on of the monitors and don't move back. Maybe this will be a point for an ongoing solution of our problem.

    Best Regards
    wopmsc

  7. #7
    josefm Gast

    Default Re: multi monitor configuration lost if monitors switched off

    Hi wopmsc,


    I'm happy to tell you that I've found a solution that worked out here.

    If it's no problem for you to use VSTA the following code will work out properly.

    // Add these usings
    using System.Runtime.InteropServices;
    using System.Diagnostics;
    
            // #######################
            // Code in "ThisProject.cs" -> Region "General" -> Region "Macros (Add macros in this region)"
            // #######################
    
            // Import of SetWindowPos of user32.dll
            [DllImport("user32.dll", SetLastError = true)]
            [return: MarshalAs(UnmanagedType.Bool)]
            private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);
    
            // Additional flag parameter
            public const int SWP_ASYNCWINDOWPOS = 0x4000;
            public const int SWP_DEFERERASE = 0x2000;
            public const int SWP_DRAWFRAME = 0x0020;
            public const int SWP_FRAMECHANGED = 0x0020;
            public const int SWP_HIDEWINDOW = 0x0080;
            public const int SWP_NOACTIVATE = 0x0010;
            public const int SWP_NOCOPYBITS = 0x0100;
            public const int SWP_NOMOVE = 0x0002;
            public const int SWP_NOOWNERZORDER = 0x0200;
            public const int SWP_NOREDRAW = 0x0008;
            public const int SWP_NOREPOSITION = 0x0200;
            public const int SWP_NOSENDCHANGING = 0x0400;
            public const int SWP_NOSIZE = 0x0001;
            public const int SWP_NOZORDER = 0x0004;
            public const int SWP_SHOWWINDOW = 0x0040;
    
            public const int HWND_TOP = 0;
            public const int HWND_BOTTOM = 1;
            public const int HWND_TOPMOST = -1;
            public const int HWND_NOTOPMOST = -2;
    
            public void Macro_SetWindowPos_3840x1080()
            {
                try
                {
                    // For getting the handle of the zenon Runtime
                    Process[] processes = Process.GetProcesses();
    
                    // Going through the processes
                    foreach (var process in processes)
                    {
                        // If the ProcessName is "Zenrt32"
                        if (process.ProcessName == "Zenrt32")
                        {
                            // Setting the window size of the process to 3840x1080
                            SetWindowPos(process.MainWindowHandle, (IntPtr)HWND_TOPMOST, 0, 0, 3840, 1080, SWP_NOMOVE | SWP_NOZORDER);
    
                            System.Diagnostics.Debug.Print("SetWindowPos 3840x1080 executed!\nProcess Name:\t{0}\nProcess Handle:\t{1}", process.ProcessName, process.MainWindowHandle.ToString());
                        }
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.Print("Follwing error occured in \"Macro_SetWindowPos_3840x1080\": {0}", ex.ToString());
                }
            }
    
            public void Macro_SetWindowPos_1920x1080()
            {
                try
                {
                    // For getting the handle of the zenon Runtime
                    Process[] processes = Process.GetProcesses();
    
                    // Going through the processes
                    foreach (var process in processes)
                    {
                        // If the ProcessName is "Zenrt32"
                        if (process.ProcessName == "Zenrt32")
                        {
                            // Setting the window size of the process to 1920x1080
                            SetWindowPos(process.MainWindowHandle, (IntPtr)HWND_TOPMOST, 0, 0, 1920, 1080, SWP_NOMOVE | SWP_NOZORDER);
    
                            System.Diagnostics.Debug.Print("SetWindowPos 1920x1080 executed!\nProcess Name:\t{0}\nProcess Handle:\t{1}", process.ProcessName, process.MainWindowHandle.ToString());
                        }
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.Print("Follwing error occured in \"Macro_SetWindowPos_1920x1080\": {0}", ex.ToString());
                }
            }

    You then can add a zenon function "Execute VSTA macro" and link it to a button, execute it via time control, etc.


    With best regards

  8. #8
    Join Date
    26.10.2011
    Posts
    6

    Default Re: multi monitor configuration lost if monitors switched off

    Hi Josefm,

    normally that's great, sorry, but to enjoy this, we've to solve another little problem. At the Zenon engineering station it's impossible to load the VSTA editor.

    With Best Regards
    wopmsc

  9. #9
    josefm Gast

    Default Re: multi monitor configuration lost if monitors switched off

    Hi,

    I can think of some scenarios, but have you turned on VBA / VSTA in your zenon6.ini file?

    For VBA you have to change the following section:
    [VBA]
    EIN=1

    For VSTA you have to change the following section:
    [VSTA]
    ON=1

    Or do you get a message box to accept, or is it just not being opened?


    Best regards

  10. #10
    Join Date
    26.10.2011
    Posts
    6

    Default Re: multi monitor configuration lost if monitors switched off

    Hi Josefm,

    now I'm able to load and open the VSTA editor. But I've got a new problem. I've less experience using VSTA, did it once at my Zenon seminar more than two years ago. Putting in your C code in a code form I'll get more than 25 errors and can't compile.
    Please can you show me the procedure more detailled?

    Kind Regards
    wopmsc

Similar Threads

  1. Multi-Indicator Button
    By dlamarche in forum zenon Supervisor
    Replies: 3
    Last Post: 25th July 2013, 21:10
  2. Multi-Monitor with different resolutions
    By martijnvanspijk in forum zenon Supervisor
    Replies: 6
    Last Post: 22nd May 2013, 12:26
  3. Multi monitor in grid 2x2
    By brada in forum zenon Supervisor
    Replies: 14
    Last Post: 25th October 2011, 09:05
  4. Server & Client monitor configuration
    By roberto1978 in forum zenon Network
    Replies: 1
    Last Post: 10th January 2011, 23:19
  5. Help Please - Lost file menu bar and cant get it back!
    By mattsd in forum zenon Supervisor
    Replies: 1
    Last Post: 23rd October 2007, 07:52

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •