Results 1 to 15 of 15

Thread: [VB6] - i need advices:(

  1. #1

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    [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)?
    VB6 2D Sprite control

    To live is difficult, but we do it.

  2. #2

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    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?
    VB6 2D Sprite control

    To live is difficult, but we do it.

  3. #3
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    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.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  4. #4

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: [VB6] - i need advices:(

    Quote Originally Posted by honeybee View Post
    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?
    VB6 2D Sprite control

    To live is difficult, but we do it.

  5. #5
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    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.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  6. #6

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    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)
    VB6 2D Sprite control

    To live is difficult, but we do it.

  7. #7
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    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.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  8. #8

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: [VB6] - i need advices:(

    Quote Originally Posted by honeybee View Post
    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?
    VB6 2D Sprite control

    To live is difficult, but we do it.

  9. #9
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    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.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  10. #10

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: [VB6] - i need advices:(

    Quote Originally Posted by honeybee View Post
    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.

    .
    finally the sub is called 1 time
    seems that resize event is called more than 1 time, when the control is created.
    but i continue with 1 bug, that, honestly, i don't know what is causing it
    but i know is what i see: very sprites on form showing an image. then the form needs very time to show the controls
    i don't know what can cause these problem... i need test more my control
    thanks for the help
    VB6 2D Sprite control

    To live is difficult, but we do it.

  11. #11

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    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?
    VB6 2D Sprite control

    To live is difficult, but we do it.

  12. #12
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    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.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  13. #13

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: [VB6] - i need advices:(

    Quote Originally Posted by honeybee View Post
    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?
    VB6 2D Sprite control

    To live is difficult, but we do it.

  14. #14
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: [VB6] - i need advices:(

    See your other thread in the games/graphics section. I've given you a really fast tiling routine
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  15. #15

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    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.
    VB6 2D Sprite control

    To live is difficult, but we do it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width