vscrollbar not activated message
Posted: Mon Mar 20, 2017 6:49 pm
Mentors
The program below is a convenience routine that I use to test ideas and to learn how things work. The matrix demonstration triggered by the DO SOMETHING button works, but the background and foreground matrix colors will only appear after I touch a scrollbar.
1. Why is this the case, I expected to see the Background and font colors right away
2. The msgbox appears to confirm that the scrollbar is active, but the lines 111 and 122 had to be commented out because error messages appear to say that the vscrollbar is not defined.
3. How do I tell the virtual window to scroll to a desired row?
Here is the entire code. I left line 122 uncommented so that you see the error message. If you put the "//" back
you can see the program work, showing the color delay problem.
The program below is a convenience routine that I use to test ideas and to learn how things work. The matrix demonstration triggered by the DO SOMETHING button works, but the background and foreground matrix colors will only appear after I touch a scrollbar.
1. Why is this the case, I expected to see the Background and font colors right away
2. The msgbox appears to confirm that the scrollbar is active, but the lines 111 and 122 had to be commented out because error messages appear to say that the vscrollbar is not defined.
3. How do I tell the virtual window to scroll to a desired row?
Here is the entire code. I left line 122 uncommented so that you see the error message. If you put the "//" back
you can see the program work, showing the color delay problem.
Code: Select all
/*
* HMG General Test Routine
*
*/
// Usefull string "("+alltrim(str(j))+","+ alltrim(str(k))+")" //cBlankInput
#include "hmg.ch"
#include "defines.ch"
#include "MatrixHdr.ch"
#define NEWLINE 13
#define DODGERBLUE {28,134,248}
#define LIGHTGOLDENROD {238 ,221 ,130 }
#define MAROON {238 ,48 ,100 }
#define COBALT1 {0,71,171}
#define COBALT2 {61,82,200}
* Set of define constants for gentest matrix draw demo
*
* nRow1,nCol1,nRowSpc,nColSpc,nWidth,nHeight,nFontSz,aBackColor ,aFontColor,cWindow
*
#define ROW1 1
#define COL1 2
#define ROWSPC 3
#define COLSPC 4
#define CELLWIDTH 5
#define CELLHEIGHT 6
#define FONTSZ 7
#define BACKCOLOR1 8
#define FONTCOLOR1 9
#define TITLEROW 10
#define TITLEHEIGHT 11
#define CODEBLOCK1 12
#define WINFORM 13
#define LABELVALUE 14
#define LABELNAME 15
#define LOOPFUNCTNS 16
#define MTITLE 17
#define HDRFONTNAME 18
#define LABELFONTNAME 19
*-----------------------------
Function Main
*-----------------------------
Local l2Tests:=.t.
LOCAL aTestArray:=array(4)
SET AUTOSCROLL ON
DEFINE WINDOW Win_1 ;
ROW 10 ;
COL 10 ;
WIDTH 750 ;
HEIGHT 650 ;
VIRTUAL WIDTH 1000 ;
VIRTUAL HEIGHT 750 ;
BACKCOLOR {12,130,55} ;
TITLE 'A General Test Form!' ;
WINDOWTYPE MAIN
END WINDOW
ON KEY Escape of Win_1 ACTION {||(Win_1.release)}
Define BUTTON TestIt
Parent win_1
Row 650
Col 25
CAPTION "Click to Test Something"
WIDTH 220
Height 40
ONCLICK {||MsgInfo( Str ( Win_1.VScrollBar.Value ) ), DoSomething()}
END BUTTON
Define BUTTON TestAnother
Parent win_1
Row 650
Col 290
CAPTION "Click to Test Another"
WIDTH 220
Visible l2Tests
Height 40
ONCLICK DoSomethingElse()
END BUTTON
Win_1.Center
ACTIVATE WINDOW Win_1
ON KEY ESCAPE of win_1 action {||(win_1.release)}
Return
*-----------------------------------------------------------------------------------
Function DoSomething()
* nRow1,nCol1,nRowSpc,nColSpc,nWidth,nHeight,nFontSz,aBackColor,aFontkColor,bOnCLick,
* cForm,bLabelValue,labelName,loopfunctions,MatrixTitle,hdr font,Label Font
*------------------------------------------------------------------------------------
Local nRows,nCols,cForm,cVaue
Local aMParameters:={}
* Define and set up parameters for Drawmatrix()
*
Local cTitle:=" Demonstration of an Array of Labels "
Local bLoopLogic:={|l,m|LoopFunctions(l,m)}
Local bOnClickCode:={||(This.Value:=This.name)}
Local bFirstVal:={|k,l|alltrim(str(k*l))}
PRIVATE cBlankInput:="-*-"
//SetProperty( "Win_1", "VScrollBar" , "value" , 0 )
*=====================================================================
*Set Up parameters to call DrawMatrix()
*=====================================================================
aMParameters:={10,10,2,2,45,40,9,DODGERBLUE,YELLOW,4,40,bOnClickCode,"Win_1",;
bFirstVal,"TLbl",bLoopLogic,cTitle,"Times New Roman","Arial"} //NIL}
cForm:="Win_1";nRows:=8;nCols:=10
DrawMatrix(nRows,nCols,aMParameters)
Win_1.VScrollBar.Value :=750
Return
*---------------------------------------------------------------------*
Function DrawMatrix(nRows,nCols,aMParameters )
*
* Draws a matrix of Cells - nRows X nCols
*
*Parameters list must be set up prior to call. Element names are
*Defined in MatrixHdr.ch.
*Elements WINFORM and LABELNAME are sting literals and require &'s
*Element CODEBLOCK1 is a code block for the ON CLICK procedure
*Element LABELVALUE is a code block for the initial VALUE of the cells
*Element LOOPFUNCTNS is a code block to execute code specific to the loop
*Element MTITLE creates a Title Label unless it is set to NIL
*---------------------------------------------------------------------*
Local j,k,clabel,cForm, cTitle
cForm:=aMParameters[WINFORM]
cTitle:=aMParameters[MTITLE]
nTitleRow:=aMParameters[TITLEROW]
nTitleHeight:=iif(cTitle!=NIL,aMParameters[TITLEHEIGHT],0)
if cTitle != NIL
Define Label cTitle
PARENT &cForm
Row aMParameters[TITLEROW]
Col aMParameters[COL1]
WIDTH (aMParameters[COLSPC]+aMParameters[CELLWIDTH])*nCols
HEIGHT aMParameters[TITLEHEIGHT]
FONTNAME aMParameters[HDRFONTNAME] //"Ariel"
ONCLICK {||This.backcolor:=DODGERBLUE}
BACKCOLOR aMParameters[BACKCOLOR1] //aBackColor
FONTCOLOR aMParameters[FONTCOLOR1]
VALUE cTitle
FONTSIZE aMParameters[FONTSZ]*2
End Label
EndIf
for j:=1 to nRows
for k := 1 TO nCols
clabel :=aMParameters[LABELNAME]+ alltrim( str(j)) + alltrim(str(k) )
// are there additional actions to take in the loop?
if aMParameters[LOOPFUNCTNS]!=Nil
eval(aMParameters[LOOPFUNCTNS],j,k)
endif
DEFINE label &clabel
PARENT &cForm
VALUE eval(aMParameters[LABELVALUE],j,k) //c1stVal
Row max(nTitleHeight+aMParameters[TITLEROW],aMParameters[ROW1]);
+2*aMParameters[ROWSPC]+(aMParameters[CELLHEIGHT]+aMParameters[ROWSPC])*(j-1)
Col aMParameters[COL1]+(aMParameters[CELLWIDTH]+aMParameters[COLSPC])*(k-1)
ON CLICK {||(eval (aMParameters[CODEBLOCK1]))}
WIDTH aMParameters[CELLWIDTH]
HEIGHT aMParameters[CELLHEIGHT]
FONTNAME aMParameters[HDRFONTNAME] //"Ariel"
BACKCOLOR aMParameters[BACKCOLOR1]
FONTCOLOR aMParameters[FONTCOLOR1]
FONTSIZE aMParameters[FONTSZ]
END LABEL
next k
next j
Return Nil
Function LoopFunctions(i,j)
if i=9 .AND. j=9
msgbox("Testling Loop function for ij=" +"(" +alltrim(str(i)) +"," +alltrim(str(j))+")" )
endif
return
*--------------------------------
Function DoSomethingElse()
*--------------------------------
msgbox("Nothing to do here")
return