再谈用VB无窗口透明Usercontrol编写透明浮动按钮
去年曾写过一篇博文,名称叫《用VB无窗口透明Usercontrol编写透明浮动按钮》,该文有一个观点是错误的,即透明无窗口Usercontrol不支持设计时点选。其实,通过在UserControl_HitTest过程里加入HitResult = vbHitResultHit语句,就可以实现设计时的点选了,为此,修改代码如下:
'* ************************************************************** *
'* 程序名称:Button.ctl
'* 程序功能:透明浮动按扭
'* 作者:lyserver
'* 联系方式:http://blog.csdn.net/lyserver
'* 说明:解决了FloatButton版本设计时不能点选的BUG
'* ************************************************************** *
Option Explicit
'======================================================================
' API 声明
'======================================================================
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function OffsetRect Lib "user32" (lpRect As RECT, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Declare Function DrawEdge Lib "user32" (ByVal hdc As Long, qrc As RECT, ByVal edge As Long, ByVal grfFlags As Long) As Long
Private Const BDR_RAISED = &H5
Private Const BDR_SUNKEN = &HA
Private Const BDR_RAISEDINNER = &H4
Private Const BDR_SUNKENINNER = &H8
Private Const BDR_RAISEDOUTER = &H1
Private Const BDR_SUNKENOUTER = &H2
Private Const BF_RECT = &HF
Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
Private Const DT_CENTER = &H1
Private
相关文档:
这一段大家编写程序很多时候都在使用API,它给我们带来了强大的功能.让我们非常惊喜.
但是我们在调试程序的时候有时候总会奔溃.这样很不方便.
其中有些是api惹的祸
使用api注意事项:
首先我说说我的观点.
1:Api是很多系统也在用.我们在设置参数时如果和系统的参数有冲突.就可能引起软件出错
2.api很多都是c语言编写的, ......
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Const EWX_LOGOFF = 0
Private Const EWX_SHUTDOWN = 1
Private Const EWX_REBOOT = 2
Private Const EWX_FORCE = 4
Private closeTime As String
Sub AdjustTokenPrivilegesForNT()
......
VB显示透明FLASH效果
演示效果:
代码如下:
公共声明区域
Option Explicit
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetW ......
使用c#语言在.net平台生成的dll是基于MSIL的二进制代码,通常情况下是无法被native的语言和程序调用的(例如vb,vc,delphi)。但是一般来说windows上native的程序都是可以直接使用com对象的。通过.net平台提供的一些工具,可以为其伪造一个com接口并注册到系统中。此时,可以在native的程序里,通过这个伪com接口来实现此. ......
Option Explicit
Public Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Public Declare Function RegCreateKey Lib "advapi32.dll" Alias ......