home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form Coop1
- BackColor = &H00C0C0C0&
- BorderStyle = 1 'Fixed Single
- Caption = "Coop1"
- ClientHeight = 1785
- ClientLeft = 1095
- ClientTop = 1485
- ClientWidth = 4845
- Height = 2190
- Left = 1035
- LinkTopic = "Form1"
- ScaleHeight = 1785
- ScaleWidth = 4845
- Top = 1140
- Width = 4965
- Begin CommandButton ExitBut
- Caption = "Exit"
- Height = 465
- Left = 3180
- TabIndex = 6
- Top = 1200
- Width = 1605
- End
- Begin TextBox TotalText
- Height = 315
- Left = 870
- MaxLength = 12
- TabIndex = 5
- Text = "144.64"
- Top = 1290
- Width = 1245
- End
- Begin TextBox AmountText
- Height = 315
- Left = 870
- MaxLength = 12
- TabIndex = 4
- Text = "$5"
- Top = 900
- Width = 1245
- End
- Begin TextBox CountText
- Height = 315
- Left = 870
- MaxLength = 4
- TabIndex = 3
- Text = "129"
- Top = 510
- Width = 1245
- End
- Begin TextBox CompanyText
- Height = 315
- Left = 870
- MaxLength = 24
- TabIndex = 2
- Text = "Desaware SpyWorks-VB"
- Top = 120
- Width = 2265
- End
- Begin CommandButton SendMessBut
- Caption = "Send Message"
- Height = 465
- Left = 3180
- TabIndex = 1
- Top = 660
- Width = 1605
- End
- Begin CommandButton LaunchBut
- Caption = "Launch New App"
- Height = 465
- Left = 3180
- TabIndex = 0
- Top = 120
- Width = 1605
- End
- Begin ccCallback Callback1
- IntVersion = 5
- Left = 2550
- Top = 1140
- Type = 6 'EnumWindows
- End
- Begin Label Label1
- Alignment = 1 'Right Justify
- BackColor = &H00C0C0C0&
- Caption = "Single"
- Height = 255
- Index = 3
- Left = 120
- TabIndex = 10
- Top = 1320
- Width = 705
- End
- Begin Label Label1
- Alignment = 1 'Right Justify
- BackColor = &H00C0C0C0&
- Caption = "Currency"
- Height = 255
- Index = 2
- Left = 60
- TabIndex = 9
- Top = 930
- Width = 765
- End
- Begin Label Label1
- Alignment = 1 'Right Justify
- BackColor = &H00C0C0C0&
- Caption = "Integer"
- Height = 255
- Index = 1
- Left = 120
- TabIndex = 8
- Top = 540
- Width = 705
- End
- Begin Label Label1
- Alignment = 1 'Right Justify
- BackColor = &H00C0C0C0&
- Caption = "String"
- Height = 255
- Index = 0
- Left = 150
- TabIndex = 7
- Top = 150
- Width = 675
- End
- Option Explicit
- Dim NewShellApp As Integer
- Dim OtherAppMainWindowHwnd As Integer
- Dim PrivateCoopMessage As Integer
- Sub Callback1_EnumWindows (hWnd As Integer, lpData As Long, retval As Integer)
- Dim thismod As Integer, res As Integer
- Dim classname As String
- ' Check if this window belongs to the new instance we launched
- thismod = GetWindowWord(hWnd, GWW_HINSTANCE)
- ' The default return value is already TRUE to continue enumeration
- If thismod <> NewShellApp Then Exit Sub
- classname = String$(32, 0)
- res = GetClassName(hWnd, classname, Len(classname) + 1)
- classname = Left$(classname, InStr(1, classname, Chr$(0)) - 1)
- If classname = THUNDERRTMAIN Then Exit Sub
- ' Stop the enumeration once we find the window
- retval = 0
- OtherAppMainWindowHwnd = hWnd
- End Sub
- Sub ExitBut_Click ()
- Unload Me
- End Sub
- Sub Form_Load ()
- PrivateCoopMessage = RegisterWindowMessage(COOP_MESSAGE)
- End Sub
- Sub LaunchBut_Click ()
- Dim res As Integer
- NewShellApp = Shell(App.Path & "\COOP2.EXE", 1)
- ' If Shell was successful then
- If NewShellApp Then
- ' Get the top level window handle of the newly launched application
- res = EnumWindows(Callback1.ProcAddress, 0)
- End If
- End Sub
- Sub SendMessBut_Click ()
- Dim cs As CoopStructure
- Dim lp As Long, lres As Long
- If PrivateCoopMessage Then
- ' Note that the Max length of CompanyText is
- ' set to the size of the CompanyName element.
- ' The other Text controls also have limited Max
- ' length to prevent overflow.
- cs.CompanyName = CompanyText.Text
- ' Prevent invalid data type
- On Error GoTo InvalidCount
- cs.Count = CInt(CountText.Text)
- On Error GoTo InvalidAmount
- cs.Amount = CCur(AmountText.Text)
- On Error GoTo InvalidTotal
- cs.Total = CSng(TotalText.Text)
- ' Turn off error checking
- On Error GoTo 0
- ' Get address of the structure and send it to the other application.
- lp = dwGetAddressForObject(cs)
- lres = SendMessageBynum(OtherAppMainWindowHwnd, PrivateCoopMessage, 0, lp)
- End If
- Exit Sub
- InvalidCount:
- cs.Count = 0
- Resume Next
- InvalidAmount:
- cs.Amount = 0
- Resume Next
- InvalidTotal:
- cs.Total = 0
- Resume Next
- End Sub
-