-
Whoa
Hello, and welcome
Today I want to ask on about my dragon-problem. Not the same ol' stupid question, I've figured that out. But my new topic is still related to the issue of object-oriented programming.
If you haven't read my previous thread:
I have a dragon which I call 'Drag'. It's a class module called Drage and a 'Drag' which is a 'Drage'
Option Excplict
Public Drag as New Drage
But this control, Drage, needs a picture to display itself on the screen. I've used the coding:
Dim Monster1 As Image
Set Monster1 = frmBane.Img
With Monster1
.Picture = LoadPicture(App.Path & Drag.Pic1)
.Left = Drag.StartPosL
.Top = Drag.StartPosT
End With
And I've created an Image with the picture of a dragon. However, I am not able to control the Image Control directly from the Class Module, something which is vitally dramatic when I'm trying to build the Method called 'MoveDragon'. So I wonder, does anyone have an idea on how to Either:
Give my dragon class a picture, Left and Top Property OR
Give my dragon full authorization of controling the Image Control.
-
It's because 'monster1 as image' makes a MEMORY image; not on any form.
You could have a picturebox property for the 'Drage' and then link a picturebox to it ByRef (IMPORTANT !), and then control it that way.
-
Hmmm
Really...Explain, please. I'm new at theese sort of things.
-
Well, make a PROPERTY in your 'Drage' CLASSMODULE called Linked, and make it's TYPE be PICTUREBOX.
Then, when you say: Public Drag as New Drage, follow it with:
Drag.Linked = Picture1
Then, you can say stuff in your classmodule like:
'varLinked = a local copy
varLinked.Left = 150i0912871 'whatever
varLinked.Picture = 1092578rqfkjacs 'once again, whatever
varLinked.Bottom = 29751q09jfsa;lz
or...
DONT make a LINKED PROPERTY.
Have a thing that translates codes from the classmodule into the form:
Picture1.Left = Drag.Left
Picture1.Top = Drag.Top
Picture1.Picture = Drag.Picture
...
etc.
Do you get what I mean?
-
Humpdi
Yeah, I think I get what you mean, but what can I use to translate code from the class module to the form?
Picture1.Picture = LoadPicture(AZpp.Path & Drag.Pic1)
will not be accepted in the class module.... so?
There's probably some silly things i've forgot and it all seems very stupid, but....how?
-
Your original idea makes more sense, having an image reference wrapped by the drage class, at least from a OOP point of view.
The image should thought be assigned by using a call, using a property. Monster1 has to be module scope.
-
Ok, first, to make a reference to a control, you have to SET Drage.Linked = Picture1. Second, the code should be App.Path & "\" & Drag.Pic. Just a few points.
Z.
-
YES!
Zaei, you're an angel. However, the coding would not be
LoadPicture(App.Path & "\" Drag.Pic2) as I use the backslash in my pic2 property, with that I mean
With Drag
.Pic2 = "\holaSenorite.Gif"
end With
or similar...However, the SET thing helped me out a lot! I owe you one. Take Care, Bye for now!
-
Oh yeah, but I did nothing.... :D
-
No!
It was sarcastic, it's okay.