Page 1 of 1
Problem with get / Tget object
Posted: Sun Aug 27, 2006 12:44 am
by eduardofreni
I use in the get object, bChange for to know step by step the characters typewrite in a variable.
Fivewin report across nkey the chr number of last character typed.
But if i call the VarGet() method for read the total character typed, he not return me, nothing for the first 2 character. After typede 3 character the method return me the first character typed.
I send the code sample, test it. It's Very strange. This limit the use of get system.
I have fivewin 2.7, xHarbour 99.60.
The code:
#include "FiveWin.ch"
function Main()
local oDlg, oGet1, n1 := " "
DEFINE DIALOG oDlg TITLE "Testing Gets"
@ 1, 1 GET oGet1 VAR n1 SIZE 80, 11
oGet1:bChange={ |nkey , nFlag| test(nkey,nFlag,@oGet1)}
@ 3, 11 BUTTON "Ok" ACTION oDlg:End()
ACTIVATE DIALOG oDlg CENTERED
return nil
procedure test(nkey,nFlag,oGet1)
Local CharContainer
CharContainer := oGet1:VarGet()
? CharContainer
? chr(nkey)
msgalert("You Write "+CharContainer,"Write?")
return
Posted: Sun Aug 27, 2006 11:01 am
by Antonio Linares
Eduardo,
Try it this way:
Code: Select all
#include "FiveWin.ch"
function Main()
local oDlg, oGet1, n1 := Space( 20 )
DEFINE DIALOG oDlg TITLE "Testing Gets"
@ 1, 1 GET oGet1 VAR n1 SIZE 80, 11
oGet1:bChange={ |nkey , nFlag| test(nkey,nFlag, oGet1, oDlg)}
@ 3, 11 BUTTON "Ok" ACTION oDlg:End()
ACTIVATE DIALOG oDlg CENTERED
return nil
procedure test(nkey,nFlag,oGet1,oDlg)
Local CharContainer
CharContainer := oGet1:GetText()
oDlg:SetText( CharContainer )
return
the dialog go to error
Posted: Tue Aug 29, 2006 12:07 am
by eduardofreni
When i test with fwh the sample give an error at this row:
oDlg:SetText( CharContainer )
To me seems that the problem is in the dialog that does not have the method.
But, if i take the character in CharContainer and add chr(nKey) the problem are solved.
Is solvable the problema, for get all character from buffer of keyboard?
I know how this problem more complicated. It is necessary to go to touch the winproc. Excuse me.
Many thanks for your prompt answer.
Best Regards.
Saludos
Eduardo Freni
PS excuse for bad english
Posted: Tue Aug 29, 2006 7:58 am
by Antonio Linares
Eduardo,
Please copy and build the entire sample that I have posted. It works fine.
Probably you are missing oDlg in your code.
Ok work
Posted: Tue Aug 29, 2006 2:42 pm
by eduardofreni
Is true, i not have passed, the oDlg at procedure test.
Now i passed and no error in procedure.
But, how to see CharContainer not contain all character typed in the string, but the string with character -1, character captured from nkey
Thanks for all.
Best regards
#include "FiveWin.ch"
function Main()
local oDlg, oGet1, n1 := " "
DEFINE DIALOG oDlg TITLE "Testing Gets"
@ 1, 1 GET oGet1 VAR n1 SIZE 80, 11
oGet1:bChange={ |nkey , nFlag| test(nkey,nFlag,@oGet1,@oDlg)}
@ 3, 11 BUTTON "Ok" ACTION oDlg:End()
ACTIVATE DIALOG oDlg CENTERED
return nil
procedure test(nkey,nFlag,oGet1,oDlg)
Local CharContainer
CharContainer := oGet1:GetText()
oDlg:SetText( CharContainer )
? chr(nkey)
? CharContainer
return
Posted: Tue Aug 29, 2006 5:29 pm
by James Bott
Try this:
procedure test(nkey,nFlag,oGet1,oDlg)
Local CharContainer
CharContainer := oGet1:varGet() // changed
msgInfo( charContainer )
oDlg:SetText( CharContainer )
? chr(nkey)
? CharContainer
return
Posted: Tue Aug 29, 2006 5:35 pm
by Silvio
Edo, why this PHOTO ?
<-------------------------<
My photo?
Posted: Tue Aug 29, 2006 8:43 pm
by eduardofreni
Hello Silvio, how are you?
My photo?
Becouse is the only in black and white.
For reduce the dimensions of image.
Why not?
Buona vida Silvio.
Eduardo Freni
Estimando James Bott
Posted: Tue Aug 29, 2006 9:12 pm
by eduardofreni
It is one unexpected and appreciate surprised your mail.
I study and appreciate your manual on FiveWin Class. Me has been much profit.
For the procedure the problem is this.
I must extract the characters, who come directly typed, from the buffer of an object get. Possibly the entire string, not a character for time.
I cannot attend the valid, I must make it before.
For this I have made this post.
I have mistaken method?
I do not know, task to have made how much was necessary.
OnChange, would have gives the possibility to me to approach the buffer of the characters written in the get.
Thanks for all James Bott.
Best Regards
Eduardo Freni
Posted: Wed Aug 30, 2006 1:35 am
by James Bott
Eduardo,
Thanks for the kind words.
Here is an example of how to get the contents of a GET including the last keystroke.
James
Code: Select all
// Testing getting GET buffer including lastkeystroke
#include "fivewin.ch"
function main
local oDlg,oGet,cTest:=space(10)
define dialog oDlg
@ 1,1 get oGet var cTest
oGet:bChange:={|nKey| oDlg:setText(getData(oGet,nKey)) }
activate dialog oDlg
return nil
Function getData(oGet,nKey)
Local cBuffer := oGet:oGet:Buffer
Local cChar:= if(nKey==VK_BACK,"",chr(nKey))
if nKey<>VK_RETURN
cBuffer:= Stuff(cBuffer, oGet:nPos, 1, cChar )
endif
// Now cBuffer contains the last char typed
return cBuffer