header-img
Info :
728x90

์‹คํ–‰ํ™”๋ฉด

๋ชจ๋‹ˆํ„ฐ ๋ฐฐ์น˜ ๋ฐ ํฌ๊ธฐ๋ฅผ ์ธ์‹ํ•ด ํผ์— ๋„์›Œ์ฃผ๊ณ ,

ํ•ด๋‹น ๋ชจ๋‹ˆํ„ฐ๋ฅผ ํด๋ฆญํ•˜๋ฉด ๊ทธ ๋ชจ๋‹ˆํ„ฐ๋กœ ํผ์ด ์ด๋™ํ•ฉ๋‹ˆ๋‹ค.

 

์ด ๊ธฐ์ˆ ์„ ๋‹จ๋…์œผ๋กœ ์‚ฌ์šฉํ•œ ๊ฒƒ์€ ์•„๋‹ˆ๊ณ 

๊ณต์žฅ ํ˜„์žฅ ๋ชจ๋‹ˆํ„ฐ๋ง ํ”„๋กœ๊ทธ๋žจ์˜ ํ™”๋ฉด ๋ฐฐ์น˜๋ฅผ ์ง๊ด€์ ์ด๊ฒŒ ์ˆ˜์ •ํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ•œ ์†Œ์Šค์ฝ”๋“œ์ž…๋‹ˆ๋‹ค.

 

๋ณดํ†ต์€ ์ด๋ ‡๊ฒŒ ์ง๊ด€์ ์œผ๋กœ ํ•˜๊ธฐ๋ณด๋‹ค๋Š”

ํผ ํ•˜๋‚˜์— ๊ทธ๋ฆฌ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ db์— ํ•ด๋‹น ๋ชจ๋‹ˆํ„ฐ์— ํ•ด๋‹น ํผ์ด ์ž๋™์œผ๋กœ ๋ฐ”์ธ๋”ฉ ๋  ์ˆ˜ ์žˆ๋„๋ก

์ €์žฅํ•˜๋Š” ๊ฒƒ์ด ๋ณดํŽธํ™”๋œ ๋ฐฉ๋ฒ•์ธ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

ํผ ๋””์ž์ธ

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace sc
{
    public partial class Form1 : Form
    {
        Button btn;

        public Form1()
        {
            InitializeComponent();

            Screen[] Monitor = Screen.AllScreens;

            for (int i = 0; i < Monitor.Length; i++)
            {
                btn = new Button();

                btn.Width = Monitor[i].WorkingArea.Width / 10;
                btn.Height = Monitor[i].WorkingArea.Height / 10;
                btn.Left = 300 + (Monitor[i].WorkingArea.Left / 10);
                btn.Top = 200 + (Monitor[i].WorkingArea.Top / 10);
                btn.Text = (i + 1) + "๋ฒˆ์งธ ๋ชจ๋‹ˆํ„ฐ";
                btn.Click += new EventHandler(btnClick);

                this.Controls.Add(btn);

            }

            void btnClick(object sender, EventArgs e)
            {
                int i;
                Button btn = sender as Button;

                string txt = btn.Text.ToString();
                i = Convert.ToInt32(txt.Substring(0, 1));
                // 2์ž๋ฆฌ์ˆ˜ ์ด์ƒ์œผ๋กœ ์•ˆ๋„˜์–ด๊ฐˆ ๊ฑฐ ๊ฐ™์•„์„œ substring ์‚ฌ์šฉ ๋ชจ๋‹ˆํ„ฐ ๊ฐœ์ˆ˜ 2์ž๋ฆฌ์ˆ˜ ๋„˜์–ด๊ฐ€๋ฉด split ์‚ฌ์šฉ

                this.showOnMonitor(i);
            }
        }

        // 01. ๋ฒ„ํŠผ ํด๋ฆญ์‹œ ๋ณธ์ธ ํผ ์ด๋™
        private void showOnMonitor(int showOnMonitor)
        {
            Screen[] sc = Screen.AllScreens;

            Screen screen = sc[showOnMonitor - 1]; // ํ˜„์žฌ๋ชจ๋‹ˆํ„ฐ ์ฐพ๊ธฐ
            this.Location = screen.Bounds.Location; // ๋ชจ๋‹ˆํ„ฐ์œ„์น˜ ๋ณ€๊ฒฝ

        }
    }
}

 

์†Œ์Šค ์ฝ”๋“œ

 

 

728x90
๋”๋ณด๊ธฐ
FRONTEND/C#