Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Strange memo editing behaviour
Message
De
20/08/1998 09:07:48
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00125100
Message ID:
00128443
Vues:
45
>>Here I go again with 'other way round' suggestion. The textbox/editbox should pass itself as a parameter, and the job of saving/restoring the .selstart could be done in the foreign character form itself. This way we may make it general enough and not have to add the feature to all the textbox/editbbox classes where we may want to use it. See the other thread (copy & paste programmatically), I've had some idea there of how to do it.
>
>Dragan,
>
>The problem with that approach is that wehn teh other forms gets focus the editbox textbox has already reset its selstart property. The saving has to occur before the control loses focus.

OK, I did it. The called form has three custom properties: oWhoCalled, lnSelLen and lnSelStart. Names should be obvious. In the form's init

Lparameters pWho

Local lnSelstart, lnSellen
if type("pWho")="O" and inlist(pWho.BaseClass, "Textbox","Editbox")
this.oWhoCalled=pWho
** now these two properties still hold their values, because the called form has not finished init(), so it still doesn't "exist" and therefore can't receive focus yet:
this.lnSelstart=oWhoCalled.selstart
this.lnSellen=oWhoCalled.sellength
else
this.oWhoCalled=.NULL.
endif

Then the form runs - in this case, it's a grid and editbox (both read_only), searches for a nice memo field to insert the text from. In the form's Unload event:

if !isnull(this-oWhoCalled)
** restore the selection (position, length)
this.oWhoCalled.selstart=lnSelstart
this.oWhoCalled.sellength=lnSellen
* this actually performs an equivalent of Stuff()
this. oWhoCalled.selText=opislt.ltext && in my case, this is the memo field I wanted to insert
endif

While in the editbox, I'm calling the search form by intercepting F9 in the editbox keypress:

case nKeyCode=-8 and used("opislt") && key F9 and the texts table is open
do form preglt with this
nodefault

though I think a context menu or a toolbar would be more appropriate (so the box doesn't lose focus). Works like charm so far, and what I like the best, doesn't hurt the _cliptext, and needs just to be called from within some editbox's or textbox's method. Could even work for any other control which has Seltext, Selstart and SelLength properties.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform