-1

新しいフォームにこのコンストラクターがあります。

public MagnifierForm(Point MousePosition)
        {
            _doMove = true;
            FormBorderStyle = FormBorderStyle.None;
            ShowInTaskbar = false;
            TopMost = true;
            Width = 150;
            Height = 150;
            GraphicsPath gp = new GraphicsPath();
            gp.AddEllipse(ClientRectangle);
            Region = new Region(gp);
            mTimer = new Timer();
            mTimer.Enabled = true;
            mTimer.Interval = 20;
            mTimer.Tick += new EventHandler(HandleTimer);
            mScreenImage = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
                                     Screen.PrimaryScreen.Bounds.Height);

            //maybe subtract half of the forms width/height from the points (offset them)
            mStartPoint = MousePosition;
            mTargetPoint = MousePosition;
            speed = 0.35F;
        }

コンストラクターの下部に、次のコードを追加しました。

mStartPoint = MousePosition;
mTargetPoint = MousePosition;

Form1 には、次のコードがあります。

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == (Keys.Control | Keys.M))
            {
                if (mf == null)
                {
                    mf = new Magnifier20070401.MagnifierForm(System.Windows.Forms.Cursor.Position);
                    mf.StartPosition = FormStartPosition.Manual;
                    mf.Location = Control.MousePosition;
                    mf.Show();

                    this.Select();
                }
                else if (mf.IsDisposed)
                {
                    mf = new Magnifier20070401.MagnifierForm(System.Windows.Forms.Cursor.Position);
                    mf.StartPosition = FormStartPosition.Manual;
                    mf.Location = Control.MousePosition;
                    mf.Show();
                }
                else
                {
                    mf.Close();
                    mf = null;
                }
            }
            return base.ProcessCmdKey(ref msg, keyData);
        }

すべてが正常に機能しています。そして、フォームの位置/場所を設定するこの mStartPoint もうまく機能しています。

しかし、文はどういう意味ですか?//たぶん、ポイントからフォームの幅/高さの半分を引きます (それらをオフセットします)

センテンスは、mStartPoint および mTargetPoint と関係があります。

この文を使いたい場合、どのように見えるべきかの例を誰かに見せてもらえますか?

4

1 に答える 1

0

このスレッドはもともとここにあったと思います。

前の行に続いて:

mScreenImage = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
                                     Screen.PrimaryScreen.Bounds.Height);

ライターは、フォームの幅と高さを他の部分で割って、最初に表示するキャプチャされたフォームの部分を計算して、表示する部分を知る必要があると言っていたと思います。コードが正しければ、表示する必要があるフォームの部分と、さまざまな倍率のさまざまなサイズを計算している場所があると思います。

于 2013-04-17T06:35:21.703 に答える