作者:绿色风
分类:
时间:2022-08-18
浏览:91
楼主 amulee |
API向窗体内写字很容易实现,参考代码如下:
- Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
- Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
- Private Declare Function TextOut Lib "gdi32" 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 Sub UserForm_Click()
- Dim sStr$
- sStr = "你好"
- TextOut GetDC(FindWindow(vbNullString, Me.Caption)), 0, 0, sStr, LenB(sStr)
- End Sub
代码中那两个0分别代表字的位置X和Y坐标。
利用API在窗体内写字.rar |
2楼 zzmxy |
阿木太强悍了,以后就有方法了~~ |
3楼 水星钓鱼 |
学习下- Private Declare Function GetActiveWindow Lib "user32" () As Long
- Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
- Private Declare Function TextOut Lib "gdi32" 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 Sub UserForm_Click()
- Dim sStr$
- sStr = "你好"
- TextOut GetDC(GetActiveWindow), 0, 0, sStr, LenB(sStr)
- End Sub
|
免责声明
有感于原ExcelTip.Net留存知识的价值及部分知识具有的时间限定性因素,
经与ExcelTip.Net站长Apolloh商议并征得其同意,
现将原属ExcelTip.Net的知识帖采集资料于本站点进行展示,
供有需要的人士查询使用,也慰缅曾经的论坛时代。
所示各个帖子的原作者如对版权有异议,
可与本人沟通提出,或于本站点留言,我们会尽快处理。
在此,感谢ExcelTip.Net站长Apolloh的支持,感谢本站点所有人**绿色风(QQ:79664738)**的支持与奉献,特此鸣谢!
------本人网名**KevinChengCW(QQ:1210618015)**原ExcelTip.Net总版主之一