C# と VB.NET の質問掲示板

ASP.NET、C++/CLI、Java 何でもどうぞ

ログ内検索
  • キーワードを複数指定する場合は 半角スペース で区切ってください。
  • 検索条件は、(AND)=[A かつ B] (OR)=[A または B] となっています。
  • [返信]をクリックすると返信ページへ移動します。
キーワード/ 検索条件 /
検索範囲/ 強調表示/ ON (自動リンクOFF)
結果表示件数/ 記事No検索/ ON
大文字と小文字を区別する

No.88572 の関連記事表示

<< 0 >>
■88572  Re[6]: コントロールを自然に動かすには??
□投稿者/ 熊さん -(2018/09/08(Sat) 16:01:04)
    2018/09/08(Sat) 16:01:51 編集(投稿者)

    ありがとうございます。
    確かにこのコードだとほとんど残像が気になりませんね。

    以下のコードが残像の出るコードです。

    フォーム上に
    PictureBox1とNumericUpDown1を配置して
    ホイールでNumericUpDown1を回していただけますでしょうか?

    すると位置が変化するはずのない赤色の中央線がぴくぴく動くことがご確認いただけると思います。

    PictureBox1.Invalidate()


    ' PictureBox1.Refresh()
    すると少しましにはなるのですが
    やはりぴくぴく動いてしまいます。


    Public Class Form6


    Public YRate As Single

    Public ProfilePosition As New XY_Profile

    Public Class XY_Profile

    Property X_Int As Integer
    Property Y_Int As Integer

    End Class



    Private Sub Form6_Imaging_Load(sender As Object, e As EventArgs) Handles MyBase.Load


    PBox1 = PictureBox1.Bounds

    With NumericUpDown1
    .Minimum = 10
    .Maximum = 100
    .DecimalPlaces = 0
    .Increment = 3
    .Value = 100
    End With

    PictureBox1.SizeMode = PictureBoxSizeMode.Zoom


    ProfilePosition.X_Int = CInt((PictureBox1.Width - 3) / 2)
    ProfilePosition.Y_Int = CInt((PictureBox1.Height - 3) / 2)



    End Sub



    Private PBox1 As Rectangle


    Private pPen As New Pen(Color.FromArgb(60, Color.Red), 2)

    Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles PictureBox1.Paint

    Dim Pbox As PictureBox = CType(sender, PictureBox)

    Dim g As Graphics = e.Graphics
    g.DrawLine(pPen, 0, ProfilePosition.Y_Int, Pbox.Width, ProfilePosition.Y_Int)
    g.DrawLine(pPen, ProfilePosition.X_Int, 0, ProfilePosition.X_Int, Pbox.Height)

    End Sub



    Private Sub NumericUpDown1_ValueChanged(sender As Object, e As EventArgs) Handles NumericUpDown1.ValueChanged


    YRate = NumericUpDown1.Value / 100

    PictureBox1.SetBounds(PBox1.X, PBox1.Top + CInt(PBox1.Height * (1 - YRate) * 0.5), PBox1.Width, CInt(PBox1.Height * YRate))

    ProfilePosition.Y_Int = CInt(0.5 * (PictureBox1.Height - 4))

    ' PictureBox1.Refresh()

    PictureBox1.Invalidate()


    End Sub

    End Class
記事No.88470 のレス /過去ログ152より / 関連記事表示
削除チェック/



<< 0 >>

パスワード/

- Child Tree -