Hi (again)
(It's seems that I'm getting all the weird stuff this week...)
I have a textbox which in the keypress (Shift+F5) event
I call a class.method to translate it's value.
When the word to translate isn't possible (unknown word,misspelled...)
another "translateform" with a grid is shown with other possible words and
the possibility to add / alter the word or cancel it.
So far so good and everythings works fine.
Except I want it just underneath the textbox with the
"problem" word.
In the init of the "translateform" I place this
so the "translateform" is placed right underneath the word
this.Left = lcallform.left + OBJTOCLIENT(lcallobject,2) +
(lcallobject.selstart * FONTMETRIC(6 , "arial", 8)) +5
this.top = lcallform.top + OBJTOCLIENT(lcallobject,1) + lcallobject.height +
32
when the first unknown word in the textbox is found and the "translateform"
is shown everything is ok.
In the same translatingloop of the keypress when there is another unknown
word
then ObjToClient() (Top and Left) returns suddenly BOTH Exactly 4000 !?
All the other values lcallform and lcallobject are correct
it returns the right objectreference and left and right and so on.
And I never ever have any form that is that wide ?
(sometimes I wish I could have ...)
to check where the problem is I've place this in the translateform.init.
So i know exactly that only objtoclient() is given me "weird" results.
MessageBox(lcallform.name+CHR(13)+"left
"+TRANSFORM(lcallform.left)+CHR(13)+" top "+TRANSFORM(lcallform.top)+;
lobject.name+CHR(13)+"left "+TRANSFORM(lobject.left)+CHR(13)+" top
"+TRANSFORM(lobject.top)+CHR(13)+;
"objtoclient "+CHR(13)+"left "+TRANSFORM(OBJTOCLIENT(lobject,2))+CHR(13)+"
top "+TRANSFORM(OBJTOCLIENT(lobject,1))+CHR(13)+;
"this "+CHR(13)+"left "+TRANSFORM(this.left)+CHR(13)+" top
"+TRANSFORM(this.top) )
Anybody an idea
or maybe a workaround ?
regards
christophe
In case you want to have a look at the translating code
(it's more a replacing code)
here it goes :
Lparameters naartaal,origfield
Local origtext, newtext,totwoord,curwoord,origfielda,lijstmeer,lijstmeerstd
If .Not. Empty(This.Value)
oldseltaal = Alias()
ok=chkopen(f_vertaal,"translate")
Do Case
Case naartaal="NL"
taal_="woord1"
skip_="skip1"
Case naartaal="EN"
taal_="woord2"
skip_="skip2"
Case naartaal="DU"
taal_="woord3"
skip_="skip3"
Case naartaal="FR"
taal_="woord4"
skip_="skip4"
Otherwise
taal_="woord2"
skip_="skip2"
Endcase
ncurlet = 0
curwoord = ""
skipwoord = .F.
nieuwwoord = .F.
origtext = Upper(Alltrim(This.Value))+" "
lenorigtext = Len(origtext)
origfielda = Substr(origfield,1,At(".",origfield,1)-1)
*loop through the sence to translate each individual word
Do While ncurlet <= lenorigtext
ncurlet = ncurlet + 1
curlet = Substr(origtext,ncurlet,1)
Do Case
Case Isdigit(curlet)
*when there is a digit in the word => no translation
skipwoord = .T.
Case Isalpha(curlet) .Or. curlet $ "-'"
*" ' "and " - " is can be handled in 1 word
curwoord = curwoord + curlet
Otherwise
*all other signs take this as the end of a word and start a new word
nieuwwoord = .T.
Endcase
If nieuwwoord
If .Not. skipwoord .And. .Not. Empty(curwoord) .And. Len(curwoord) > 1
newwoord = ""
*lookup the dictionary table "translate"
If Seek(curwoord,"translate","woord1")
If translate.skip1
*no translation neccesary in any language
skipwoord = .T.
Else
*no translation possible in a language
skipwoord = translate.&skip_
Endif
Endif
If .Not. skipwoord
newwoord = Upper(Alltrim(translate.&taal_))
lencurwoord = Len(curwoord)
If Empty(newwoord)
*no translation found
*ask what to do
This.SelStart = ncurlet - lencurwoord -1 &&begin pos
lijstmeer = "Add Woord;Other Word;Skip Word;"
*mymessagebox("WHEN FIRST TIME = OK, SECOND TIME ?!? Objecttoclient
returns 4000")
Do Form vertaalmeer Name "vertaalmeer" With
This,Thisform,lijstmeer,curwoord,taal_ To newwoord
Release vertaalmeer
newwoord = Upper(Alltrim(newwoord))
Else
*check if more possiblities
nlijstmeer = 0
lijstmeer=""
Do While curwoord = translate.woord1
clijstwoord = Upper(Alltrim(translate.&taal_))
If .Not. Empty(clijstwoord)
nlijstmeer = nlijstmeer + 1
lijstmeer = lijstmeer + clijstwoord + ";"
Endif
Skip In "translate"
Enddo
If nlijstmeer > 1
*more translations possibilities found
This.SelStart = ncurlet - lencurwoord -1 &&begin pos
lijstmeer = lijstmeer + "Add Woord;Other Word;Skip Word;"
*mymessagebox("WHEN FIRST TIME = OK, SECOND TIME ?!? Objecttoclient
returns 4000")
Do Form vertaalmeer Name "vertaalmeer" With
This,Thisform,lijstmeer,curwoord,taal_ To newwoord
Release vertaalmeer
newwoord = Upper(Alltrim(newwoord))
Endif
Endif
*replace word with translation
If .Not. Empty(newwoord)
*alter cur pos with length newword
If .Not. Empty(origfield)
*textbox is in grid
Replace &origfield With
Stuff(Evaluate(origfield),ncurlet-lencurwoord,lencurwoord,newwoord) In
&origfielda
origtext = Upper(Alltrim(Evaluate(origfield)))+" "
Thisform.gridpapyrus.Refresh
Else
*textbox is on a form
This.Value =
Stuff(Evaluate(origfield),ncurlet-lencurwoord,lencurwoord,newwoord)
origtext = Upper(Alltrim(This.Value)) + " "
Endif
ncurlet = ncurlet - lencurwoord + Len(newwoord)
lenorigtext = Len(origtext)
Endif
Endif &¬ skipwoord
Endif &&.not. skipwoord .and. .not. EMPTY(curwoord) .and. LEN(curwoord)>1
skipwoord = .F.
nieuwwoord = .F.
curwoord = ""
newwoord = ""
lencurwoord = 0
Endif &&nieuwwoord
Enddo &&ncurlet <= LENorigtext
Select &oldseltaal
Endif