autoredraw

This is a discussion on autoredraw within the Windows Programming forums, part of the Platform Specific Boards category; hey does anybody know how to make the best autoredraw i don't think paint event can handle it so good ...

  1. #1
    Registered User
    Join Date
    Dec 2004
    Posts
    103

    autoredraw

    hey does anybody know how to make the best autoredraw i don't think paint event can handle it so good since events can only fire at every 100 ms so maybe there is another way, and is there a command for clearing the pixels from the dlg box ? invalidate(); doesn't work so good + it does more than clearing the pixels..

    thanks

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,485
    So is this for windows, or some other graphical API ?

  3. #3
    Registered User
    Join Date
    Dec 2004
    Posts
    103
    windows :P and im using mfc

  4. #4
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    moved to windows board

  5. #5
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    hey does anybody know how to make the best autoredraw i don't think paint event can handle it so good since events can only fire at every 100 ms
    That's news to me.

    What exactly do you want to achieve?
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    >>so good since events can only fire at every 100 ms

    Paint msgs are the lowest priority in the message que and can be ignored.
    The que can be bypassed from within the app by InvalidateRect() (sets the area to redraw) then UpdateWindow() (posts message internally ie not thru OS msg que)

    As CornedBee states, if you tell us more detail we can give better advice.

    ie
    for a game?
    use a different msg que handler (PeekMessage() not GetMessage() )
    getting flicker?
    look at WM_WM_ERASEBKGND msgs (return true)

    ect
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  7. #7
    Registered User
    Join Date
    Dec 2004
    Posts
    103
    well im recoding my chat prog in vc++ 6.0 i have it done in visual basic right now and visual basic supports autoredraw though i can use the paint event but thats slow and that way you can see it flicker by moving something on it, anyway my chat program has a 48x48 pic thats resized on the dlg window ( form ) and i wanna make a good autoredraw for it like to work atleast how the one in vb works

    screenshot of my prog if helps -> http://www.olympus-studios.biz/chate...screenshot.jpg
    or
    site -> www.olympus-studios.biz/chatex if you wanna test it

  8. #8
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    What you should do is identify the area that needs redrawing (something in the PAINTSTRUCT) and redraw only that. This way, you save a lot of time.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  9. #9
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    A slight increase in update frequency is unlikely to remove a flicker problem.

    MSDN: Flicker-Free Displays Using an Off-Screen DC

    Search: flicker free WM_PAINT

    Pay special attention to WM_ERASEBKGND. Your screenshot looks great!

  10. #10
    Registered User
    Join Date
    Dec 2004
    Posts
    103
    yea i know about WM_ERASEBKGND it improves things a bit, anyway i have no idea how to identify the area that needs redrawing i also need the fastest function to clear some pixels off the dlg box drawing stuff on another drawed stuff doesnt work anybody know that function ? oh and about the screenshot thx thats nothing compared to what im going to do in c++ if i learn to handle it like vb well no doubt c++ is alot harder than it lol

  11. #11
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    Are you handling any painting (OnPaint) ?

    There is no autoredraw in MFC. You have to do the drawing yourself (unless using controls which are slow and large ones tend to flicker).

    Is that screen shot a large edit with a theme applied or are you skinning the window and wdrawing the text to a bitmap?
    If a large edit then it will probably always have some flicker as the whole control is redawn rather than just the area that needs it.

    Look at the links anonytmouse gave you and search here for double buffering.

    >> have no idea how to identify the area that needs redrawing

    in your OnPaint() handler use GetUpdateRect()
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  12. #12
    Registered User
    Join Date
    Dec 2004
    Posts
    103
    thx ill give them a shot i didn't notice they were links but how to erase some pixels off the dlg window ? InvalidateRect ? i mean i seen how it works instead of just clearing the pixels from the dlg box it makes other controls flicker too
    Last edited by eXistenZ; 12-05-2004 at 03:33 AM.

  13. #13
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    pardon???
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  14. #14
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    You can paint over existing pixels, but erasing pixels is not possible - what would be there instead?
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  15. #15
    Registered User
    Join Date
    Dec 2004
    Posts
    103
    i know but i tried that pixels over pixels painting and doesn't seem to work right i gotta use invalidate else you will see some of the previous pixels remaining maybe i need some kind of dlg window refresh function i used to have the same problem in visual basic so i just used Me.Refresh

    check out the screenshots youll notice the difference
    Attached Images Attached Images   

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21