Results 1 to 3 of 3

Thread: [RESOLVED] SetTimer corrupts windows after a while?

  1. #1

    Thread Starter
    Fanatic Member ididntdoit's Avatar
    Join Date
    Apr 2006
    Location
    :uoıʇɐɔoן
    Posts
    765

    Resolved [RESOLVED] SetTimer corrupts windows after a while?

    I know that what I'm doing in this case is very bad programming practice, but we have to follow certain criteria in these programs that I write for class. Just a heads up.

    The program must animate something on the screen at a certain interval (usually 10-25ms) using SetTimer(hWnd, TMR_MINE, 10, NULL) and handle the timer ticks with WM_TIMER in the messages loop of the program.

    The problem is that after a minute or so of running the program stops drawing to my window and if I drag my window anywhere on the screen things go whacky, Windows Styles seems to be corrupted and shows really weird things. If anyone needs a visual, I may be able to capture a screen movie of it and upload it.

    I know this isn't just my code because I've seen it happen to a couple buddys of mine also. Is this a known bug and if so how is it worked around?

    EDIT: BTW, VS2008 IDE, Windows XP Pro SP2
    Visit here to learn to make the VB interface fit you!.
    "I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison
    "The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners" -- Ernst Jan Plugge

  2. #2
    New Member TheD4rkRider's Avatar
    Join Date
    Apr 2009
    Location
    Egypt
    Posts
    6

    Re: SetTimer corrupts windows after a while?

    Well if i understand your problem correctly, this can be solved by drawing your objects in the WM_PAINT message handler.

    The WM_PAINT message is sent to the application by Windows whenever the client area needs to be updated (when the window has been resized, moved or obscured by another window).

    That is if you don't update your drawings using the WM_PAINT message handler when the window is resized/draged/minimized all the drawings you have done before will be lost.

    And maybe a screenshot of the problem will make it clear.

    Regards,
    TheD4rkRider

  3. #3

    Thread Starter
    Fanatic Member ididntdoit's Avatar
    Join Date
    Apr 2006
    Location
    :uoıʇɐɔoן
    Posts
    765

    Re: SetTimer corrupts windows after a while?

    All of my painting is actually in WM_PAINT. I only have a few calculations in WM_TIMER and a call to InvalidateRect();

    Let me see if I have that screen capture program somewhere handy...

    EDIT: OK, well I can't seem to get the screen capture thing going good ATM but I found the problem: a tiny memory leak that ended up doing some messed up stuff. I doubt I could upload a movie of it anyways based on the strict filters and file sizes imposed by the forums.
    Last edited by ididntdoit; Oct 3rd, 2009 at 10:51 PM.
    Visit here to learn to make the VB interface fit you!.
    "I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison
    "The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners" -- Ernst Jan Plugge

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