Fix your forms to paint borders correctly under Vista Aero

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


When executing a Fox Form, Fox asks Windows to create a window, then sets the BorderStyle of the window. Apparently, under Vista Aero (except as Administrator), the BorderStyle cannot be set after the Window has been created.


To reproduce the problem, start Visual FoxPro (I tried back to VFP7 (released summer 2001))

  • File->New->Form

  • In the property sheet, dbl-click BorderStyle to change it to 1 or 2

    • 0 = No border   ( no problem, because there are no borders to draw)

    • 1 = Fixed Single

    • 2 = Fixed Dialog

    • 3 = Sizable (Default)      (no problem, because it’s the default)

  • Hit Ctrl-E or click on the “!” in the toolbar to run the form. Give it a name

  • Move the form around so that the borders or title bar will need to be repainted

  • Result: The window behaves as if there is no border: it won’t get repainted.



Amazingly enough, run under Admin mode, and you’ll see the problem disappear. Perhaps a non-admin app changing the BorderStyle might be a security risk: An app might be able to grab a window handle from another process and impersonate a Credentials screen or something.


When Fox runs a form, it reads the Properties and sets them in the order encountered. For a Form, the “DoCreate” pseudo property means to create the window. The BorderStyle happens to be written after the DoCreate, so the BorderStyle setting is ignored


The properties look like this before the fix:

Top = 0

Left = 0

Height = 250

Width = 375

DoCreate = .T.

BorderStyle = 1

Caption = "Form1"

Name = "Form1"





So your choices are:

  • Open the Form as a table (It really is just a table) and manually put BorderStyle before DoCreate.

  • Run the program below that fixes your SCX files by putting the BorderStyle property before the DoCreate

  • Convert your SCX forms to VCX (Visual Classes), where the BorderStyle is set at window creation time. (Just choose File->Save As Class from the Form designer)

  • Wait for the next release of VFP SP

  • Run Vista without Aero

  • Run your app as Admin




See also



Program starts below (and works in VFP7 too)





FixDir(CURDIR()) && Call recursive program with current directory


*Recursive program to fix all forms found in cPath and subdirectories

* Fix Vista Aero Border painting by changinge DoCreate and BorderStyle order

PROCEDURE FixDir(cPath)    && Fix all forms in directory cPath and subdirectories

          LOCAL n,aFiles[1],cPath,i,j,cTemp,nBorderStyle,nDoCreate,aProps[1],nLines,nIndex

          n=ADIR(aFiles,cPath+"*.scx")        && look in current dir for all form files (.SCX)

          FOR i = 1 TO n


                   USE (cPath+aFiles[i,1]) ALIAS SCX  && open the form as a table

                   SCAN FOR !EMPTY(Properties) AND ATC("DoCreate",Properties)>0       && locate the Properties


                             nLines = ALINES(aProps,Properties)          && Create an array of all the lines in the Properties



                             FOR j = 1 TO nLines  && Loop through and record the array indices of DoCreate and BorderStyle


                                      DO CASE

                                      CASE ATC("DoCreate",aProps[j])>0


                                      CASE ATC("BorderStyle",aProps[j])>0




                             IF nDoCreate > 0 AND nDoCreate  < nBorderStyle         && If DoCreate precedes BorderStyle, insert BorderStyle before


                                      FOR nIndex = 1 TO nLines   && now emit the properties in the desired order

                                                DO CASE

                                                CASE nIndex = nDoCreate



                                                CASE nIndex = nBorderStyle

                                                          * do nothing: already added






                                      REPLACE Properties WITH cTemp    && and update




                   USE IN SCX    && close the file


          n=ADIR(aFiles,cPath+"*.*","D")     && Get any subdirs

          FOR i = 1 TO n

                   IF ATC("D",aFiles[i,5])>0 AND aFiles[i,1] != "."

                             FixDir(cPath+aFiles[i,1]+"\")          && recur





</end of program>


Comments (15)
  1. Calvin_Hsia says:

    I’ve modified the code: instead of swapping the DoCreate and the BorderStyle, it now inserts the BorderStyle before the DoCreate. It might make a subtle difference, although I don’t know of any cases where it would.

  2. Randy Jean says:


    Your continued contributions to the VFP community are much appreciated.  Keep up the great work!

  3. Markus Winhard says:

    Hi Calvin,

    thank you very much for another insight into the inner workings of VFP. I’d like to add that your fix can be called from a project hook class’ BeforeBuild event.

    Unfortunately it’s not as useful for a professional VFP user. Most of us are using Visual SourceSafe with VFP. So most forms are checked in at build time and thus are read only (removing the read only attribute is not really an option).

    As the ProjectHook class has no BeforeCheckIn event I have no clue how to automate running your code before check in.

    Any idea?



  4. Dominic Webb says:

    Unfortunately this fix does not work – at least under VFP 8. Mostly (but not always) the borders are correctly painted on creation, but if a form is opened over the top, or the form moved over the edge of the screen and back, corruptions occur. The properties of one my forms that does not work (after Calvin’s fix) are:

    Height = 396

    Width = 314

    BorderStyle = 2

    DoCreate = .T.

    ShowTips = .T.

    AutoCenter = .T.

    Caption = "Letter Generator"

    ControlBox = .F.

    Closable = .F.

    MaxButton = .F.

    MinButton = .F.

    WindowType = 1

    Name = "LETTER"

    I have tried moving other properties before the DoCreate, but without success. Interestingly, running as administrator does correct the problem.

    Another workaround I have just tried is to set HalfHeightCaption = .T., which gives a Windows 2000 look, but does seem to avoid the corruptions.

    A final problem affecting VFP applications is with fonts corrupting. I understand from Rick Strahl that this is due to the ClearType setting which is now default in Vista. Are there likely to be any solutions to this?

  5. Calvin_Hsia says:


    I tried creating a form with exactly the same properties as you specify in VFP8, and it repro’s the Aero problem as expected. I run the fix in my code above to put the BorderStyle before the DoCreate, and the problem goes away. Keep in mind that every time VFP rewrites the form from any modification, the fix above needs to be applied. If you can still repro the problem, can you provide the exact repro steps. Thanks

  6. Calvin_Hsia says:


    Perhaps in your beforeBuild event you can run code that turns off the readonly attrib, applies the fix. The AfterBuild event can be used to clean up. You could even make/restore a backup copy in these events.

  7. Calvin,

    Thank you for these set of fixes!

  8. Above is an image of an inner form (from the C++ project below) before and after I dragged it a little

  9. Cesar Chalom says:

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

  10. Gregory Adam says:


    When the border/Titlebar is not shown, clicking outside the form and clicking back inside the form sometimes repaints it correctly with a Titlebar

    Have taken out the ‘DoCreate = .T.’ line altogether.  Some testing seems to confirm that this is another possibility

    (1) Compile form does not put ‘DoCreate = .T.’

    (2) Editing a form does put the ‘DoCreate = .T.’ back

    Any thoughts ?

  11. Joe M. says:

    How can I enabled the Aero Glass effect to a  VFP program that’s built as a SDI? In other words, this program uses the main VFP screen at runtime. VFP ignores the Aero Glass effect. Can it be enabled in this instance?

  12. We’ve figured out the Vista border issue (we think). We couldn’t reproduce it here, but Jim Slater noted

  13. Christoph Dreßler says:

    The Border problem exists also with Border Style = 3. I fix the program be amended and all was well.

  14. Hi Calvin. I’m coming late to the party but have the same VFP form border issues and need some clarity. All of the forms in my app. were built using Vsual Fox Express and VFP9. All of the forms are VCXs. None are SCX. Nevertheless, in Aero, they all paint correctly at startup but any form movement (moving a form from one place to another on the screen) or calling another form corrupts their borders. The form’s title bar disappears thereby losing its Min, Max and Close buttons.

    I haven’t tried your code because your message imples the VCX forms should behave correctly. What am I missing? Thanks.

  15. 出会い says:


Comments are closed.

Skip to main content