Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Function to simulate grid or Browse command
Message
From
06/02/2017 19:56:18
 
 
To
06/02/2017 11:20:16
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
FoxPro 2.x
Miscellaneous
Thread ID:
01647591
Message ID:
01647649
Views:
62
>>I'm maintaining an old FoxPro system
>>
>>One of the modifications needs me to put a browse-like list showing récords from one or more related tables. I have used BROWSE before but The system itself in other programa uses another routine which I feel veryslow and is very long and not documentos.
>>
>>Can anybody help me?
>>
>>TÍA
>>
>>Luis Guerra
>
>What is wrong with BROWSE on fox2x? It is fast. What is your exact question?

Normally BROWSE windows want to reside in their own window, and trying to get it to behave like a grid control from VFP can't (normally) be done. However with a bit of sleight of hand, you can give the *appearance* that it is. To illustrate here's an ASCII graphic diagram of the general idea:
+-----A----------------+
| +-------C----------+ |
| |+----B-----------+| |
| ||                || |
| ||                || |
| ||                || |
| |+----------------+| |
| +------------------+ |
| +-----D------------+ |
| |  <OK> <Cancelt>  | |
| +------------------+ |
+----------------------+
"A" is the form within the application where you want the "grid" to appear. "B" and "D" are child windows of "A" with "D" set up to have NO borders. Window "C" is actually a child window of "B" with its boundaries lying outside of the boundaries of "B" and this is where we open the BROWSE window (only the portion of "C" that is visible within "B" will appear -- essentially we're using "B" to trim off the borders off the BROWSE window). On child window "D" we place the form controls (in this diagram, I've got two command buttons "OK" and "Cancel"). The reason for introducing "D" is so that the "grid" stays visible (if a control placed on "A" gets focus, the child windows of "A" will momentarily disappear -- by putting the controls o another child, we're able to keep the "grid" visible). The last bit is a bunch of ON KEY traps to further the illusion that the BROWSE window is a grid.
In DOS the positioning and sizing of the child windows is relatively straightforward -- it gets a bit more involved when dealing with FoxPro Windows since size of border could vary according to how the Windows UI is configured. It's also a bit tricky since coordinate system in FoxPro Windows is in terms of "foxels" and not "pixels" (so you'll have to do conversions between the units).

code for the SPR generated using GENSCRNX.PRG:

* wG3List is the window for this form.
* wG3Clip is a child of wG3List and acts as a "clipping region"
* wG3Ctl is a child of wG3List and this is where the "Accept" and "Quit" buttons reside
* wBrw is a child window of wG3Clip -- we start the BROWSE window using configuration of this window.
*       ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ?
*       ?                                                        ?
*       ?05/13/1996            G3LIST.SPR               12:37:24 ?
*       ?                                                        ?
*       ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ?
*       ?                                                        ?
*       ?Frank Su, Zon Jan                                       ?
*       ?                                                        ?
*       ?Copyright (c) 1996 Jantek Electronics, Inc.             ?
*       ?400 S. Victory Blvd                                     ?
*       ?Burbank, CA  91502                                      ?
*       ?                                                        ?
*       ?Description:                                            ?
*       ?This program was automatically generated by GENSCRN.    ?
*       ?                                                        ?
*       ÓÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ?

PARAMETERS xarea,ng3

*       ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ?
*       ?                                                        ?
*       ?          G3LIST/Windows Setup Code - SECTION 1         ?
*       ?                                                        ?
*       ÓÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ?
*

#REGION 1
*-:NOSCNOBJ
*-:SET PLATONLY ON
PRIVATE nOrgArea,cOrgOrder,lOpenTemp,nOrgRec
** Start of inserted file SOURCE\WINDEFS.INC ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄstart
#DEFINE BASE_FONT "FOXFONT",9
#DEFINE TXT_H      FontMetric(1,BASE_FONT)
#DEFINE TXT_Asc    FontMetric(2,BASE_FONT)
#DEFINE TXT_Dec    FontMetric(3,BASE_FONT)
#DEFINE TXT_Ld     FontMetric(4,BASE_FONT)
#DEFINE TXT_AveW   FontMetric(6,BASE_FONT)
#DEFINE TXT_MinW   FontMetric(7,BASE_FONT)
#DEFINE TITLE_H    SysMetric(9)
#DEFINE VSCRL_W    SysMetric(5)
#DEFINE HSCRL_H    SysMetric(8)
#DEFINE DETAIL_H   (FontMetric(1,BASE_FONT)+3)

** End of inserted file SOURCE\WINDEFS.INC ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄend

#DEFINE MAIN_WIN "WG3LIST"
#DEFINE CLIP_WIN "WG3CLIP"
#DEFINE CTL_WIN  "WG3CTL"
#DEFINE BRW_WIN  "G3_BROWSE"

nOrgArea = Select(0)

lOpenTemp = Empty(m.xArea)
IF m.lOpenTemp
    SELECT 0
    USE DBF.JTA\Dept AGAIN ORDER Dept
    xArea = Alias()
ELSE
    SELECT (m.xArea)
    cOrgOrder = Order()
    nOrgRec = RecNo()
    SET ORDER TO Dept
    GOTO TOP
ENDIF

IF Type("nG3")#"N"
    nG3 = 1
ENDIF

DO G3Read

IF m.lOpenTemp
    SELECT (m.xArea)
    USE
ELSE
    IF m.nG3#-1
        =NearSeek(m.nG3)
    ELSE
        IF Between(m.nOrgRec,1,RecCount())
            GOTO (m.nOrgRec)
        ELSE
            GOTO BOTTOM
        ENDIF
    ENDIF
    SET ORDER TO &cOrgOrder
ENDIF

SELECT (m.nOrgArea)

RETURN


FUNCTION G3Read
*++
* The code for this function is generated by GENSCRN. It is
* called under control of the Winlib function wModalRead. It
* issues the GETs and executes the READ.
*--
    PRIVATE cWinTitle

    cWinTitle = _G3_Desc+" List"
*-:NOWCLAUSES TITLE


#REGION 0
REGIONAL m.currarea, m.talkstat, m.compstat

IF SET("TALK") = "ON"
	SET TALK OFF
	m.talkstat = "ON"
ELSE
	m.talkstat = "OFF"
ENDIF
m.compstat = SET("COMPATIBLE")
SET COMPATIBLE FOXPLUS

m.rborder = SET("READBORDER")
SET READBORDER OFF

*       ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ?
*       ?                                                        ?
*       ?              Windows Window definitions                ?
*       ?                                                        ?
*       ÓÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ?
*

IF NOT WEXIST("wG3List") ;
	OR UPPER(WTITLE("wG3List")) == "wG3List.PJX" ;
	OR UPPER(WTITLE("wG3List")) == "wG3List.SCX" ;
	OR UPPER(WTITLE("wG3List")) == "wG3List.MNX" ;
	OR UPPER(WTITLE("wG3List")) == "wG3List.PRG" ;
	OR UPPER(WTITLE("wG3List")) == "wG3List.FRX" ;
	OR UPPER(WTITLE("wG3List")) == "wG3List.QPR"
	DEFINE WINDOW wG3List ;
		AT  0.000, 0.000  ;
		SIZE 17.867,50.800 ;
		FONT "Arial", 9 ;
		FLOAT ;
		NOCLOSE ;
		NOMINIMIZE ;
		SYSTEM ;
		COLOR RGB(,,,192,192,192) ;
		TITLE (M.CWINTITLE)
	MOVE WINDOW wG3List CENTER
ENDIF


*       ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ?
*       ?                                                        ?
*       ?          G3LIST/Windows Setup Code - SECTION 2         ?
*       ?                                                        ?
*       ÓÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ?
*

#REGION 1


*****************************************************************
*           This program was preprocessed by GENSCRNX.
*
*--GENSCRNX  2.0
*--Platform  FoxPro 2.6 for Windows
*--Screen    d:\jtawin.821\screens\g3list.scx
*--Project   d:\jtawin.821\mg_emp\mg_emp.pjx
*--FOXSCX    C:\FPW\FOXSCX.DBF
*--Time      05/13/1996 12:37:21
*
*****************************************************************
*-:All3D

SET READBORDER OFF

*       ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ?
*       ?                                                        ?
*       ?              G3LIST/Windows Screen Layout              ?
*       ?                                                        ?
*       ÓÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ?
*

#REGION 1
IF WVISIBLE("wG3List")
	ACTIVATE WINDOW wG3List SAME
ELSE
	ACTIVATE WINDOW wG3List NOSHOW
ENDIF
X_Scale = FontMetric(6,"FoxFont",9, ;
                     "N") ;
          / FontMetric(6,wFont(1,MAIN_WIN),wFont(2,MAIN_WIN))

DEFINE WINDOW (CLIP_WIN) IN (MAIN_WIN) ;
    FROM 0.533,1.8 ;
    SIZE 18,29.75;
    FONT "FoxFont",9 ;
    STYLE "N"

ACTIVATE WINDOW (MAIN_WIN) NOSHOW     
**
** PushButton-in-a-window
**
X_Scale = FontMetric(6,"Arial",9, ;
                     "B") ;
          / FontMetric(6,wFont(1,MAIN_WIN),wFont(2,MAIN_WIN))

*** WAIT WINDOW "Scaling factor (X): "+Str(X_Scale,10,4)

ACTIVATE WINDOW (MAIN_WIN) NOSHOW

*** @ 15.533,0 TO 15.533,wCols()
*** @ 17.4,0 TO 17.4,wCols()

*** LftBdr = 11.6
*** FOR I=0 TO 1
***     @ 0,m.LftBdr TO wRows(),m.LftBdr
***     @ 0,m.LftBdr+10.167*m.X_Scale ;
***         TO wRows(),m.LftBdr+10.167*m.X_Scale
***     LftBdr = m.LftBdr + 13.5*m.X_Scale
*** NEXT

