Thursday, July 14, 2011

Visual FoxPro Tips: Programmatically Change Command Window Font

Sometime, we are bored with it's default Courier New font at Visual FoxPro command line window. Of course we can make a change to FoxPro's command window font with it's properties. But, this chance may be quite takes time. With a set of codes written in a .prg file, we can make font turnover with just one click or one Enter.

Here are codes set to easily change your Visual FoxPro command window font. All you need to do is just write down this code into a VFP .prg file. Run the .prg to change font. The codes using functions from foxtools.fll.

LOCAL ARRAY laEnv[25]
SET LIBRARY TO FoxTools ADDITIVE
 
ACTIVATE WINDOW Command
* Get the whandle for the current window
lnwhandle  = _WonTop()
lnResult = _EdGetEnv( lnwHandle, @laEnv )
* Make sure that call succeed and the handle belongs to the Command Window
IF lnResult <> 0 AND laEnv[25]=0
 && Font Name
 laEnv[22] = "Consolas"
 && Font Size
 laEnv[23] = 13
 IF _EdSetEnv( lnwHandle, @laEnv ) <> 0 
  ? "Success"
 ELSE
  ? "Could not set Command Window Font"
 ENDIF 
ELSE
 ? "Could not get Command Window handle"
ENDIF 


Ok! Enjoy this easy thing to change your Visual FoxPro Command-line window's font.

Code from here.

No comments: