私がやろうとしていること、そして本当に苦労していることは、アプリケーションで複数の画像を次々にパネルに描画させることです。これは現在、関数にリクエストを送信して画像を描画することで機能するようにコーディングされています。上記の画像に対応する値を送信しますが、その後行き詰まります。パネルに何もペイントできません。関数は次のとおりです。
Function ImageUpdater(ByVal CellNum As Short, ByVal NewImage As Short)
Dim NewImgLoc As String = CurDirShrt & "\Data\Img\" & NewImage & ".png"
DrawPic = NewImgLoc
Try
InitializeComponent()
Cell(CellNum) = NewImage
DrawCell = Cell(CellNum)
UpdateForm = True
'PaintMe(panGame, Nothing)
'e.Graphics.DrawImage(Image.FromFile(NewImgLoc), PicCell(CellNum).X, PicCell(CellNum).Y, CellSize, CellSize)
'PicCell(CellNum).BackgroundImage = Image.FromFile(NewImgLoc)
'PicCell(CellNum).Refresh()
Catch ex As Exception
InitializeComponent()
Cell(CellNum) = 0
DrawCell = Cell(CellNum)
UpdateForm = True
'PaintMe(panGame, Nothing)
'e.Graphics.DrawImage(MisImg, PicCell(CellNum).X, PicCell(CellNum).Y, CellSize, CellSize)
'PicCell(CellNum).BackgroundImage = MisImg
'PicCell(CellNum).Refresh()
End Try
Return 0
End Function
私にとってうまくいかなかったペイント関連のアイテムには、コメント行が含まれていました。パネルをペイントするさまざまな方法を試すことができるように、コメントが付けられました。
パネルの PaintEventArgs サブに画像とそれぞれの場所を送信するために、この関数に何を追加する必要があり、そのサブには何が必要ですか? または、そのサブに送信しない場合は、どうすればよいですか?
PaintEventArgs サブは次のとおりです。
Private Sub PaintMe(sender As Object, e As PaintEventArgs) Handles panGame.Paint
While ChangeInProgress
Application.DoEvents()
If UpdateForm = True Then
e.Graphics.DrawImage(Image.FromFile(DrawPic), PicCell(DrawCell).X, PicCell(DrawCell).Y, CellSize, CellSize)
UpdateForm = False
End If
End While
Return
End Sub