Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Access to the active code editor window?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00702897
Message ID:
00702904
Vues:
16
>Hello. I'm looking to write a keyboard hook of some sorts that needs to be able to access the code that I'm writing(read-only), and pump the keyboard buffer based on what it finds(or possibly edit code very much near the cursor). Is there any way to do this? It needs to work for modifying PRGs, and object methods. It must access the code currently being written, which is not neccessarly the code saved to the file being edited.
>
> What I'm actually trying to accomplish, is adding the CTRL+SPACE functionality of VC++ to VFP-- if I hit CTRL+SPACE while I'm typing a variable name, it will search backwards from the current location, looking for a variable in scope to which I am referring-- it would then complete what I'm attempting to type, and possibly even replace what I've already typed(say, I defined the variable mixed-case, and I'm typing it all lower-case, it will change it to the mixed case in which I defined it). If there is a way to accomplish this without writing my own keyboard hook, I'd love to hear about it.
>
>Thanks!

There are some functions in the FoxTools.FLL you can call that can give you access to the code. Here's some sample code that will return all of the code in the currently open window:
FUNCTION GetFullCode()

LOCAL lcProgram, ;
      lnHwd, ;
      laEnv, ;
      lnPos

SET LIBRARY TO SYS(2004) + "FOXTOOLS.FLL"
lnHwd = _WONTOP()
DIMENSION laEnv[25]

_edGetEnv(lnHwd, @laEnv)

lcProgram = ""
lnPos = 0

DO WHILE lnPos <= laEnv[2]
   lcProgram = lcProgram + _EDGETCHAR(lnHwd, lnPos)
   lnPos = lnPos + 1 
ENDDO

RETURN lcProgram
If you do a search for the various underscored-named functions, you should be able to find more examples.
-Paul

RCS Solutions, Inc.
Blog
Twitter
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform