|
-
Dec 19th, 2011, 02:06 PM
#1
Thread Starter
PowerPoster
[VB6] - i need advices:(
i'm update my Sprite 2D control and i see 1 problem. depending on how many controls i put on form, the form is load, but needs more time
i found the problem, but i don't understand how resolve it
the problem, i have tested, is that ShowImage()(is for show the images with(or not with) graphics effects) is activated 22 times(when the control is initializated\created). the graphics properties call that sub. and they are 22 properties. can i avoid these problem(when the control is created)?
-
Jan 1st, 2012, 04:12 PM
#2
Thread Starter
PowerPoster
Re: [VB6] - i need advices:(
i know that, when control is created, it reads all properties(to see there values). my question is: what is the event that can tell me when the properties was read them?
-
Jan 2nd, 2012, 12:24 AM
#3
Re: [VB6] - i need advices:(
I, for one, am confused as to what exactly the problem is or how to solve it. It would help if you could post the code, or zip and attach your project sothat someone here can take a look at it and suggest improvements.
Without knowing what you are trying to achieve by the project, it's difficult to comment upon any particular aspects or suggest changes.
.
-
Jan 2nd, 2012, 03:40 PM
#4
Thread Starter
PowerPoster
Re: [VB6] - i need advices:(
 Originally Posted by honeybee
I, for one, am confused as to what exactly the problem is or how to solve it. It would help if you could post the code, or zip and attach your project sothat someone here can take a look at it and suggest improvements.
Without knowing what you are trying to achieve by the project, it's difficult to comment upon any particular aspects or suggest changes.
.
i have 8 graphic effects properties, that both call the ShowImage sub. these sub do the graphics effects, depending on that 8 properties. when the control is created these 8 properties are read automatic. then the ShowImage sub is called 8 times or even more, slowing down the when the form is showed. how?
think on these: you have 100 controls(my sprite control) on form and both showes an image. and, when the control is created, the ShowImage sub is called. if 1 control calls it 8 times, think how many times 100 controls can call it?(8X100=800)
well these can slow down and very the form when is showed. even on IDE. yes i try open the form, on IDE, and the IDE\form needs time to show the controls with images. my objective is try read these sub only 1 time, when the control is created, but after read all properties. but how can i do it?
-
Jan 3rd, 2012, 12:05 AM
#5
Re: [VB6] - i need advices:(
That's a little better. Just to ensure we are on common ground, here's what your code looks like as of now. Please correct me if I am wrong:
Code:
Property One
OnChange Call ShowImage
End Property
Property Two
OnChange Call ShowImage
End Property
Property Three
OnChange Call ShowImage
End Property
Property Four
OnChange Call ShowImage
End Property
Property Five
OnChange Call ShowImage
End Property
'and so on
Sub Form_Load()
Read Property One 'which will in turn call ShowImage
Read Property Two 'which will in turn call ShowImage again
'and so on
End Sub
Two workarounds come to mind: Remove the call to the ShowImage function from the individual property subs. So your code would look like this:
Code:
Property One
'OnChange Call ShowImage
End Property
Property Two
'OnChange Call ShowImage
End Property
Property Three
'OnChange Call ShowImage
End Property
Property Four
'OnChange Call ShowImage
End Property
Property Five
'OnChange Call ShowImage
End Property
'and so on
Sub Form_Load()
Read Property One 'which will NOT call ShowImage
Read Property Two 'which will NOT call ShowImage again
'and so on
ShowImage 'Being called only once, after all properties have been set/get
End Sub
The other solution is to use a flag to decide whether the ShowImage should be called from within the property subs:
Code:
Bool CallShowImage = False
Property One
If CallShowImage = True Then
OnChange Call ShowImage
End If
End Property
Property Two
If CallShowImage = True Then
OnChange Call ShowImage
End If
End Property
Property Three
If CallShowImage = True Then
OnChange Call ShowImage
End If
End Property
Property Four
If CallShowImage = True Then
OnChange Call ShowImage
End If
End Property
Property Five
If CallShowImage = True Then
OnChange Call ShowImage
End If
End Property
'and so on
Sub Form_Load()
Read Property One 'which will NOT call ShowImage
Read Property Two 'which will NOT call ShowImage again
'and so on
ShowImage 'Call this once in the form_load
CallShowImage = True 'Now each property sub will automatically invoke the ShowImage
End Sub
The second code has the advantage of eliminating your performance problems at startup, but still being able to invoke ShowImage from individual property subs after the startup.
By the way, you may notice the code above is not strictly as per the syntax, and I am hoping you will be able to understand the logic and implement it your own way.
.
-
Jan 3rd, 2012, 01:03 PM
#6
Thread Starter
PowerPoster
Re: [VB6] - i need advices:(
i understand what you mean, but how can i do it, if the usercontrol, when is inititalizate\created, read the properties automatic?
can you tell me the usercontrol events order?(maybe i can see what i need )
-
Jan 3rd, 2012, 09:43 PM
#7
Re: [VB6] - i need advices:(
User control event orders should be the same as the form events, so the above code should, in principle, still work inside a user control.
.
-
Jan 4th, 2012, 04:13 PM
#8
Thread Starter
PowerPoster
Re: [VB6] - i need advices:(
 Originally Posted by honeybee
User control event orders should be the same as the form events, so the above code should, in principle, still work inside a user control.
.
but can you, please give the event order?
the iniproperty event is activated after read all properties or before?
-
Jan 5th, 2012, 01:24 AM
#9
Re: [VB6] - i need advices:(
To be honest, I don't give a rat's tail what the control firing order is, and I don't remember too.
You can either search Google (which is tough, since VB6 is way too old), or place message boxes in the various events you have handled. The firing of the message boxes will show you the sequence in which the events are firing.
.
-
Jan 5th, 2012, 12:59 PM
#10
Thread Starter
PowerPoster
Re: [VB6] - i need advices:(
-
Jan 6th, 2012, 02:09 PM
#11
Thread Starter
PowerPoster
Re: [VB6] - i need advices:(
ok... i have 1 question: what can needs time to show the control?
i have try see the control events and both seems normaly... the timers are false and the showimage sub is only called, when the control is showed. the resize event only test the resize way(vertical, horizontal and diagonals) and theres the hook api function for the mouse wheel. nothing more. then i'm trying to thing what causes that delay and i don't understand
can anyone sugest me something?
-
Jan 7th, 2012, 12:24 PM
#12
Re: [VB6] - i need advices:(
I suggest you upload your project as a zip file so someone here can take a look. Without knowing the whole code, it's really difficult to comment upon such issues.
.
-
Jan 8th, 2012, 01:44 PM
#13
Thread Starter
PowerPoster
Re: [VB6] - i need advices:(
 Originally Posted by honeybee
I suggest you upload your project as a zip file so someone here can take a look. Without knowing the whole code, it's really difficult to comment upon such issues.
.
ok.. i belive that i found the real problem of these.
1st - we found the way how call that sub once after the control be created.
2nd - now i need speed up my code
and for start, i need speed up my tiles code:
Code:
~If blnTiles = True Then
picGraphicsEffects.Width = UserControl.Width
picGraphicsEffects.Height = UserControl.Height
picGraphicsEffects.Picture = UserControl.Image
For x = 0 To UserControl.Width Step IIf(StripsActivate = True, StripsWidth - 1, imgSize.Width - 1)
For y = 0 To UserControl.Height Step IIf(StripsActivate = True, StripsHeight - 1, imgSize.Height - 1)
BitBlt picGraphicsEffects.hDC, x, y, PicAnimation(lngActualSubImage).Width, PicAnimation(lngActualSubImage).Height, picGraphicsEffects.hDC, 0, 0, vbSrcCopy
API_DoEvents
Next
Next
picGraphicsEffects.Picture = picGraphicsEffects.Image
UserControl.Picture = picGraphicsEffects.Image
End If
i don't know how can i do it. if use hdc variables, the code speed up more or i must use the DIB's code?
-
Jan 10th, 2012, 02:28 PM
#14
Re: [VB6] - i need advices:(
See your other thread in the games/graphics section. I've given you a really fast tiling routine
-
Jan 11th, 2012, 04:54 PM
#15
Thread Starter
PowerPoster
Re: [VB6] - i need advices:(
i have here an image:
http://www.mediafire.com/i/?3mazro88t43xfqd
the form is showed in these way by some seconds... can anyone advice me how avoid these bug or slow thing?
Last edited by joaquim; Jan 11th, 2012 at 04:58 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|