DEFINE WINDOW (CTL_WIN) IN (MAIN_WIN) NONE ;
    FROM 15.533,11.6 ;
    SIZE 1.867,(23.667 ;
                     *FontMetric(6,"Arial",9, ;
                                  "B")-0) ;
                    / FontMetric(6,wFont(1,MAIN_WIN),wFont(2,MAIN_WIN)) ;
    FONT wFont(1,MAIN_WIN), wFont(2,MAIN_WIN) ;
    STYLE wFont(3,MAIN_WIN) ;
    COLOR Rgb(0,0,0,192,192,192)

ACTIVATE WINDOW (CTL_WIN)

** Button parameters: (Height,Width,Spacing):1.867,10.167,3.333
** Button count: 2
** Button cluster width: 23.667

@ 0,0 GET m.o_Action ;
    PICTURE "@*HT Accept;Quit" ;
    SIZE 1.867,10.167,3.333 ;
    DEFAULT 1 ;
    FONT "Arial",9 ;
    STYLE "B" ;
    VALID Action(o_Action)

@ 0,0 GET xDummy DEFAULT 0 ;
    PICTURE "@*I" ;
    SIZE wRows(),wCols() ;
    WHEN MDown() ;
    VALID GoBrowse()

SHOW WINDOW (MAIN_WIN)
SHOW WINDOW (CTL_WIN)     
*-#SECTION 3

_Brw_Lft = 0
_Brw_Rgt = wCols(CLIP_WIN)-VSCRL_W/TXT_H
_Brw_Top = 0
_Brw_Bot = wRows(CLIP_WIN)

DEFINE WINDOW wBrw IN (CLIP_WIN) ;
    AT -TITLE_H/TXT_H,-1 ;
    SIZE wRows(CLIP_WIN)-2/TXT_H,wCols(CLIP_WIN)-VSCRL_W/TXT_H;
    FONT wFont(1,CLIP_WIN),wFont(2,CLIP_WIN) NOCLOSE NOZOOM FLOAT

ACTIVATE WINDOW (CLIP_WIN)

=NearSeek(m.nG3)
IF .NOT. Bof()
    SKIP -7
ENDIF
BROWSE WINDOW wBrw IN (CLIP_WIN) ;
    FONT wFont(1,CLIP_WIN),wFont(2,CLIP_WIN) ;
    FIELDS X=Space(4)+Str(Dept,5)+"   "+Desc:27 ;
            :H=PadR(Chr(255)+PadR(_G3_Desc,9)+"  Description",27)+Chr(255) ;
    TITLE BRW_WIN ;
    NORGRID NOEDIT NOAPPEND NODELETE NOMENU NOWAIT
RELEASE WINDOW wBrw
=NearSeek(m.nG3)

** ON KEY LABEL ALT+B ACTIVATE WINDOW (BRW_WIN)
** KEYBOARD "{ALT+B}"

lChkDbl = .F.
nLoc = -1
DblClick=60
nLastClick = -86400

PUSH KEY CLEAR
ON KEY LABEL ALT+F12 ACTIVATE WINDOW (BRW_WIN)
ON KEY LABEL ENTER xJunk=Iif(Program()="ACTION",0,Action(1))
ON KEY LABEL CTRL+ENTER xJunk=Iif(Program()="ACTION",0,Action(1))
ON KEY LABEL CTRL+W xJunk=Iif(Program()="ACTION",0,Action(1))
ON KEY LABEL CTRL+Q xJunk=Iif(Program()="ACTION",0,Action(2))
ON KEY LABEL ESC xJunk=Iif(Program()="ACTION",0,Action(2))
ON KEY LABEL LEFTMOUSE xJunk = Iif(Program()="G3READ", Squeak(CLIP_WIN),.F.)
DO GoBrowse

ACTIVATE WINDOW (MAIN_WIN)     

IF NOT WVISIBLE("wG3List")
	ACTIVATE WINDOW wG3List
ENDIF


*       ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ?
*       ?                                                        ?
*       ?   WindowsREAD contains clauses from SCREEN   G3LIST    ?
*       ?                                                        ?
*       ÓÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ?
*

READ CYCLE ;
	WITH (MAIN_WIN),(CLIP_WIN),(BRW_WIN),(CTL_WIN)

RELEASE WINDOW wG3List

#REGION 0

SET READBORDER &rborder

IF m.talkstat = "ON"
	SET TALK ON
ENDIF
IF m.compstat = "ON"
	SET COMPATIBLE ON
ENDIF


*       ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ?
*       ?                                                        ?
*       ?               G3LIST/Windows Cleanup Code              ?
*       ?                                                        ?
*       ÓÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ?
*

#REGION 1
POP KEY

RELEASE WINDOW (CTL_WIN)
RELEASE WINDOW (CLIP_WIN)
RELEASE WINDOW (MAIN_WIN)

RETURN



*       ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ?
*       ?                                                        ?
*       ?   G3LIST/Windows Supporting Procedures and Functions   ?
*       ?                                                        ?
*       ÓÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ?
*

#REGION 1
FUNCTION Action
    PARAMETERS nOpt

    ACTIVATE WINDOW (CTL_WIN)
    nG3 = Iif(m.nOpt==2, -1, Dept)
    CLEAR READ
RETURN

FUNCTION GoBrowse
    KEYBOARD "{RIGHTARROW}{ALT+F12}"
RETURN .T.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform