zoukankan      html  css  js  c++  java
  • C#多屏时控制窗体显示在哪个显示器上

    Have an application functionaluty which has 4 forms which are needed to interact by the user by dragging data from these forms to one another
    the main form is located in the MDI Parent and the rest are on their respective screen (3 other secondry screens)

    At the moment i am testing using 2 screens but i get a very similar behavious when i run it on a 4 screened system.

    For the 2 screen system:
    form1 opens in primary screen (ie the MDI Parent)
    form2 opens in 2nd screen
    form3 opens in 1st screen (primary)
    form 4opens in 2nd screen

    for the 4 screened system:
    form1 opens in primary screen (ie the MDI Parent)
    form2 opens in 2nd screen
    form3 opens in 1st screen (primary)
    form 4opens in 2nd screen

    When this feature is requested by the user, form1 opens
    form1 has the following code which opens form2, form3, and form4 in their respective screens

    following is the code in method called by form_load within form1

    1. private void openForms()
    2. {
    3.    Form2 form2 = new Form2();
    4.    Form3 form3 = new Form3();
    5.    Form4 form4 = new Form4();
    6.  
    7.    Screen[] screens = Screens.AllScreens;
    8.    if(screens.Length == 2)
    9.    {
    10.       List<Screen> lstScreen = new List<Screen>();
    11.       foreach(Screen screen in Screen.AllScreens)
    12.       {
    13.          if(screen.Primary == false)
    14.             lstScree.Add(screen);
    15.       }
    16.       form2.Location = lstScreen[0].WorkingArea.Location;
    17.       form3.Location = lstScreen[0].WorkingArea.Location;
    18.       form4.Location = lstScreen[0].WorkingArea.Location;
    19.    }
    20.    else if(screens.Length == 4)
    21.    {
    22.       List<Screen> lstScreen = new List<Screen>();
    23.       foreach(Screen screen in Screen.AllScreens)
    24.       {
    25.          if(screen.Primary == false)
    26.             lstScree.Add(screen);
    27.       }
    28.       form2.Location = lstScreen[0].WorkingArea.Location;
    29.       form3.Location = lstScreen[1].WorkingArea.Location;
    30.       form4.Location = lstScreen[2].WorkingArea.Location;
    31.    }
    32. }

    While debugging it for the 2 screen system, i found that the Location of all the 3 forms is being set to -1280,0 even after the show method is executed the positions are shown to -1280,0

    so cant figure out why form3 appears on the primary screen, but form4 appears back onto the 2nd screen.

  • 相关阅读:
    关于C51的中断函数要注意的几个问题
    WORD文档中插入页码的问题
    【转载】vim复制时的缩进
    【转载】在Linux下,一个文件也有三种时间,分别是:访问时间、修改时间、状态改动时间
    【转载】LINUX上MYSQL优化三板斧
    【转载】小结一下linux 2.6内核的四种IO调度算法
    【转载】linux挂载mount参数优化
    【转载】ipcs与Linux共享内存
    【转载】Linux下的IO监控与分析
    【转载】netstat--查看服务器[有效]连接数--统计端口并发数--access.log分析
  • 原文地址:https://www.cnblogs.com/lizi/p/2361230.html
Copyright © 2011-2022 走看看