为了美化软件的界面,程序员都会做些特殊的显示效果,其 中文字特效也是常用的效果。例如,在安装程序运行界面上,左上角通常都会以阴影字效果显示软件的标题,使标题更醒目、让人耳目一新的感觉。为让人记忆深刻,一些软件的主窗口(如一些数据库管理系统)的标题就常以特大立体字方式显示,效果都不错。 本例主要通过Windows API函数DrawState()来实现。 Private Const DST_TEXT = &&H1 Private Const DSS_DISABLED = &&H20 Private Declare Function DrawState Lib "user32" Alias "DrawStateA" (ByVal hDC As Long, ByVal hBrush As Long, ByVal lpDrawStateProc As Long, ByVal lParam As String, ByVal wParam As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal n3 As Long, ByVal n4 As Long, ByVal un As Long) As Long Private Sub Form_Load() Dim NewStr As String FontSize = 24 '设置窗口字体 NewStr = "欢迎收看本节目" DrawState Me.hDC, 0, 0, NewStr, LenB(StrConv(NewStr, vbFromUnicode)), 10, 80, 0, 0, DST_TEXT Or DSS_DISABLED '显示该字符 AutoRedraw = True End Sub |