Re: Some questions about INTRACTIVECHANGE Event.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Let me preface this by saying I usually don't comment on any attempt to
attain precision pixel widths of strings. It's truly a sinkhole of time.
I've known many people who are way smarter than me who worked very hard on
the issue, and the best they can come up with is an approximation. Every one
of them said they'd never do it again.

That said, you've answered your own question when you said the value
evaluated properly in Valid but not in keypress. The control's Value
property doesn't get written to the control's Controlsource until focus
leaves the control. In keypress, focus hasn't attempted to leave the
control. In Valid, the Value has been written to Controlsource.

I *think* (but this is distant memory) that This.TextWidth() evaluates the
controlsource. So before you evaluate Textwidth(), cause the control's Value
to be written to the controlsource by using This.Setfocus().

I don't see where you're initializing the value stored in OWNER, nor where
it's being written as you're running through this process. You *might* be
facing a simple scoping issue. We see enough of those around here. But my
money is on figuring out which value you're really evaluating in
Textwidth().

Dan



"Jud" <judsonrp@xxxxxxxxxxx> wrote in message
news:1170300217.897937.23980@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,
This is VFP6 SP5.

My intent was to make a TextBox which would, while I was typing, let
me know when I had typed too many characters to fit within a fixed
number of pixels, and remove the last character I had just typed.

I started with "_234567890_234567890 " in the TextBox
OWNER_ TEXT.

I then added three "x"s to get "_234567890_234567890xxx "
which calls the following code 3 times.

*** This is OWNER_TEXT.INTERACTIVECHANGE:

acti screen
? [||| in -- "] + owner + ["]

IF THIS.TEXTWIDTH( ALLTRIM(OWNER) ) > OWNERMAX
* OVER the Maximum.
?? CHR(7) + CHR(7)
THIS.FORECOLOR = 255 && RED
INKEY(0.3, "HM")

OWNER = ALLTRIM(OWNER)
DO WHILE THIS.TEXTWIDTH( OWNER ) > OWNERMAX
OWNER = LEFT(OWNER, LEN(OWNER) - 1)
ENDDO while over.

OWNER = PADR(OWNER, 50)
THIS.FORECOLOR = 0 && BLACK
ENDIF over.


? [||| out- "] + owner + ["]

------------------- end of code.

As I typed, this produced:

||| in -- "_234567890_234567890 "
||| out- "_234567890_234567890 "
||| in -- "_234567890_234567890 "
||| out- "_234567890_234567890 "
||| in -- "_234567890_234567890 "
||| out- "_234567890_234567890 "

This Event does see the changes and reacts, but the value of OWNER
passed to it does not contain them, even though OWNER has too many
characters. And therefore, the IF...ENDIF statement is never true.
Until Tab or Enter is pressed and focus moves to another control, then
code in the OWNER_TEXT.VALID event does see the added "x"s and removes
them, using similar code.

My Help system says the following:
--------
InteractiveChange Event

Occurs when the user changes the value of a control using the keyboard
or the mouse.

Remarks

This event occurs each time the object's value changes interactively.
For example, as a user types in a text box, the InteractiveChange
event is triggered after each keystroke.
--------
KeyPress Event

Occurs when the user presses and releases a key.

Remarks

A KeyPress event is useful for intercepting keystrokes entered in a
control. It enables you to immediately test keystrokes for validity or
to format characters as they are typed. Use the KeyPreview property to
create global keyboard-handling routines.
-------- end of Help.

Neither the InteractiveChange or KeyPress Event seem to see anything
but the variable as it existed when focus was brought to the TextBox.
And have no access to the actual contents, visible in the TextBox as
you type.

Am I missing something? Is it possible to evaluate the actual
contents between key presses as I type, and do something about them?

Any help would be greatly appreciated. Thanks in advance.

Jud



.



Relevant Pages

  • Re: Some questions about INTRACTIVECHANGE Event.
    ... me know when I had typed too many characters to fit within a fixed ... OWNER_ TEXT. ... For example, as a user types in a text box, the InteractiveChange ... A KeyPress event is useful for intercepting keystrokes entered in a ...
    (microsoft.public.fox.helpwanted)
  • Re: Verify/cancel entered text in textbox
    ... Why not just use a NumericUpDown control, ... > activates a part of the dialog that will trigger a Validation attempt. ... > can do this check either at the KeyPress event or at the TextChanged ... The TextChanged event is not cancellable (that I can ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Fuddruckers...For your Information.
    ... Only if you believe that the property owner can discrimate as much as ... discriminate on who is on your property is seriously reduced. ... some of his control over his property. ... You have to legally define "public access" ...
    (talk.politics.guns)
  • Re: Fuddruckers...For your Information.
    ... Only if you have no respect for the law or the right of a property ... Only if you believe that the property owner can discrimate as much as ... discriminate on who is on your property is seriously reduced. ... some of his control over his property. ...
    (talk.politics.guns)
  • RE: [Full-disclosure] RE: [ISN] How To Save The Internet
    ... The point might be better made here that we have many security models ... a box owner may assign so that their access permissions are granted ... the current legal morass over intellectual property is of social value ... Nor is there much up-front discussion for consumers of what they can control, ...
    (Full-Disclosure)