MSDNからVBのサンプルをコピーして実行させてみましたが、
空のフォームが表示されるだけでした。
shiken.gifの画像を実行ファイルと同じ場所に格納してあります。
原因がわかりません。
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Public Class animateImage
Inherits Form
'Create a Bitmpap Object.
Private animatedImage As New Bitmap("shiken.gif")
Private currentlyAnimating As Boolean = False
'This method begins the animation.
Public Sub AnimateImage()
If Not currentlyAnimating Then
'Begin the animation only once.
ImageAnimator.Animate(animatedImage, _
New EventHandler(AddressOf Me.OnFrameChanged))
currentlyAnimating = True
End If
End Sub
Private Sub OnFrameChanged(ByVal o As Object, ByVal e As EventArgs)
'Force a call to the Paint event handler.
Me.Invalidate()
End Sub
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
'Begin the animation.
AnimateImage()
'Get the next frame ready for rendering.
ImageAnimator.UpdateFrames()
'Draw the next frame in the animation.
e.Graphics.DrawImage(Me.animatedImage, New Point(0, 0))
End Sub
Public Shared Sub Main()
Application.Run(New AnimateImage)
End Sub
End Class
アクアと申します。どうぞ宜しくお願いします。
Private animatedImage As New Bitmap("shiken.gif")
ここのBitmap(" ")の記述をアニメーションGIFの"フルパス+ファイル名"に置き換えて実行してみてください。
例えばデスクトップにGifイメージが置かれてある場合には
Private animatedImage As New Bitmap("C:\Users\ユーザー名\Desktop.shiken.gif")
となります。
ちなみに当方の環境は
Windows Vista Ultimate x86
Visual Studio Team System 2008
です。
ありがとうございます。
しかし、状況は変わりません。
また、存在しないファイル名を記述してもエラー表示がでず
同じように空のフォームが表示されます。
VB2008
windows XPSP3
実行ファイルと同じ場所に shiken.gif があるならば・・・
Private animatedImage As New Bitmap(Application.StartupPath + "\shiken.gif")
としないと、その画像ファイル使われませんが・・・
以上。
Windowsフォームプロジェクトを作成した際に用意されているForm1のコードデザイナにMSDNのサンプルをコピー&ペーストして実行しているのではないでしょうか?
であれば、以下を試してみてください。
1)ファイルメニューをクリックし、[新規作成(N)]→[プロジェクト]→[Windowsフォームアプリケーション]の順番でクリックし、任意のプロジェクト名を記述し、[OK]を押す。
2)1で新しいプロジェクトが作成されてますが、ソリューションエクスプローラーにあるForm1を選択、右クリックしてメニューを表示させ、Form1を削除します。
3)ソリューションエクスプローラーにあるプロジェクト名を選択し、右クリックしメニューを表示し、[追加(D)]をクリックするとさらにメニューが表示されるので、[クラス]を選択します。
4)ファイル名をAnimateImage.vbと設定し、[OK]を押します。
5)MSDNのサンプルをコピー&ペーストします。
6)Private animatedImage As New Bitmap("shiken.gif")のBitmap(" ")をフルパス+ファイル名で指定します。
7)メニューの[プロジェクト(P)]をクリックし、最下段にある["〜"のプロパティ(P)](←"〜"は1で指定したプロジェクト名)を選択する。
8)[アプリケーション]のタブが開いてあるので、[スタートアップ]の項目を確認するとForm1となっていると思いますので、そのコンボボックスを開き、AnimateImageを指定します。
以上の手順を踏んで貰ったらF5を押してデバッグ実行してみてください。
アクアさんの仰ったとおりに実行してみるとうまく動きました。
有り難うございました。
オショウさんも有り難うございました。
ツイート | ![]() |