Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
I ve a Dream... Let make a Grid as if ExcelSheet!!
Message
De
15/06/1998 11:59:34
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Titre:
I ve a Dream... Let make a Grid as if ExcelSheet!!
Divers
Thread ID:
00108250
Message ID:
00108250
Vues:
65
I have a dream, I want to make a Grid(GridExcel) as if Excel WorkSheet! Flexible Header(HeaderExcel)!
Besides, the textbox(txtExcel) can be directly reused without grid!!

Wish List on Grid are:
1) Fix IME problem on Grid, with checking IMEFlag.
If IMEFlag is .T., skip code as this field is filled on foreign lang.
* e.g. txtExcel.gotFocus
if !IMEFlag
this.imemode = 2
Endif

2) when Shift+Click the Header, freeze more than one column!
* e.g. headerExcel.MouseDown
LPARAMETERS nButton, nShift, nXCoord, nYCoord
if nButton = 1 and nShift = 1 && Shift+Click
This.parent.parent.FreezeColumn = This.parent.ColumnOrder
* GridExcel.FreezeColumn = Column.ColumnOrder
Endif

But... need expertise to modify the gridlock.scrolled()
according to GridExcel.FreezeColumn value...
Need help on coding here! ^_~

3) Click Header will Sort to this column if field have order tag.
Ctrl+Click Header will be Sort Decreasingly.
I know somebody here has made it in file section. ^_^;

4) From this onwards, most will due with TextExcel coding.
Duplicate an Object 'Eval' + This.name on init and set similar properties!!
Since Excel carry both expression and result value, only duplicate object can do it! Unless onfocus, all other field show result value!

5) If the txtExcel Is not in grid, set favour outlook:
* txtExcel.init
if [COLUMN] $ Upper(This.parent.BaseClass)
THis.BorderStyle = 0 && no border
THis.SpecialEffect = 1 && Flat layout
Endif
Done

6) make additional feature according to Type!
add new properties and procedures:
- VarType: use for EvaltxtExcel object code!
carry Type(txtExcel.value)
- NeedUpper: Flag For Need Upper All First Letter Of Each Word Like This Line
- AllUpper: FLAG FOR CHANGE ALL WORD TO UPPER
~ UpCaption: Function To Upper Each Word, Work With NeedUpper

7) if it is a numeric field ... use EvaltxtExcel to eval value!
* EvaltxtExcel.lostFocus
if Left(this.name,4) = [Eval]   && Runtime object

if This.VarType = [N]  && Numeric Value
LOCAL cValue, EVALFLAG, AssignValue

cValue = ALLTRIM(THIS.VALUE)

IF !EMPTY(cValue) && NON-Empty!

EVALFLAG = .T.

FOR IX = 1 TO LEN(CVALUE)
	IF SUBSTR(CVALUE, IX, 1) $ '+-*/% 	1234567890,.()[]{}'
		* PASS AS + - * / . {SPACE} 1234567890 () [] {} ,
	ELSE
		EVALFLAG = .F.
		Wait Window "The Expression: '&cValue' cannot be evaluated!"+ alltrim(str(ix))+ "At above position!!"
		EXIT		
	ENDIF
ENDFOR

IF EVALFLAG = .T.
	AssignValue = EVAL(CVALUE)
	DO CASE
		CASE EMPTY(AssignValue)
			WAIT "Warning Zero Value is Calculated!!" WINDOW
		CASE AssignValue < 0
			WAIT "What's wrong with Your Input!? "+REPL(CHR(13),2)+"A negivative result is found!!" WINDOW
		CASE AssignValue > 0
			Wait "Evaluated Value: " + alltrim(str(AssignValue)) window nowait timeout 5
			if This.parent.txtExcel.value <> AssignValue
				this.parent.txtExcel.value = assignvalue
			endif
	ENDCASE
ENDIF
	
ENDIF && END !EMPTY()

EndIF && end VarType
Endif && End Eval object

** Done by me! ~_^
8) if it is a Date field, use David's coding to handling Keypress properties.....
Thanks David here!! ~_^

9) if it is a text field, and NeedUpper Flag is .T.,
Change All Wording Starting With Upper Case!!


* EvaltxtExcel.lostFocus
if Left(this.name,4) = [Eval] && Runtime object
if This.VarType = [C]
This.parent.txtExcel.value = This.upcaption()
Endif && End VarType
Endif && End Eval Object



* EvaltxtExcel.upCaption()
Lparameters RLINE

LLINE = ALLTRIM(RLINE)
RLINE = ""

DO WHILE LEN(LLINE) > 0
IF AT(" ", LLINE) > 0
RLINE = RLINE + ALLTRIM(UPPER(LEFT(LLINE,1))) + ALLTRIM(SUBSTR(LLINE, 2, AT(" ",LLINE) -1)) + " "
LLINE = ALLTRIM(SUBSTR(LLINE, AT(" ",LLINE) +1))
ELSE
DO CASE
CASE LEN(LLINE) > 2
RLINE = RLINE + ALLTRIM(UPPER(LEFT(LLINE,1))) + ALLTRIM(SUBSTR(LLINE, 2))

OTHERWISE
RLINE = RLINE + ALLTRIM(UPPER(LEFT(LLINE,1)))
ENDCASE
LLINE = ""
ENDIF
ENDDO
* Done By Me!! ^_~


10) if it is a text field and ALLUPPER flag is .T.

* EvaltxtExcel.Keypress
LPARAMETERS nKeyCode, nShiftAltCtrl
if this.ALLUPPER
do case
CASE BETWEEN(nKeyCode, 97, 122)
NODEFAULT
* DODEFAULT(nKeyCode -32) && Seem problem!
KEYBOARD CHR(nKeyCode-32)
endcase
ENDIF


Combining above Wish list will make a powerful txtExcel object!!
and thus we can change all textbox to this object and highly powerful!
;D=====================

In case need some addition coding put in middle, I recommend to add
new procedure(s):
PreKeyPress> procedure do before calling KeyPress
OtherKeyPress> procedure do on other CASES of Keypress....
PostKeyPress> procedure do after calling KeyPress
i.e.
* txtExcel.KeyPress
Lpara ...
This.PreKeyPress()
Do Case
Case ...

OTherwise
This.OtherKeypress(nKeyCode, nShiftCTrlAlt)..
EndCAse
This.PostKeyPress()


So, no need to worry on interrupt or replace all coding of existing class... ^_^; Really OOP thinking...

Although I said it is a DREAM, I think we can do it!!
if you can help me on any above feature, help me! ^_^'

Thanks all!!
The weak wait for chance, The strong bid for chance,
The clever notch up chance, but The merciful give you chance.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform