Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function SetBkMode Lib "gdi32" (ByVal hdc As Long, ByVal nBkMode As Long) As Long Private Declare Function TextOut Lib "gdi32.dll" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As LongPrivate Const TRANSPARENT = 1Private Sub Timer1_Timer()Dim hwnd As Long hwnd = GetDC(0) Cls SetBkMode hwnd, TRANSPARENT '设置透明 TextOut hwnd, 550, 150, "ttyy", 18 TextOut hwnd, 600, 150, "staifdsj", 18 DoEvents End Sub 代码里要加些什么???
Dim hwnd As Long Dim LF As LOGFONT Dim hFont As Long, oldfont As Long hwnd = GetDC(0) RtlMoveMemory LF.lfFaceName(0), ByVal CStr("宋体"), LenB(StrConv("宋体", vbFromUnicode)) + 1 LF.lfHeight = (18 * 20) / Screen.TwipsPerPixelY LF.lfWidth = (18 * 20) / Screen.TwipsPerPixelY LF.lfCharSet = DEFAULT_CHARSET hFont = CreateFontIndirect(LF) oldfont = SelectObject(hwnd, hFont)Cls SetBkMode hwnd, TRANSPARENT '设置透明 TextOut hwnd, 550, 150, "ttyy", 18 TextOut hwnd, 600, 150, "staifdsj", 18 DoEvents
楼上的同志,第二行编译出问题了,LOGFONT没定义???
我晕死,你不会用api浏览器自己添加声明吗?
Option ExplicitPrivate Const MM_ANISOTROPIC = 8 Private Const LF_FACESIZE = 32 Private Const DEFAULT_CHARSET = 1Private Type LOGFONT lfHeight As Long lfWidth As Long lfEscapement As Long lfOrientation As Long lfWeight As Long lfItalic As Byte lfUnderline As Byte lfStrikeOut As Byte lfCharSet As Byte lfOutPrecision As Byte lfClipPrecision As Byte lfQuality As Byte lfPitchAndFamily As Byte lfFaceName(0 To LF_FACESIZE - 1) As Byte End Type Private Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" (lpLogFont As LOGFONT) As Long Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As LongPrivate Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function SetBkMode Lib "gdi32" (ByVal hdc As Long, ByVal nBkMode As Long) As Long Private Declare Function TextOut Lib "gdi32.dll" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As Any, source As Any, ByVal numBytes As Long)Private Const TRANSPARENT = 1 Private Sub Command1_Click()Dim hwnd As Long Dim LF As LOGFONT Dim hFont As Long, oldfont As Long hwnd = GetDC(0) CopyMemory LF.lfFaceName(0), ByVal CStr("宋体"), LenB(StrConv("宋体", vbFromUnicode)) + 1 LF.lfHeight = (18 * 20) / Screen.TwipsPerPixelY LF.lfWidth = (18 * 20) / Screen.TwipsPerPixelY LF.lfCharSet = DEFAULT_CHARSET hFont = CreateFontIndirect(LF) oldfont = SelectObject(hwnd, hFont)Cls SetBkMode hwnd, TRANSPARENT '设置透明 TextOut hwnd, 550, 150, "ttyy", 18 TextOut hwnd, 600, 150, "staifdsj", 18 DoEvents End Sub
Private Declare Function SetBkMode Lib "gdi32" (ByVal hdc As Long, ByVal nBkMode As Long) As Long
Private Declare Function TextOut Lib "gdi32.dll" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As LongPrivate Const TRANSPARENT = 1Private Sub Timer1_Timer()Dim hwnd As Long
hwnd = GetDC(0)
Cls
SetBkMode hwnd, TRANSPARENT '设置透明
TextOut hwnd, 550, 150, "ttyy", 18
TextOut hwnd, 600, 150, "staifdsj", 18
DoEvents
End Sub
代码里要加些什么???
Dim LF As LOGFONT
Dim hFont As Long, oldfont As Long
hwnd = GetDC(0)
RtlMoveMemory LF.lfFaceName(0), ByVal CStr("宋体"), LenB(StrConv("宋体", vbFromUnicode)) + 1
LF.lfHeight = (18 * 20) / Screen.TwipsPerPixelY
LF.lfWidth = (18 * 20) / Screen.TwipsPerPixelY
LF.lfCharSet = DEFAULT_CHARSET
hFont = CreateFontIndirect(LF)
oldfont = SelectObject(hwnd, hFont)Cls
SetBkMode hwnd, TRANSPARENT '设置透明
TextOut hwnd, 550, 150, "ttyy", 18
TextOut hwnd, 600, 150, "staifdsj", 18
DoEvents
Private Const LF_FACESIZE = 32
Private Const DEFAULT_CHARSET = 1Private Type LOGFONT
lfHeight As Long
lfWidth As Long
lfEscapement As Long
lfOrientation As Long
lfWeight As Long
lfItalic As Byte
lfUnderline As Byte
lfStrikeOut As Byte
lfCharSet As Byte
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lfFaceName(0 To LF_FACESIZE - 1) As Byte
End Type
Private Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" (lpLogFont As LOGFONT) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As LongPrivate Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function SetBkMode Lib "gdi32" (ByVal hdc As Long, ByVal nBkMode As Long) As Long
Private Declare Function TextOut Lib "gdi32.dll" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As Any, source As Any, ByVal numBytes As Long)Private Const TRANSPARENT = 1
Private Sub Command1_Click()Dim hwnd As Long
Dim LF As LOGFONT
Dim hFont As Long, oldfont As Long
hwnd = GetDC(0)
CopyMemory LF.lfFaceName(0), ByVal CStr("宋体"), LenB(StrConv("宋体", vbFromUnicode)) + 1
LF.lfHeight = (18 * 20) / Screen.TwipsPerPixelY
LF.lfWidth = (18 * 20) / Screen.TwipsPerPixelY
LF.lfCharSet = DEFAULT_CHARSET
hFont = CreateFontIndirect(LF)
oldfont = SelectObject(hwnd, hFont)Cls
SetBkMode hwnd, TRANSPARENT '设置透明
TextOut hwnd, 550, 150, "ttyy", 18
TextOut hwnd, 600, 150, "staifdsj", 18
DoEvents
End Sub