Results 1 to 6 of 6

Thread: Prevent control from painting

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    112

    Prevent control from painting

    Can I prevent a control form painting until I want it to? Here is my situation:

    I have a control consisting of 3 picture boxes, pbx1, pbx2 and pbx3 all in a row next to each other.
    When a button is clicked, the images slowly slide to the left in unison. When pbx1 reaches a certain point on the left, it jumps to the end of the line so that the new order is pbx2, pbx3 then pbx1. The pictureboxes continue to slide to the left until pbx3 has reached pbx2's origninal position.

    At this point I relocate each picturebox to its original location, but I change their images to match what was onscreen prior to that relocation. The end result is that there is a very slight flicker in my rightmost picturebox as it is swapped with leftmost picturebox and has its image changed.

    It's not a huge deal, but I'd like to be able to turn off painting for just a fraction of a second while I reposition the pictureboxes and change their images. Once that is done, I'd turn painting back on.

    Can anyone show me how to do this? I'm completely useless when it comes to overriding and canceling things.

    Thanks,

  2. #2
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    Re: Prevent control from painting

    I don't have a direct answer but I would like to say that you'd be much better off if you would draw those pictures yourself either on your form or on an inherited control, without the use of multiple pictureboxes.
    "so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Prevent control from painting

    You should call SuspendLayout on the form prior to your actions and then ResumeLayout when you're done. I'm not 100% sure but I believe that could solve your problem.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Prevent control from painting

    Why doesnt he use lockwindowupdate on the picture box so it doesnt update until its already been moved

  5. #5
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Re: Prevent control from painting

    Hi Jm,suspendlayout doesnt work to stop the repainting stuff.. but I wonder if it doesnt do that,what can that function actually do.
    Godwin

    Help someone else with what someone helped you!

  6. #6
    Frenzied Member Phill64's Avatar
    Join Date
    Jul 2005
    Location
    Queensland, Australia
    Posts
    1,201

    Re: Prevent control from painting

    the suspend and resumelayout functions prevent the drawing of new controls so that a large number of control changes can be made without the lag of displaying it until the end, according to msdn

    http://msdn.microsoft.com/library/de...ayouttopic.asp

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