본문 바로가기

C# 개인 공부 기록용/Memo

UI 둥글게 만들기

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

namespace M_Test
{
    public partial class M_Form : Form
    {
        #region Btn Border Round
        [DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
        private static extern IntPtr CreateRoundRectRgn
           (
           int nLeft,
           int nTop,
           int nRight,
           int nBottom,
           int nWidthEllipse,
           int nHeightEllipse
           );
        #endregion

        private void Timer_Tick(object sender, EventArgs e)
        {
            Lbl_Time.Text = DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss");
        }

        public M_Form()
        {
            InitializeComponent();

            // 타이머 시작
            Date_Timer.Start();

            #region M_Form Pn Round
            Pn_Title.Region = Region.FromHrgn(CreateRoundRectRgn
            (0, 0, Pn_Title.Width, Pn_Title.Height, 80, 80));

            Pn_Title_M.Region = Region.FromHrgn(CreateRoundRectRgn
            (0, 0, Pn_Title_M.Width, Pn_Title_M.Height, 80, 80));
            #endregion

            #region M_Form Btn Round
            Btn_Old.Region = Region.FromHrgn(CreateRoundRectRgn
            (0, 0, Btn_Old.Width, Btn_Old.Height, 30, 30));

            Btn_Season_Ticket.Region = Region.FromHrgn(CreateRoundRectRgn
            (0, 0, Btn_Season_Ticket.Width, Btn_Season_Ticket.Height, 30, 30));


            Btn_Charge_Card.Region = Region.FromHrgn(CreateRoundRectRgn
            (0, 0, Btn_Charge_Card.Width, Btn_Charge_Card.Height, 30, 30));

            Btn_Select.Region = Region.FromHrgn(CreateRoundRectRgn
            (0, 0, Btn_Select.Width, Btn_Select.Height, 15, 15));
            #endregion
        }