TIP: removing flicker on windows

  1. ‹ Older
  2. 6 years ago

    Kem T

    12 Nov 2013 Pre-Release Testers, Xojo Pro, XDC Speakers New York

    I'll have to check WFS and add this code if it's not there already. Nice work.

    (I'm curious why the conversation is in Pro. Wouldn't everyone benefit from this?)

  3. Massimo V

    12 Nov 2013 Pre-Release Testers, Xojo Pro Europe (Germany, Würzburg)

    @Russ L on my listbox a call to listbox.refresh immediately after the call to allowRedraw seems to work just fine.

    This seems not the case for me. That’s why I said a call to RedrawWindow may be needed.

  4. Brock N

    12 Nov 2013 Pre-Release Testers, Xojo Pro
    Edited 6 years ago
    Sub AllowRedraw(extends w as Window, allow as Boolean = true)
      #if targetWin32
        If allow then
          const WM_SETREDRAW = &h000B
          declare sub SendMessage lib "User32" alias "SendMessageW" (hwnd As integer, msg As integer, wParam As Boolean, lParam as Integer)
          ' SendMessage((HWND) hWnd, WM_SETREDRAW, (WPARAM) wParam, (LPARAM) lParam);
          SendMessage(w.handle, WM_SETREDRAW, true, 0)
          w.Refresh
        else
          const WM_SETREDRAW = &h000B
          declare sub SendMessage lib "User32" alias "SendMessageW" (hwnd As integer, msg As integer, wParam As Boolean, lParam as Integer)
          ' SendMessage( (HWND) hWnd, WM_SETREDRAW, (WPARAM) wParam,(LPARAM) lParam);
          SendMessage(w.handle, WM_SETREDRAW, false, 0)
        end
      #endif
    End Sub

    Here's a condensed version of what Massimo wrote. It does it in one method:
    Simply call:
    myWindow.AllowRedraw(false)
    //Flickering stuff here
    myWindow.AllowRedraw(true)

    I also included a w.Refresh when you turn on allowRedraw, I don't know if this will suffice for RedrawWindow command or not - Anyone know?

  5. Russ L

    12 Nov 2013 Pre-Release Testers, Xojo Pro

    nice update Mr Nash.

    btw this is in the pro channel because thats where I've been asking questions about the listbox lately, i agree it would benefit all windows users, maybe it can be moved to the windows channel?

  6. Richard D

    12 Nov 2013 Pre-Release Testers, Xojo Pro Europe (UK, London)

    what about this? even more condense

    Sub AllowRedraw(extends w as Window, allow as Boolean = true)
      #if targetWin32
        const WM_SETREDRAW = &h000B
        declare sub SendMessage lib "User32" alias "SendMessageW" (hwnd As integer, msg As integer, wParam As Boolean, lParam as Integer)
        If allow then
          SendMessage(w.handle, WM_SETREDRAW, true, 0)
          w.Refresh
        else
          SendMessage(w.handle, WM_SETREDRAW, false, 0)
        end
      #endif
      end Sub
  7. Norman P

    12 Nov 2013 Xojo Inc, Pre-Release Testers, Xojo Pro Seeking work. npalardy@great-w...

    FYI - this is covered in Aarons book page 418
    Lots of VERY useful stuff in there for Windows users

  8. Russ L

    19 Nov 2013 Pre-Release Testers, Xojo Pro

    I've just found that when i call these functions the part of the container control that overlaps the locked window (or allow redraw)
    doesn't work correctly, it is not receiving mouse events as far as i can tell.

    this is really annoying because i need to be able to see which row in my listbox is clicked!

  9. 5 years ago

    Russ L

    22 Nov 2013 Pre-Release Testers, Xojo Pro

    I've got it nearly sorted now!

    you need to make the overlaying controls top left be inside the control you are locking. then it seems to work just fine.

    in fact I'm really quite pleased with the results!

  10. Karen A

    26 Nov 2013 Pre-Release Testers

    @Russ L
    btw this is in the pro channel because thats where I've been asking questions about the listbox lately

    Just noticed this thread... Not all the listbox experts are Xojo Pro ;)

  11. Russ L

    26 Nov 2013 Pre-Release Testers, Xojo Pro

    I am sorry, oh wise one. It was not my intention to anger the listbox gods. ;-)

    I only posted it there because I happened to be in that Chanel at the time.
    It wasn't meant to be elitist.

    Also, it's not just about list boxes but any layered containercontrols.

  12. Karen A

    26 Nov 2013 Pre-Release Testers

    <sigh> And issues with layered container controls are of general interest too...

    One more reason what I wish there was only the NUG... I learned a lot from the discussions there ... here on average (at least outside of the Pro channel) the questions seem to trend more 'basic' than the NUG at it's height. Oh well...

    In any case I'm glad this got moved here, as I added it to my copy of the WFS.

    Thanks

  13. Russ L

    26 Nov 2013 Pre-Release Testers, Xojo Pro

    Well. I agree about the nug. I used to get some good stuff on there but I think the forum is better now that I'm used to it.

    I think that container controls, are probably a feature used by more advanced users but that's not the same set as pro users. Maybe there should be a special case for people who have contributed a lot to the community, to be allowed into the pro forum. I know one of the things I learned from you was that what I thought was a pretty basic control could be made to sing.

  14. Derk J

    26 Nov 2013 Pre-Release Testers, Xojo Pro

    Why isn't this in the framework?

  15. Russ L

    26 Nov 2013 Pre-Release Testers, Xojo Pro

    Lol.. Just, lol.

  16. Norman P

    26 Nov 2013 Xojo Inc, Pre-Release Testers, Xojo Pro Seeking work. npalardy@great-w...

    @Derk J Why isn't this in the framework?

    WM_REDRAW you mean ?

  17. Karen A

    26 Nov 2013 Pre-Release Testers

    @Norman P WM_REDRAW you mean ?

    I think he means as a high level API to freeze updates to deal with flicker on Windows without having to deal with/ know about declares and be sure you are not messing with Xojo framework operations using it.

  18. Russ L

    26 Nov 2013 Pre-Release Testers, Xojo Pro

    Sorry for my sarcastic reply. Been a very long day.

    I agree that it would make sense. There is a refresh so why not a lock refresh.
    Its 20 lines of code and some lines in the LR and it makes a MASSIVE difference.

    Control.blockredraw
    Control.allowredraw

  19. Derk J

    26 Nov 2013 Pre-Release Testers, Xojo Pro

    @Norman P WM_REDRAW you mean ?

    I mean ANY anti-flicker supported by windows apis.
    I use windows many times more for development than mac, for that i have seen alot of flicker.

    I just feel like it should never have been possible to even create flicker. But it happens, then i see this and think why doesn't the framework has such build in (so you never notice flicker) or have a AutoBlockFlicker flag on some controls for example.

  20. jim m

    27 Nov 2013 Pre-Release Testers piDog.com

    Have you tried using drawinto in the paint event of the window or container? I've seen some great results with pushbuttons and progressbars. This is one approach I use in the ActivityViewer project to help reduce flicker on Win32.

    Sub Paint(g As Graphics, areas() As REALbasic.Rect)
    PushButton1.DrawInto g,PushButton1.Left,PushButton1.top
    End Sub

    Seems to help a lot if live resizing the window causes flicker. Doesn't work well for listboxes though if I recall...

  21. Richard D

    26 Jan 2014 Pre-Release Testers, Xojo Pro Europe (UK, London)

    @Russ L I've just found that when i call these functions the part of the container control that overlaps the locked window (or allow redraw)
    doesn't work correctly, it is not receiving mouse events as far as i can tell.

    this is really annoying because i need to be able to see which row in my listbox is clicked!

    i encounter problem with these code took.. i have this code on the resized and resizing on my main form and i open a container control that have some code on the on open to read a table and show the record but instead of doing that, it went into a endless loop on the Open Event for the container control. Removing the code solved the problem.

  22. Newer ›

or Sign Up to reply!