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)

 

CLEAR ALL

CLEAR

 

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

                   ?cPath+aFiles[i,1]

                   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

                             ?Properties

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

                             nDoCreate=0

                             nBorderStyle=0

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

                                      ?j,aProps[j]

                                      DO CASE

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

                                                nDoCreate=j

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

                                                nBorderStyle=j

                                      ENDCASE

                             ENDFOR

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

                                      cTemp=""

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

                                                DO CASE

                                                CASE nIndex = nDoCreate

                                                          cTemp=cTemp+aProps[nBorderStyle]+CHR(13)+CHR(10)

                                                          cTemp=cTemp+aProps[nDoCreate]+CHR(13)+CHR(10)

                                                CASE nIndex = nBorderStyle

                                                          * do nothing: already added

                                                OTHERWISE

                                                          cTemp=cTemp+aProps[nIndex]+CHR(13)+CHR(10)

                                                ENDCASE

                                      ENDFOR

                                     

                                      REPLACE Properties WITH cTemp    && and update

                                      ?properties

                             ENDIF

                   ENDSCAN

                   USE IN SCX    && close the file

          ENDFOR

          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

                   ENDIF

          ENDFOR

         

RETURN

</end of program>