*!*
修改 Windows 系统的:字体、字形、大小、颜色等设置
*!*
请慎用!请慎用!请慎用!(重要事情说三遍)
Declare integer SystemParametersInfo in win32api integer uiAction, integer uiParam, string@ pvParam, integer fWinIni
#Define SPI_GETNONCLIENTMETRICS 41
#Define SPI_SETNONCLIENTMETRICS 42
#Define SPIF_SENDCHANGE
2
#Define NCM_SIZE
10*4+5*60
#Define FW_ULTRALIGHT 200
#Define FW_REGULAR 400
#Define FW_BOLD 700
#Define FW_HEAVY 900
* 或者当前的设置
ncm_current = Padr(BinToC(NCM_SIZE,"4RS"),NCM_SIZE,Chr(0))
SystemParametersInfo(SPI_GETNONCLIENTMETRICS,NCM_SIZE, @ncm_current, 0)
ncm_changed = m.ncm_current
* 获取 logfont 结构
lcFontStr = SUBSTR(m.ncm_current,161,60)
lcFontStrChanged = lcFontStr
* 获取当前的值
nheight = CTOBIN(LEFT(m.lcFontStr,4),"4RS")
nweight = CTOBIN(SUBSTR(m.lcFontStr,17,4),"4RS")
nitalic = CTOBIN(SUBSTR(m.lcFontStr,21,1),"1RS")
nunderline = CTOBIN(SUBSTR(m.lcFontStr,22,1),"1RS")
nstrike =
CTOBIN(SUBSTR(m.lcFontStr,23,1),"1RS")
cfontname = SUBSTR(lcFontStr,29)
* Fontname = Arial
&& 字体名
lcFont = "Arial"
lcFontStrChanged = STUFF(m.lcFontStrChanged,29,32,m.lcFont + REPLICATE(CHR(0), 32 - LEN(m.lcFont)))
ncm_changed = STUFF(m.ncm_changed,161,60,m.lcFontStrChanged)
SystemParametersInfo(SPI_SETNONCLIENTMETRICS,NCM_SIZE, ncm_changed,SPIF_SENDCHANGE)
MESSAGEBOX("Arial")
* Fontsize = 14
&& 字体大小
lnFontSize = 14
lcFontStrChanged = STUFF(m.lcFontStrChanged,1,4,BINTOC(getheight(m.lnFontSize),"4RS"))
ncm_changed = STUFF(m.ncm_changed,161,60,m.lcFontStrChanged)
SystemParametersInfo(SPI_SETNONCLIENTMETRICS,NCM_SIZE, ncm_changed,SPIF_SENDCHANGE)
MESSAGEBOX("Fontsize = 14")
* Bold
&& 粗体字
lcFontStrChanged = STUFF(m.lcFontStrChanged,17,4,BINTOC(FW_BOLD ,"4RS"))
ncm_changed = STUFF(m.ncm_changed,161,60,m.lcFontStrChanged)
SystemParametersInfo(SPI_SETNONCLIENTMETRICS,NCM_SIZE, ncm_changed,SPIF_SENDCHANGE)
MESSAGEBOX("Bold")
* Italic
&& 斜体字
lcFontStrChanged = STUFF(m.lcFontStrChanged,21,1,BINTOC(1 ,"1RS"))
ncm_changed = STUFF(m.ncm_changed,161,60,m.lcFontStrChanged)
SystemParametersInfo(SPI_SETNONCLIENTMETRICS,NCM_SIZE, ncm_changed,SPIF_SENDCHANGE)
MESSAGEBOX("Italic")
* Underline
&& 下划线
lcFontStrChanged = STUFF(m.lcFontStrChanged,22,1,BINTOC(1 ,"1RS"))
ncm_changed = STUFF(m.ncm_changed,161,60,m.lcFontStrChanged)
SystemParametersInfo(SPI_SETNONCLIENTMETRICS,NCM_SIZE, ncm_changed,SPIF_SENDCHANGE)
MESSAGEBOX("Underline")
* Strikethrough
&& 删除线
lcFontStrChanged = STUFF(m.lcFontStrChanged,23,1,BINTOC(1 ,"1RS"))
ncm_changed = STUFF(m.ncm_changed,161,60,m.lcFontStrChanged)
SystemParametersInfo(SPI_SETNONCLIENTMETRICS,NCM_SIZE, ncm_changed,SPIF_SENDCHANGE)
MESSAGEBOX("Strikethrough")
* Change Back
&& 更改背景
ncm_changed = STUFF(m.ncm_changed,161,60,m.lcFontStr)
SystemParametersInfo(SPI_SETNONCLIENTMETRICS,NCM_SIZE, ncm_changed,SPIF_SENDCHANGE)
FUNCTION getheight
LPARAMETERS tnPointSize
DECLARE INTEGER GetDC IN USER32 INTEGER hwnd
DECLARE INTEGER ReleaseDC IN USER32 INTEGER hwnd, INTEGER hdc
DECLARE INTEGER GetDeviceCaps IN GDI32 INTEGER hdc, INTEGER nIndex
DECLARE integer MulDiv IN Kernel32 INTEGER, INTEGER, INTEGER
LOCAL lnhDC, lnfHeight, LOGPIXELSY
LOGPIXELSY = 90
lnhDC = GetDC(0)
lnfHeight = -MulDiv(tnPointSize, GetDeviceCaps(lnhDC, LOGPIXELSY), 72)
lnhDC = ReleaseDC(0, lnhDC)
CLEAR DLLS "GetCD", "ReleaseDC", "GetDeviceCaps", "MulDiv"
RETURN lnfHeight