Page 2 of 3
Re: HMG-specific GRID syntax help needed
Posted: Mon Dec 09, 2019 9:00 pm
by Red2
Hi All,
Thank you for you suggestions. Unfortunately there is still a (blank) grid display issue of some kind.
To recap:
1) The grid’s code in the .FMG is now more simplified
(see below).
2) Verified: The .DBF is opened prior to “ACTIVATE WINDOW ” with GOTO TOP.
3) Verified: The .DBF is the work area’s current alias according to:
----Debugger
----Vertical (row) grid navigation occurs.
----Row navigation perfectly reflects the RECCOUNT().
----The ALIAS() is displayed by textbox “Text_1”
4) Page “Page 1” is NOT readonly because textbox “Text_1” displays the alias.
5) The HMG help file lists two grid control syntaxes, “Standard Syntax (xBase Style)” and “Alternate Syntax”. I am using “Alternate Syntax” with no semicolons at line’s end.
Code: Select all
DEFINE TAB pgf_ItemsStates AT 40 , 30 WIDTH 820 HEIGHT 430 VALUE 1 FONT "Arial" SIZE 9 TOOLTIP "" ON CHANGE Nil MULTILINE
PAGE "Page 1"
DEFINE GRID grd_Items
ROW 50
COL 40
WIDTH 740
HEIGHT 300
VALUE 1
WIDTHS { 150, 150 }
HEADERS { "Mfg. Name", "Type" }
ROWSOURCE "All_Items"
COLUMNFIELDS {"All_Items->MFG_NAME", "All_Items->TYPE"}
END GRID
DEFINE TEXTBOX Text_1
ROW 370
COL 50
WIDTH 230
HEIGHT 25
FONTNAME "Arial"
VALUE "Value: " +chr(34)+alias()+chr(34)+ " (is the ALIAS)"
END TEXTBOX
END PAGE
PAGE "Page 2"
END PAGE
END TAB
I am STUCK and a bit frustrated! What am I missing? There must be something obvious being overlooked!
I am really grateful for all of your kind help. Once again, any further ideas would most appreciated.
Red2
Re: HMG-specific GRID syntax help needed
Posted: Mon Dec 09, 2019 11:43 pm
by AUGE_OHR
hi,
next try : you 1st Line seems different to my
Code: Select all
DEFINE TAB pgf_ItemsStates AT 40 , 30 WIDTH 820 HEIGHT 430 VALUE 1 FONT "Arial" SIZE 9 TOOLTIP "" ON CHANGE Nil MULTILINE
seems you work on TAB Page not on WINDOW ...
Code: Select all
DEFINE WINDOW TEMPLATE AT 371 , 616 WIDTH 466 HEIGHT 561 VIRTUAL WIDTH Nil VIRTUAL HEIGHT Nil TITLE "" ICON NIL CURSOR NIL ON INIT OpenDbfReply() ON RELEASE CloseDbfReply() ON INTERACTIVECLOSE Nil ON MOUSECLICK Nil ON MOUSEDRAG Nil ON MOUSEMOVE Nil ON SIZE Nil ON MAXIMIZE Nil ON MINIMIZE Nil ON PAINT Nil BACKCOLOR {0,0,0} NOTIFYICON NIL NOTIFYTOOLTIP NIL ON NOTIFYCLICK Nil ON GOTFOCUS Nil ON LOSTFOCUS Nil ON SCROLLUP Nil ON SCROLLDOWN Nil ON SCROLLLEFT Nil ON SCROLLRIGHT Nil ON HSCROLLBOX Nil ON VSCROLLBOX Nil
i'm still a harbour / HMG Newbie but as i understand FMG is a TEMPLATE which is missing in your Code
i have look for VALUE in my Code and it was NIL at Start
---
try a small Demo with WINDOW if it work, than you can try TAB again.
hope it help
have fun
Re: HMG-specific GRID syntax help needed
Posted: Tue Dec 10, 2019 12:21 am
by Red2
Thank you Jimmy,
I really appreciate your help. As for the pages (code) in my last post, it is not really relevant to the issue. That is, whether the grid is on a page or not, the grid does not display the .DBF's records. In both cases grid rows are all blank/empty.
In my last post I did not include my "DEFINE WINDOW" code but it is actually there in my .FMG. It was generated by the IDE and is not interesting (unless I am missing something).
Code: Select all
DEFINE WINDOW TEMPLATE AT 151 , 313 WIDTH 891 HEIGHT 593 VIRTUAL WIDTH Nil VIRTUAL HEIGHT Nil TITLE "View/Edit Data" ICON NIL MODAL NOSIZE CURSOR NIL ON INIT ItemsBrowse_Frm_OnInit() ON RELEASE ItemsBrowse_Frm_OnRelease() ON INTERACTIVECLOSE Nil ON MOUSECLICK Nil ON MOUSEDRAG Nil ON MOUSEMOVE Nil ON SIZE Nil ON PAINT Nil BACKCOLOR Nil ON GOTFOCUS Nil ON LOSTFOCUS Nil ON SCROLLUP Nil ON SCROLLDOWN Nil ON SCROLLLEFT Nil ON SCROLLRIGHT Nil ON HSCROLLBOX Nil ON VSCROLLBOX Nil
...
... // (See my previous post's code)
...
END WINDOW
I should mention that both
"ItemsBrowse_Frm_OnInit()" and
" ItemsBrowse_Frm_OnRelease()" are just empty stubs for now.
Still stuck but I am sure someone can explain my error or omission! Thanks again everyone for your most generous help.
Red2
Re: HMG-specific GRID syntax help needed
Posted: Tue Dec 10, 2019 2:56 am
by AUGE_OHR
Red2 wrote: ↑Tue Dec 10, 2019 12:21 am
I should mention that both
"ItemsBrowse_Frm_OnInit()" and
" ItemsBrowse_Frm_OnRelease()" are just empty stubs for now.
hm ... perhaps is "that" the Problem
yes, i know you have check it but you can re-open it just before load FMG
Code: Select all
PROCEDURE Choise_TO()
IF !IsWindowDefined( ReplayTo )
IF OpenDbfReply()
cTOwho := "TO"
Load Window ReplayTo
ON KEY ESCAPE OF ReplayTo ACTION ReplayTo.Release
ON KEY RETURN OF ReplayTo ACTION Save_To()
ON KEY DELETE OF ReplayTo ACTION DelReplay()
CENTER WINDOW ReplayTo
Activate Window ReplayTo
CloseDbfReply()
ELSE
MsgInfo("Error open REPLYTO.DBF")
ENDIF
ENDIF
RETURN
Code: Select all
FUNCTION OpenDbfReply()
LOCAL lRet := .T.
SELECT 3
USE REPLYTO.DBF ALIAS REPLYTO EXCLUSIVE
IF NETERR()
lRet := .F.
ELSE
SET INDEX TO REPLYTO.CDX
ENDIF
RETURN lRet
Code: Select all
PROCEDURE CloseDbfReply()
SELECT 3
CLOSE
SELECT 1
RETURN
Re: HMG-specific GRID syntax help needed
Posted: Tue Dec 10, 2019 3:36 am
by andyglezl
Parecerá tontería, pero ya checaste que los colores que estas usando no son WHITE / WHITE ?
*-----------------------------------------------------------------------------------------------------------------------
It will seem silly, but have you checked that the colors you are using are not WHITE / WHITE ?
Sin ver tu ejemplo funcional, es estar adivinando...
*----------------------------------------------------------------
Without seeing your functional example, it's being guessing ...
Re: HMG-specific GRID syntax help needed
Posted: Tue Dec 10, 2019 3:27 pm
by Red2
Thank you Jimmy and Andyglezl. I really appreciate all of your kind help!
1) The button that calls the .FMG (with the grid) selects the .DBF immediately before calling the form.
(Please see code below).
----The work area should be correctly set, no?
----Based on the grid’s navigation accurately reflecting the RECCOUNT() I do not see how the RowSource is set wrong.
Code: Select all
#include "hmg.ch"
declare window ItemsBrowse
function main_Btn_ItemsBrowse_Action()
******************
select "All_Items"
goto top
******************
if ( isWindowActive( ItemsBrowse ) )
doMethod( "ItemsBrowse", "Minimize" )
doMethod( "ItemsBrowse", "Restore" )
doMethod( "ItemsBrowse", "SetFocus" )
else
load window ItemsBrowse
ItemsBrowse.Center
ItemsBrowse.Activate
endif
Return Nil
2) It is
not silly to question the grid’s FontColor. I changed the grid's FontColor from Nil (the default) to
{0,0,0). The grid still displays rows blank/empty. I believe we can rule out FontColor.
What am I overlooking???
Thanks again,
Red2
Re: HMG-specific GRID syntax help needed
Posted: Tue Dec 10, 2019 5:56 pm
by ROBROS
Hi Red,
in your code should be defined 1 (one) main window.
In your code you define a "main function", but there is no "main window" within "function main"
Robert
Re: HMG-specific GRID syntax help needed
Posted: Tue Dec 10, 2019 7:25 pm
by Red2
Hi All,
Interesting Fact:
If I simply substitute "my" grid for the "sample" grid in
"P:\HMG.3.4.4\SAMPLES\Basics\TUTORIAL\Tutor20.PRG" my .DBF data displays
perfectly!
This tells me that "my" grid is not the problem. Something
else is certainly the cause!
In my program the cause is
not the "tab pages" because my grid still is blank when the pages are remove and (the grid) is placed
directly onto the form.
QUESTION: Can those of you more experienced in HMG/Harbour explain what "blanks" a grid??? I am very baffled!
Thank you,
Red2
Here I just open "my" .DBF. and increase the size of the window to hold "my" grid. My .DBF has 8 type character fields.
Code: Select all
// P:\HMG.3.4.4\SAMPLES\Basics\TUTORIAL\Tutor20.PRG
// I simply substitute my grid and .DBF
#include "hmg.ch"
***************
Function Main
OpenTables()
DEFINE WINDOW Win_1 ;
AT 0,0 ;
WIDTH 1000 HEIGHT 500 ;
TITLE 'Tutor 20: GRID Test' ;
MAIN NOMAXIMIZE
DEFINE MAIN MENU
POPUP 'File'
ITEM 'Set Grid RecNo' ACTION Win_1.Grid_1.Value := Val ( InputBox ('Set Grid RecNo','') )
ITEM 'Get Grid RecNo' ACTION MsgInfo ( Str ( Win_1.Grid_1.RecNo ) )
SEPARATOR
ITEM 'Exit' ACTION Win_1.Release
END POPUP
POPUP 'Help'
ITEM 'About' ACTION MsgInfo ("Tutor 20: GRID Test")
END POPUP
END MENU
// @ 10,10 GRID Grid_1 ;
// WIDTH 610 ;
// HEIGHT 390 ;
// HEADERS { 'Code' , 'First Name' , 'Last Name', 'Birth Date', 'Married' , 'Biography' } ;
// WIDTHS { 150 , 150 , 150 , 150 , 150 , 150 } ;
// ROWSOURCE "Test" ;
// COLUMNFIELDS { 'Code' , 'First' , 'Last' , 'Birth' , 'Married' , 'Bio' } ;
// COLUMNCONTROLS {{'TEXTBOX','NUMERIC','999'},{'TEXTBOX','CHARACTER'},{'TEXTBOX','CHARACTER'},{'TEXTBOX','DATE'},{'CHECKBOX'},{'TEXTBOX','CHARACTER'}};
// ALLOWDELETE ;
// EDIT
DEFINE GRID Grid_1 // My grd_Items is renamed here to: Grid_1
ROW 10
COL 20
WIDTH 950
HEIGHT 400
VALUE 1
WIDTHS { 150, 150, 90, 100, 150, 100, 100, 150 }
HEADERS {"Mfg. Name", "Type", "Serviceable", "Descr.", "Model", "Length", "OAL", "Serial Nbr"}
FONTNAME "Arial"
FONTSIZE 9
TOOLTIP ""
ONCHANGE Nil
ONGOTFOCUS Nil
ONLOSTFOCUS Nil
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
ONDBLCLICK Nil
ONHEADCLICK Nil
ONQUERYDATA Nil
MULTISELECT .F.
ALLOWEDIT .F.
VIRTUAL .F.
DYNAMICBACKCOLOR Nil
DYNAMICFORECOLOR Nil
COLUMNWHEN Nil
COLUMNVALID Nil
COLUMNCONTROLS Nil
SHOWHEADERS .T.
CELLNAVIGATION .F.
NOLINES .F.
HELPID Nil
IMAGE Nil
JUSTIFY Nil
ITEMCOUNT Nil
BACKCOLOR NIL
FONTCOLOR {0,0,0}
HEADERIMAGES Nil
ROWSOURCE "All_Items"
COLUMNFIELDS {"MFG_NAME", "TYPE", "SERVICEABL", "DESCR", "MODEL", "LENGTH", "OAL", "SERIAL_NBR"}
ALLOWAPPEND .F.
ALLOWDELETE .F.
BUFFERED .F.
DYNAMICDISPLAY .F.
ONSAVE Nil
LOCKCOLUMNS 0
END GRID
END WINDOW
CENTER WINDOW Win_1
ACTIVATE WINDOW Win_1
Return Nil
*************************
Procedure OpenTables()
REQUEST DBFCDX, DBFFPT
RDDSETDEFAULT ("DBFCDX")
USE ( "P:\HMG\All_Items.DBF" ) exclusive NEW
set index to "P:\HMG\All_Items.CDX"
set order to 1
goto top
Return Nil
Re: HMG-specific GRID syntax help needed
Posted: Wed Dec 11, 2019 9:35 am
by ROBROS
Hi Red,
I send you a simple grid example, I left out the properties I do not need. See attached zip-file. Maybe it helps you.
Robert
Re: HMG-specific GRID syntax help needed
Posted: Wed Dec 11, 2019 10:46 am
by AUGE_OHR
Red2 wrote: ↑Tue Dec 10, 2019 7:25 pm
Here I just open "my" .DBF. and increase the size of the window to hold "my" grid. My .DBF has 8 type character fields.
Code: Select all
// @ 10,10 GRID Grid_1 ;
// WIDTH 610 ;
// HEIGHT 390 ;
// HEADERS { 'Code' , 'First Name' , 'Last Name', 'Birth Date', 'Married' , 'Biography' } ;
// WIDTHS { 150 , 150 , 150 , 150 , 150 , 150 } ;
// ROWSOURCE "Test" ;
// COLUMNFIELDS { 'Code' , 'First' , 'Last' , 'Birth' , 'Married' , 'Bio' } ;
// COLUMNCONTROLS {{'TEXTBOX','NUMERIC','999'},{'TEXTBOX','CHARACTER'},{'TEXTBOX','CHARACTER'},{'TEXTBOX','DATE'},{'CHECKBOX'},{'TEXTBOX','CHARACTER'}};
// ALLOWDELETE ;
// EDIT
what is with that Code
does it not work
try again and strip
Code: Select all
COLUMNCONTROLS {{'TEXTBOX','NUMERIC','999'},{'TEXTBOX','CHARACTER'},{'TEXTBOX','CHARACTER'},
ALLOWDELETE ;
EDIT
Red2 wrote: ↑Tue Dec 10, 2019 7:25 pm
Code: Select all
DEFINE GRID Grid_1 // My grd_Items is renamed here to: Grid_1
strip all to minimum
Code: Select all
DEFINE GRID Grid_1 // My grd_Items is renamed here to: Grid_1
ROW 10
COL 20
WIDTH 950
HEIGHT 400
WIDTHS { 150, 150, 90, 100, 150, 100, 100, 150 }
HEADERS {"Mfg. Name", "Type", "Serviceable", "Descr.", "Model", "Length", "OAL", "Serial Nbr"}
ROWSOURCE "All_Items"
COLUMNFIELDS {"MFG_NAME", "TYPE", "SERVICEABL", "DESCR", "MODEL", "LENGTH", "OAL", "SERIAL_NBR"}
END GRID
END WINDOW
if it work you can add "more"
---
while i had Problem with GRID and
Code: Select all
DYNAMICBACKCOLOR Nil
DYNAMICFORECOLOR Nil
i have try BROWSE ( NOT Browse() ) which is also a WC_LISTVIEW ( = GRID )
BROWSE have
Code: Select all
WIDTHS {200,200}
HEADERS {"Reply To","From"}
WORKAREA REPLYTO
FIELDS {"REPLYTO->REPLYTO" , "REPLYTO->FROM"}
benefit of BROWSE : it have
what does it mean :
when load data from DBF into GRID it will IHMO not move Pointer in DBF when navigate in GRID.
when look into c:\hmg.3.4.4\SOURCE\h_browse.prg and search for "BROWSESYNC" you will find this
Code: Select all
Procedure _BrowseSync (i)
Local _Alias
Local _BrowseArea
Local _RecNo
Local _CurrentValue
If _HMG_SYSDATA [ 254 ] == .T.
_Alias := Alias()
_BrowseArea := _HMG_SYSDATA [ 22 ] [i]
If Select (_BrowseArea) == 0
Return
EndIf
Select &_BrowseArea
_RecNo := RecNo()
_CurrentValue := _BrowseGetValue ( '' , '' , i )
If _RecNo != _CurrentValue
Go _CurrentValue
EndIf
if Select( _Alias ) != 0
Select &_Alias
Else
Select 0
Endif
EndIf
Return
i do not found something like this in GRID so for DBF i "think" BROWSE is better Way with "SET BROWSESYNC ON"