第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為什么不在新的透明窗體上用鼠標(biāo)繪制矩形?

為什么不在新的透明窗體上用鼠標(biāo)繪制矩形?

C#
素胚勾勒不出你 2021-10-24 17:01:17
它正在進入F_Paint事件,但不是F_MouseDown事件。我希望能夠在F表單上繪制矩形。也許因為F表格是透明的,所以不能在上面畫畫?但它永遠不會到達F_MouseDown我在事件中使用斷點的F_MouseDown事件。不知道為什么它沒有參加MouseDown活動。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 Tester{    public partial class Form1 : Form    {        Ffmpeg ffmpeg = new Ffmpeg();        private bool _canDraw;        private int _startX, _startY;        private Rectangle _rect;        public Form1()        {            InitializeComponent();            BackColor = Color.Blue;            TransparencyKey = BackColor;            Opacity = 1;            var f = new HelperForm { Opacity = 0, ShowInTaskbar = false, FormBorderStyle = FormBorderStyle.None };            f.MouseDown += F_MouseDown;            f.MouseMove += F_MouseMove;            f.MouseUp += F_MouseUp;            f.Paint += F_Paint;            f.Show();            Visible = false;            Owner = f;            Visible = true;            Move += (o, a) => f.Bounds = Bounds;            Resize += (o, a) => f.Bounds = Bounds;            f.Bounds = Bounds;            ffmpeg.Start(@"d:\ffmpegx86\test.mp4", 24);        }        private void F_Paint(object sender, PaintEventArgs e)        {            //Create a new 'pen' to draw our rectangle with, give it the color red and a width of 2            using (Pen pen = new Pen(Color.Red, 2))            {                //Draw the rectangle on our form with the pen                e.Graphics.DrawRectangle(pen, _rect);            }        }        private void F_MouseUp(object sender, MouseEventArgs e)        {            //The system is no longer allowed to draw rectangles            _canDraw = false;        }
查看完整描述

1 回答

?
喵喔喔

TA貢獻1735條經(jīng)驗 獲得超5個贊

阻止繪制矩形和觸發(fā)鼠標(biāo)事件的原因有很多。首先,您將設(shè)置Opacity0; 這意味著您嘗試?yán)L制的任何內(nèi)容都永遠不可見。相反,您應(yīng)該將 設(shè)置為TransparencyKey中的顏色BackColor

f.TransparencyKey = f.BackColor;

然后,您嘗試使用_rect從未初始化的對象繪制一個矩形;因此,您嘗試?yán)L制的矩形將以 0 寬度和 0 高度的大小繪制,這意味著它不會被繪制,因此,在初始化期間,您應(yīng)該為_rect例如:

_rect = new Rectangle(Point.Empty, this.Size);

繪制的矩形現(xiàn)在應(yīng)該是可見的;但是,事件不會觸發(fā),因為您正在反轉(zhuǎn)表單所有權(quán),因此,而不是

Owner = f;

用:

f.Owner = this;


查看完整回答
反對 回復(fù) 2021-10-24
  • 1 回答
  • 0 關(guān)注
  • 149 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號