We help IT Professionals succeed at work.

Foxpro

LimMH
LimMH asked
on
Hi,

I am currently using vfp 9.0.
Need help with this:

I had a 3.0 code in .prg file which creates a window and display checkboxes for items found in a table. The there is a OK and a Cancel buttons. When the user set a checkbox and click on the Ok button, it sent something for printing The code goes like this:

IF NOT WEXIST("ANA_MSG")
      DEFINE WINDOW ANA_MSG ;
            AT 0.000, 0.000 ;
            SIZE 24.923,90.00 ;
            FONT "MS Sans Serif", 8 ;
            double;
            NOFLOAT ;
            NOCLOSE ;
            NOMINIMIZE ;
            COLOR RGB(,,,192,192,192)
      move window ana_msg center
ENDIF

SELECT ANALY2      
if reccount() > 0
      DELETE FILE (hdpath+"temp\ORDERING.idx")
      index on SUBJECT to (hdpath+"temp\ORDERING.idx") UNIQUE
      GO TOP
      no_subj = 0
      DO WHILE NOT EOF()
            no_subj = no_subj + 1
            SKIP +1
      ENDDO                  
      go top
      dimension arra3b[no_subj,1]
      copy to array arra3b for subject # " "
      SET INDEX TO
      DELETE FILE (hdpath+"temp\ORDERING.idx")
      dimension arra4[no_subj+1]
*####
      BETWN2 = INT((NO_SUBJ+2)/2)                              
      arra4 = 0
      activate window ana_msg noshow
      @ 0.588,15.650 SAY "SUBJECT ANALYSIS - INDIVIDUAL SUBJECT"  ;
            FONT "MS Sans Serif", 8 ;
            STYLE "BT";
            COLOR RGB(0,0,0,,,,)
      @ 0.538,15.600 SAY "SUBJECT ANALYSIS - INDIVIDUAL SUBJECT"  ;
            FONT "MS Sans Serif", 8 ;
            STYLE "BT";
            COLOR RGB(255,0,0,,,,)
      @ 1.775,15.600 TO 1.775,67.500 ;
            PEN 1, 8 ;
            STYLE "1";
            COLOR RGB(0,0,0,,,)
      @ 1.665,15.600 TO 1.665,67.500 ;
            PEN 1, 8 ;
            STYLE "1";
            COLOR RGB(0,255,0,,,)

      for c = 1 to BETWN2  step 1
            @ (1.200+c*1.274),1.600 GET arra4[c];
                  PICTURE ("@*C "+ alltrim(arra3b[c,1]));
                  SIZE 1.280,24.167 ;
                  DEFAULT 0 ;
                  FONT "MS Sans Serif", 8 ;
                  STYLE "BT"
      endfor
      for D = (BETWN2+1) to NO_SUBJ step 1
            @ (1.200+(D-BETWN2)*1.274),46.320 GET arra4[D];
                  PICTURE ("@*C "+ alltrim(arra3b[D,1]));
                  SIZE 1.280,24.167 ;
                  DEFAULT 0 ;
                  FONT "MS Sans Serif", 8 ;
                  STYLE "BT"
      endfor
      
      @ 1.200+(no_subj - BETWN2 +1)*1.274,46.320 GET arra4[no_subj +1];
            PICTURE "@*C SELECT/UNSELECT ALL";
            SIZE 1.280,24.167 ;
            DEFAULT 0 ;
            FONT "MS Sans Serif", 8 ;
            STYLE "BT";
            VALID _R1()
            
      @ 22.5,25 get mbut1;
            picture "@*HN OK";
            size 2,12,1;
            DEFAULT 1;
            style "B";
            valid _r2()
      @ 22.5,49 get mbut2;
            picture "@*HN CANCEL";
            size 2,12,1;
            DEFAULT 1;
            style "B";
            valid _r3()
                  
      ACTIVATE WINDOW ANA_MSG
      read cycle WITH ANA_MSG
endif                                                      
release window ana_msg
release arra3b
release arra4
SHOW WINDOW SCH_EXAM

FUNCTION _R1
if arra4[no_subj +1] = 1
      for d = 1 to no_subj
            arra4[d] = 1
      endfor
      show gets
ELSE
      for d = 1 to no_subj
            arra4[d] = 0
      endfor
      show gets
endif

FUNCTION _R2
gf_break = .f.
SELECT ANALY2
DELETE FILE (hdpath+"\temp\IN.idx")
index on subject+class to (hdpath+"\temp\IN.idx")
FOR FET = 1 TO (alen(arra4,1)-1) STEP +1
      if gf_break = .t. && break the continuous analysis
            exit
      endif
      if arra4[fet] = 1
            SET FILTER TO alltrim(analy2.subject) == alltrim(arra3b[FET,1])
            go top
            store 0 to m1,m2,m3,m4,m5,m6,m7,m8,m9
            ex_title = MYEAR00+" "+EXAM_TIT
            an_title = "ANALYSIS OF SEC "+MLVL00+" "+ALLTRIM(ARRA3B[FET,1])
            HIDE WINDOW ANA_MSG
            if prt_prev = 1
                  report form hdpath+"report\S_sub_IN.frx" NOEJECT NOCONSOLE preview
            else
                  report form hdpath+"report\S_sub_IN.frx" NOEJECT NOCONSOLE to printer
            endif
            SHOW WINDOW ANA_MSG
            SET FILTER TO
            GO TOP
      endif
ENDFOR            
SELECT ANALY2
SET INDEX TO
DELETE FILE (hdpath+"\temp\IN.idx")

FUNCTION _R3
clear read

But when this code runs in vfp 9.0, the controls  (checkboxes, labels and buttons) on the screen are display initially but once I moved the mouse, all the controls disappear. Only when the mouse is over the control will that individual control reappear and disappear again when the mouse is moved away. Other functionality seems to be working though.

Is there a way to fix this?

Alternatively, is there a way to create new form and within it checkboxes, labels and buttons and functions in a prg file that can work in vfp 9.0 without a hitch?

Comment
Watch Question

Founder, Software Engineer, Data Scientist
Commented:
If you are using Vista then you will be in for surprises.

In VFP 3.0 to 9.0 the correct way of doing this is:

oForm = CREATEFORM("Form")

But instead of doing it programatically, you create a form using the interface. It takes much less code than what you have posted.

If you need a number of checkboxes depending on code, then you can create a grid and put the checkboxes inside the columns of the grid.

Check solutions.app that ships with VFP 9.0. It's in Task Manager/Samples.

Author

Commented:
Hope it was a full ans without the need for more research. Nevertheless thanks for the lead.
The code is not 3.0 but 2.0 and the reason why to switch to 9.0 should namely be new OO controls usage. VFP 9 isn't so backward compatible as you would suppose and I think it is correct because it will force you to use better programming techniques... :-)

BTW, your code works in VFP 6.

The fix for VFP 9 is easy: Add SHOW GETS command before the READ CYCLE command.
CaptainCyrilFounder, Software Engineer, Data Scientist

Commented:
VFP 9.0 is backward compatible with very minor fixes.

If you are using Vista, then it's a different ball game. Code from 6.0 would not work well because of this Aero interface.