Probleme de visualisation picturebox

minimoi114 Messages postés 5 Date d'inscription jeudi 25 janvier 2007 Statut Membre Dernière intervention 30 décembre 2008 - 17 mars 2008 à 20:15
minimoi114 Messages postés 5 Date d'inscription jeudi 25 janvier 2007 Statut Membre Dernière intervention 30 décembre 2008 - 20 mars 2008 à 14:11

3 réponses

minimoi114 Messages postés 5 Date d'inscription jeudi 25 janvier 2007 Statut Membre Dernière intervention 30 décembre 2008
17 mars 2008 à 20:16
Bonjour a tous,
Je realise actuellement un petit jeu en vb.net pour un pti (pratiques de techniques informatiques) pour mon BTS. Je suis confronté a un probleme que je n'arrive pas a resoudre. En fait j'ajoute des objets dynamiquement. La classe de base d'un objet du monde (WorldObject) contient un picturebox dans lequel on peu placer une image (par exemple l'image d'un personnage). Cependant cette classe de base se contente d'afficher un picturebox noir (on precisera l'image dans une classe heritiere si necessaire). Le problème est que le control est ajouté au formulaire mais rien n'apparait.

Voici le code pour ajouter le picturebox (de type public):

Me.form.Controls.Add(Me.objects(Me.ObjectIndex).picBox) ' ajout sur le formulaire de l'image

Les controles sont ajoutés et visibles, je ne comprend pas pourquoi on ne voit rien. J'ai essayé me.form.refresh() mais ca n'a rien donné. A la suite j'ai collé quelques info que j'ai recupéré du immediate window. Si quelqu'un pourrai me dire pourquoi ca ne marche pas comme prévu ca me serai d'une grande aide.

Merci d'avance!

Voici quelques informations du debogueur:


// On note que les controles ont bien été ajoutés

?me.form.Controls
{System.Windows.Forms.Form.ControlCollection}
System.Windows.Forms.Form.ControlCollection: {System.Windows.Forms.Form.ControlCollection}
Count: 2
IsReadOnly: False
Item: In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user.
Owner: {System.Windows.Forms.Form}


// Ceci est le picturebox d'un objet de type WorldObject

?me.form.Controls.Item(0)
{System.Windows.Forms.PictureBox}
System.Windows.Forms.PictureBox: {System.Windows.Forms.PictureBox}
AccessibilityObject: {System.Windows.Forms.Control.ControlAccessibleObject}
AccessibleDefaultActionDescription: Nothing
AccessibleDescription: Nothing
AccessibleName: Nothing
AccessibleRole: Default {-1}
AllowDrop: False
Anchor: 5
AutoScrollOffset: {X 0 Y 0}
AutoSize: False
BackColor: "{Name=Black, ARGB=(255, 0, 0, 0)}"
BackgroundImage: Nothing
BackgroundImageLayout: Tile {1}
BindingContext: {System.Windows.Forms.BindingContext}
Bottom: 400
Bounds: {X 0 Y 300 Width = 100 Height = 100}
CanFocus: True
CanSelect: False
Capture: False
CausesValidation: True
CheckForIllegalCrossThreadCalls: True
ClientRectangle: {X 0 Y 0 Width = 100 Height = 100}
ClientSize: {Width 100 Height 100}
CompanyName: "Microsoft Corporation"
Container: Nothing
ContainsFocus: False
ContextMenu: Nothing
ContextMenuStrip: Nothing
Controls: {System.Windows.Forms.Control.ControlCollection}
Created: True
Cursor: {System.Windows.Forms.Cursor}
DataBindings: {System.Windows.Forms.ControlBindingsCollection}
DefaultBackColor: "{Name=Control, ARGB=(255, 240, 240, 240)}"
DefaultFont: {Name = "Microsoft Sans Serif" Size=8.25}
DefaultForeColor: "{Name=ControlText, ARGB=(255, 0, 0, 0)}"
DisplayRectangle: {X 0 Y 0 Width = 100 Height = 100}
Disposing: False
Dock: None {0}
Enabled: True
Focused: False
Font: {Name = "Microsoft Sans Serif" Size=8.25}
ForeColor: "{Name=ControlText, ARGB=(255, 0, 0, 0)}"
Handle: 67598
HasChildren: False
Height: 100
ImeMode: Disable {3}
InvokeRequired: False
IsAccessible: False
IsDisposed: False
IsHandleCreated: True
IsMirrored: False
LayoutEngine: {System.Windows.Forms.Layout.DefaultLayout}
Left: 0
Location: {X 0 Y 300}
Margin: {System.Windows.Forms.Padding}
MaximumSize: {Width 0 Height 0}
MinimumSize: {Width 0 Height 0}
ModifierKeys: None {0}
MouseButtons: None {0}
MousePosition: {X 55 Y 631}
Name: "WorldObject0"
Padding: {System.Windows.Forms.Padding}
Parent: {System.Windows.Forms.Form}
PreferredSize: {Width 100 Height 100}
ProductName: "Microsoft® .NET Framework"
ProductVersion: "2.0.50727.312"
RecreatingHandle: False
Region: Nothing
Right: 100
RightToLeft: No {0}
Site: Nothing
Size: {Width 100 Height 100}
TabIndex: 0
TabStop: False
Tag: Nothing
Text: ""
Top: 300
TopLevelControl: {System.Windows.Forms.Form}
UseWaitCursor: False
Visible: True
Width: 100
WindowTarget: {System.Windows.Forms.Control.ControlNativeWindow}


// Ceci est le picturebox d'un objet de type human qui herite de worldobject

?me.form.Controls.Item(1)
{System.Windows.Forms.PictureBox}
System.Windows.Forms.PictureBox: {System.Windows.Forms.PictureBox}
AccessibilityObject: {System.Windows.Forms.Control.ControlAccessibleObject}
AccessibleDefaultActionDescription: Nothing
AccessibleDescription: Nothing
AccessibleName: Nothing
AccessibleRole: Default {-1}
AllowDrop: False
Anchor: 5
AutoScrollOffset: {X 0 Y 0}
AutoSize: False
BackColor: "{Name=Black, ARGB=(255, 0, 0, 0)}"
BackgroundImage: Nothing
BackgroundImageLayout: Tile {1}
BindingContext: {System.Windows.Forms.BindingContext}
Bottom: 438
Bounds: {X 300 Y 288 Width = 150 Height = 150}
CanFocus: True
CanSelect: False
Capture: False
CausesValidation: True
CheckForIllegalCrossThreadCalls: True
ClientRectangle: {X 0 Y 0 Width = 150 Height = 150}
ClientSize: {Width 150 Height 150}
CompanyName: "Microsoft Corporation"
Container: Nothing
ContainsFocus: False
ContextMenu: Nothing
ContextMenuStrip: Nothing
Controls: {System.Windows.Forms.Control.ControlCollection}
Created: True
Cursor: {System.Windows.Forms.Cursor}
DataBindings: {System.Windows.Forms.ControlBindingsCollection}
DefaultBackColor: "{Name=Control, ARGB=(255, 240, 240, 240)}"
DefaultFont: {Name = "Microsoft Sans Serif" Size=8.25}
DefaultForeColor: "{Name=ControlText, ARGB=(255, 0, 0, 0)}"
DisplayRectangle: {X 0 Y 0 Width = 150 Height = 150}
Disposing: False
Dock: None {0}
Enabled: True
Focused: False
Font: {Name = "Microsoft Sans Serif" Size=8.25}
ForeColor: "{Name=ControlText, ARGB=(255, 0, 0, 0)}"
Handle: 67600
HasChildren: False
Height: 150
ImeMode: Disable {3}
InvokeRequired: False
IsAccessible: False
IsDisposed: False
IsHandleCreated: True
IsMirrored: False
LayoutEngine: {System.Windows.Forms.Layout.DefaultLayout}
Left: 300
Location: {X 300 Y 288}
Margin: {System.Windows.Forms.Padding}
MaximumSize: {Width 0 Height 0}
MinimumSize: {Width 0 Height 0}
ModifierKeys: None {0}
MouseButtons: None {0}
MousePosition: {X 55 Y 631}
Name: "Human1"
Padding: {System.Windows.Forms.Padding}
Parent: {System.Windows.Forms.Form}
PreferredSize: {Width 150 Height 150}
ProductName: "Microsoft® .NET Framework"
ProductVersion: "2.0.50727.312"
RecreatingHandle: False
Region: Nothing
Right: 450
RightToLeft: No {0}
Site: Nothing
Size: {Width 150 Height 150}
TabIndex: 1
TabStop: False
Tag: Nothing
Text: ""
Top: 288
TopLevelControl: {System.Windows.Forms.Form}
UseWaitCursor: False
Visible: True
Width: 150
WindowTarget: {System.Windows.Forms.Control.ControlNativeWindow}
0
NHenry Messages postés 15113 Date d'inscription vendredi 14 mars 2003 Statut Modérateur Dernière intervention 22 avril 2024 159
18 mars 2008 à 16:58
Bonjour

Où est-ce que tu affiche l'image que tu veux afficher ?

Comment tu as coder sa gestion (de l'image) ?

Nous captons le cockpit coupable qui a capoté
VB (6, .NET1&2), C++, C#.Net1
Mon site
0
minimoi114 Messages postés 5 Date d'inscription jeudi 25 janvier 2007 Statut Membre Dernière intervention 30 décembre 2008
20 mars 2008 à 14:11
J'ai trouvé le problème finalment, c' etait que le picture box été a l'exterieur du formulaire (top>height ou left>width).
Merci quand meme NHenry
Désolé pour le poste.
0
Rejoignez-nous