汉代青铜印章价格:【vb】只要程序窗口为活动窗口就截获剪贴板数据

来源:百度文库 编辑:神马品牌网 时间:2024/05/03 12:23:14
只要当前窗口获得焦点,就将剪贴板数据截获到文本框,剪贴板数据为文本。
我使用了form的gotfocus事件发现不行,请高手赐教。不希望用timer控件

参考:http://www.graphics.net.cn/bbs/vb/0440/179.asp
http://blog.csdn.net/xinbin1122/category/90621.aspx
=================================================
第13楼 回复人:yefanqiu 2003-07-09 08:13:32 返回顶部

'窗体子类化(声明部分,你自己声明)
'设置
Public Sub SetSubClass(lpHwnd As Long, lngX As Long, lngY As Long)
If Not m_Hook Then
m_hWnd = lpHwnd
m_PrevWndProc = SetWindowLong(lpHwnd, GWL_WNDPROC, AddressOf WindowProc)
m_Hook = True
End If
End Sub
'取消
Public Sub UnSubClass()
If m_Hook Then
Call SetWindowLong(m_hWnd, GWL_WNDPROC, m_PrevWndProc)
m_Hook = False
End If
End Sub
Private Function WindowProc(ByVal hw As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim mmiInfo As MINMAXINFO

If uMsg = WM_ACTIVATE Then
If (wParam = WA_ACTIVE Or wParam = WA_CLICKACTIVE) Then
'frmMain.lblTitle.ForeColor = &H246B& '窗口得到焦点时
frmMain.imgIcon.Picture = frmMain.imgICO(0).Picture
Else
'frmMain.lblTitle.ForeColor = RGB(50, 50, 50) '窗口失去焦点时
frmMain.imgIcon.Picture = frmMain.imgICO(1).Picture
End If
End If

WindowProc = CallWindowProc(m_PrevWndProc, hw, uMsg, wParam, lParam)
End Function
============================================
第二份资料:
自定义事件,比如自定义MyGotFoucs事件代替Form_GotFoucs.
How to use VB6.0's Event.
Creat a new class named Class1, it's codes like this:

Public Event MyEvent()

Public Sub RaiseTheEvent()
'some other codes here
RaiseEvent MyEvent

End Sub

Create a new form, draw a command on it named Command1, double the command to open the code.

It codes like this:

Option Explicit

Private WithEvents Myclass As class1

Private Sub Command1_Click()
Set Myclass = New class1
Call Myclass.RaiseTheEvent 'In this sub event is raised.

End Sub

Private Sub Myclass_MyEvent()'this is the sub to dill with the event.
MsgBox "class1's event occured."
End Sub

Start the application and Click the button will raise the event.