标题:如何用vb语言 实现制作一个桌面小程序(小盒子,无窗口,类似于QQ宠物)呢? ...
只看楼主
xzlxzlxzl
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:湖北
等 级:贵宾
威 望:125
帖 子:1091
专家分:5825
注 册:2014-5-3
得分:0 
'如果左上角点恒为背景色,则代码修改如下即可

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 "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Sub Command1_Click()
  End
End Sub

Private Sub Form_Load()
  '以左上角点为背景色透明窗体
  Dim rtn As Long
  Me.AutoRedraw = True
  rtn = GetWindowLong(hwnd, -20)
  rtn = rtn Or &H80000
  SetWindowLong hwnd, -20, rtn
  SetLayeredWindowAttributes hwnd, Me.Point(15, 15), 0, 1
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  '移动窗体
  If Button = 1 Then
    Me.Left = Me.Left + X - Me.Width / 2
    Me.Top = Me.Top + Y - Me.Height / 2
  End If
End Sub

[ 本帖最后由 xzlxzlxzl 于 2014-12-17 03:14 编辑 ]
2014-12-15 14:20
zhengang1026
Rank: 6Rank: 6
等 级:侠之大者
威 望:1
帖 子:136
专家分:409
注 册:2013-2-6
得分:0 
回复 9楼 xzlxzlxzl
果然一样!当时没想那么多,只是想将每点移动前的座标存起来与移动后的座标作比较。还是人老了脑子不够用啊
2014-12-15 17:12



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-439807-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.457786 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved