And here's an example of the SetClipboardViewer API :

VB Code:
  1. 'Create a new project, add a module to it
  2. 'Add a command button to Form1
  3. 'In the form
  4. Private Sub Form_Load()
  5.     'KPD-Team 1999
  6.     'URL: [url]http://www.allapi.net/[/url]
  7.     'E-Mail: [email][email protected][/email]
  8.     'Subclass this form
  9.     HookForm Me
  10.     'Register this form as a Clipboardviewer
  11.     SetClipboardViewer Me.hwnd
  12. End Sub
  13. Private Sub Form_Unload(Cancel As Integer)
  14.     'Unhook the form
  15.     UnHookForm Me
  16. End Sub
  17. Private Sub Command1_Click()
  18.     'Change the clipboard
  19.     Clipboard.Clear
  20.     Clipboard.SetText "Hello !"
  21. End Sub
  22.  
  23. 'In a module
  24. 'These routines are explained in our subclassing tutorial.
  25. 'http://www.allapi.net/vbtutor/subclass.php
  26. Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  27. Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  28. Declare Function SetClipboardViewer Lib "user32" (ByVal hwnd As Long) As Long
  29. Public Const WM_DRAWCLIPBOARD = &H308
  30. Public Const GWL_WNDPROC = (-4)
  31. Dim PrevProc As Long
  32. Public Sub HookForm(F As Form)
  33.     PrevProc = SetWindowLong(F.hwnd, GWL_WNDPROC, AddressOf WindowProc)
  34. End Sub
  35. Public Sub UnHookForm(F As Form)
  36.     SetWindowLong F.hwnd, GWL_WNDPROC, PrevProc
  37. End Sub
  38. Public Function WindowProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  39.     WindowProc = CallWindowProc(PrevProc, hwnd, uMsg, wParam, lParam)
  40.     If uMsg = WM_DRAWCLIPBOARD Then
  41.         MsgBox "Clipboard changed ..."
  42.     End If
  43. End Function