ich hab mir mal eine kleine fotoanzeige in visual basic gemacht und stoße beim debugg immer auf folgenden fehler: "Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt." in den fällen bei den threads, die ich bei google gefunden hab tritt dieser fehler nur bei einer deklaration auf, aber bei mir tritt es in zeile 46 auf:
Imports System.Runtime.InteropServices
Public Class Form1
<Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.Sequential)> Public Structure MARGINS
Public LeftWidth As Integer
Public RightWidth As Integer
Public TopHeight As Integer
Public Buttomheight As Integer
End Structure
<Runtime.InteropServices.DllImport("dwmapi.dll")> Public Shared Function DwmExtendFrameIntoClientArea(ByVal hWnd As IntPtr, ByRef pMarinset As MARGINS) As Integer
End Function
Dim Settings As New My.MySettings
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Try
Me.BackColor = Color.Black
Dim margins As MARGINS = New MARGINS
margins.LeftWidth = 0
margins.RightWidth = 0
margins.TopHeight = 34
margins.Buttomheight = 0
Dim result As Integer = DwmExtendFrameIntoClientArea(Me.Handle, margins)
Catch ex As Exception
MsgBox("It seems your computer has no Aero or you DWM is damaged!", vbCritical, "Error loading the application")
Application.Exit()
End Try
End Sub
Private Sub open_Click(sender As System.Object, e As System.EventArgs) Handles open.Click
openpic.ShowDialog()
Try
picture.ImageLocation = openpic.FileName
Catch ex As Exception
MsgBox("The file you selected is not a valid image file!", MsgBoxStyle.OkOnly, "Invalid image file")
End Try
End Sub
Private Sub openpic_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles openpic.FileOk
Try
Me.Width = picture.Image.Width
Catch ex As Exception
Me.Width = Me.MinimumSize.Width
End Try
Me.Height = picture.Image.Height
End Sub
End Class
offenbar liegt das in "picturebox.image.height", weil ich es über textboxen und settings-strings versucht habe mit dem gleichen fehler.
open = button
openpic = openfiledialog
Picture = picturebox
danke im voraus für antworten!

Hilfe
Neues Thema
Antworten

Nach oben


