Foxpro Menu items, combo boxes not refreshing selected item under Aero in Vista


If you’re running a Foxpro application under Vista when using Aero , you might encounter a problem when scrolling through lists, such as intellisense dropdowns, comboboxes, menus.


 


As you move from one item in the list to the next, each item in turn appears to be selected (colors inverted), which means the prior selected item should be unselected.


 


However, on Vista Aero, sometimes the prior items do not get painted unselected, thus showing multiple selected items.


 


There’s a simple workaround (that works back to VFP7): call the GdiSetBatchLimit API.


 


The GdiSetBatchLimit function sets the maximum number of function calls that can be accumulated in the calling thread’s current batch. The system flushes the current batch whenever this limit is exceeded.


 


 


This will be fixed in the next SP release of VFP


 


The workaround is to run these 2 lines of code somewhere in your application only once.


 


DECLARE integer GdiSetBatchLimit IN WIN32API integer


GdiSetBatchLimit(1)


           

Comments (11)

  1. Halasz says:

    Calvin, thank you for solution ! It works great 🙂

    Tom Halasz

  2. Dominic Webb says:

    This works, but still leaves the problem of the corrupting Window title bars (for non-resizable forms). Is there a workaround for this, and will this be fixed in SP2?

  3. Hi Calvin,

    vfp9 on vista is also not painting the NonClientArea of a form correctly if the form isn’t sizable (as Dominic mentioned). The problem also occurs after the form was partly moved outside the visible area, e.g. below the lower border of the vfp screen.

    I assume vista is blocking some window message. When you run vfp as administrator (e.g. from the context menu) the problem is gone.

    So, is there a way around it, too?

    Markus

  4. Hi,

    Just add this code to your INIT event of your form:

    LOCAL lnBorderStyle

    lnBorderStyle = this.BorderStyle

    ACTIVATE WINDOW (THIS.NAME) IN SCREEN NOSHOW

    this.BorderStyle = lnBorderStyle

    Best regards,

    Ricardo Almeida

  5. Apparently, the borders of some forms don’t get painted correctly on Windows Vista. When executing a

  6. Markus Winhard says:

    Hi Ricardo,

    thank you for this tip. It turned out that it even works without setting BorderStyle again after ACTIVATE WINDOW.

    Just in case someone needs a solution for forms shown in top level form, too, take a look at http://www.bingo-ev.de/~mw368/vfp9_vista.html

    Markus

  7. In this post: Foxpro Menu items, combo boxes not refreshing selected item under Aero in Vista I describe

  8. Cesar Chalom says:

    Here are some of the links that I often visit regarding VFP9 SP2 and Sedna. The official Microsoft Visual…

  9. KennethTamayo says:

    DECLARE integer GdiSetBatchLimit IN WIN32API integer

    GdiSetBatchLimit(1)

    The above indeed works perfectly (at least in Windows Vista Home Premium) in AutoComplete functions, however, complying/deploying SP2 by itself did not prevent the reported display errors "showing multiple selected items"… The two magic lines were required in order to avoid this display problem.

  10. Jim Norton says:

    On a related issue, is there any reason why on Aero enabled (on Vista with Aero) floating forms (so those with showwindow>0) the closing ‘X’ (top right) is showing as enabled (red in colour) at all times, even if the closable property is false. You can’t click it, but it’s still red. All forms with showwindow=0 still have old style smaller ‘X’ boxes, and they correctly display Red or Grey to show enabled or Disabled status.

    I’ve already applied the Combo Box and Graphic refresh fixes for Vista to the forms, but they still have the problem.

    Anyone have any ideas?

  11. Daniel says:

    This combobox bug is still not solved in 2009!