home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Tool Box
/
SIMS_2.iso
/
vb_code1
/
msg_spy
/
spydemop.frm
< prev
next >
Wrap
Text File
|
1994-05-26
|
17KB
|
521 lines
VERSION 2.00
Begin Form frmMsgSpyDemoPro
BackColor = &H00C0C0C0&
BorderStyle = 1 'Fixed Single
Caption = "Message Spy VBX Demo (VB Pro)"
ClientHeight = 5652
ClientLeft = 180
ClientTop = 1380
ClientWidth = 4956
Height = 6096
Icon = SPYDEMOP.FRX:0000
Left = 120
LinkTopic = "Form2"
ScaleHeight = 471
ScaleMode = 3 'Pixel
ScaleWidth = 413
Tag = "This is the main form."
Top = 996
Width = 5076
Begin SSPanel pnl3dMCIStatus
BackColor = &H00C0C0C0&
BevelOuter = 1 'Inset
Font3D = 0 'None
ForeColor = &H000000FF&
Height = 252
Left = 960
TabIndex = 6
Tag = "This is the MCI control's status panel."
Top = 3540
Width = 2832
End
Begin MMControl MMControl1
BackEnabled = -1 'True
EjectEnabled = -1 'True
Height = 375
Left = 540
NextEnabled = -1 'True
PauseEnabled = -1 'True
PlayEnabled = -1 'True
PrevEnabled = -1 'True
RecordEnabled = -1 'True
StepEnabled = -1 'True
StopEnabled = -1 'True
TabIndex = 5
Tag = "This is an MCI control."
Top = 3060
Width = 3540
End
Begin MsgSpy MsgSpy1
Left = 1980
MessageNumber = 1024
SpyMode = 0 'All Messages
Tag = "This is a Message Spy control!"
Top = 1440
End
Begin SSFrame Frame3D1
Caption = "3D Frame"
Font3D = 1 'Raised w/light shading
ForeColor = &H00FF0000&
Height = 2472
Left = 2460
ShadowStyle = 1 'Raised
TabIndex = 8
Tag = "This is a 3D frame."
Top = 480
Width = 2052
Begin OptionButton Option3
BackColor = &H00C0C0C0&
Caption = "Radio button"
Height = 375
Left = 240
TabIndex = 11
Tag = "This is the first radio button in the frame."
Top = 1380
Value = -1 'True
Width = 1455
End
Begin OptionButton Option4
BackColor = &H00C0C0C0&
Caption = "Radio button"
Height = 375
Left = 240
TabIndex = 12
Tag = "This is the second radio button in the frame."
Top = 1920
Width = 1455
End
Begin CheckBox Check2
BackColor = &H00C0C0C0&
Caption = "Check Box"
Height = 312
Left = 240
TabIndex = 10
Tag = "This is the second check box."
Top = 900
Width = 1572
End
Begin CheckBox Check1
BackColor = &H00C0C0C0&
Caption = "Check Box"
Height = 312
Left = 240
TabIndex = 9
Tag = "This is the first check box."
Top = 360
Width = 1572
End
End
Begin SSPanel pnl3dStatusArea
BackColor = &H00C0C0C0&
Font3D = 0 'None
ForeColor = &H00000000&
Height = 1932
Left = -120
TabIndex = 13
Top = 3900
Width = 5472
Begin SSPanel pnl3dControlTag
BackColor = &H00C0C0C0&
BevelOuter = 1 'Inset
Font3D = 0 'None
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 7.8
FontStrikethru = 0 'False
FontUnderline = 0 'False
ForeColor = &H00000000&
Height = 240
Left = 300
TabIndex = 16
Top = 480
Width = 4548
End
Begin SSCheck chk3dTrackAll
Caption = "Track &All Messages"
Font3D = 0 'None
Height = 195
Left = 2760
TabIndex = 15
Top = 120
Width = 1935
End
Begin SSCheck chk3dEnabled
Caption = "&Spying Enabled"
Font3D = 0 'None
Height = 192
Left = 720
TabIndex = 14
Top = 120
Value = -1 'True
Width = 1752
End
Begin SSPanel pnl3dLParam
BackColor = &H00C0C0C0&
BevelOuter = 1 'Inset
Font3D = 0 'None
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 7.8
FontStrikethru = 0 'False
FontUnderline = 0 'False
ForeColor = &H00000000&
Height = 240
Left = 3180
TabIndex = 23
Top = 1320
Width = 1665
End
Begin SSPanel pnl3dWParam
BackColor = &H00C0C0C0&
BevelOuter = 1 'Inset
Font3D = 0 'None
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 7.8
FontStrikethru = 0 'False
FontUnderline = 0 'False
ForeColor = &H00000000&
Height = 240
Left = 2220
TabIndex = 22
Top = 1320
Width = 705
End
Begin SSPanel pnl3dMsg
BackColor = &H00C0C0C0&
BevelOuter = 1 'Inset
Font3D = 0 'None
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 7.8
FontStrikethru = 0 'False
FontUnderline = 0 'False
ForeColor = &H00000000&
Height = 240
Left = 1260
TabIndex = 21
Top = 1320
Width = 705
End
Begin SSPanel pnl3dhWnd
BackColor = &H00C0C0C0&
BevelOuter = 1 'Inset
Font3D = 0 'None
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 7.8
FontStrikethru = 0 'False
FontUnderline = 0 'False
ForeColor = &H00000000&
Height = 240
Left = 300
TabIndex = 20
Top = 1320
Width = 705
End
Begin SSPanel pnl3dYPos
BackColor = &H00C0C0C0&
BevelOuter = 1 'Inset
Font3D = 0 'None
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 7.8
FontStrikethru = 0 'False
FontUnderline = 0 'False
ForeColor = &H00000000&
Height = 240
Left = 4140
TabIndex = 19
Top = 900
Width = 705
End
Begin SSPanel pnl3dXPos
BackColor = &H00C0C0C0&
BevelOuter = 1 'Inset
Font3D = 0 'None
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 7.8
FontStrikethru = 0 'False
FontUnderline = 0 'False
ForeColor = &H00000000&
Height = 240
Left = 3180
TabIndex = 18
Top = 900
Width = 705
End
Begin SSPanel pnl3dMessage
BackColor = &H00C0C0C0&
BevelOuter = 1 'Inset
Font3D = 0 'None
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 7.8
FontStrikethru = 0 'False
FontUnderline = 0 'False
ForeColor = &H00000000&
Height = 240
Left = 300
TabIndex = 17
Top = 900
Width = 2625
End
End
Begin OptionButton Option2
BackColor = &H00C0C0C0&
Caption = "Radio button"
Height = 375
Left = 420
TabIndex = 3
Tag = "This is the second radio button."
Top = 1620
Width = 1455
End
Begin SSPanel Panel3D1
BackColor = &H00C0C0C0&
BevelOuter = 1 'Inset
Caption = "3D Panel"
Font3D = 0 'None
ForeColor = &H00000000&
Height = 255
Left = 2460
TabIndex = 7
Tag = "This is a 3D panel."
Top = 120
Width = 2055
End
Begin TextBox Text1
Height = 285
Left = 420
TabIndex = 0
Tag = "This is a text box."
Text = "Text box"
Top = 120
Width = 1635
End
Begin ListBox List1
Height = 792
Left = 420
TabIndex = 4
Tag = "This is a list box."
Top = 2160
Width = 1632
End
Begin OptionButton Option1
BackColor = &H00C0C0C0&
Caption = "Radio button"
Height = 375
Left = 420
TabIndex = 2
Tag = "This is the first radio button."
Top = 1080
Value = -1 'True
Width = 1455
End
Begin CommandButton Command1
Caption = "Command btn"
Height = 375
Left = 420
TabIndex = 1
Tag = "This is a command button."
Top = 540
Width = 1635
End
End
'-------------------------------------------------
'
' SpyDemoP - a Message Spy Custom Control demo
'
' (using VB Professional Edition VBX controls)
'
' Note the possible uses of the following
' properties within the MsgReceieved event:
'
' MessageName - the name of the message
' IsControl - whether message is for a control
' Control - the actual subclassed control!!!
' ControlName - the subclassed control's name
' IsForm - whether message is for a form
' Form - the actual subclassed form!!!
' FormName - the subclassed form's name
' HIWORD - like HIWORD(LParam) in C/C++
' LOWORD - like LOWORD(LParam) in C/C++
'
' Copyright (c) 1992-1994 Anton Software Limited.
'
'-------------------------------------------------
Option Explicit
' Const WM_SETFOCUS = &H7
' Const WM_MOUSEMOVE = &H200
'
' These constants are not needed, as the message
' name is provided directly. Nevertheless, for
' production code, or if performance is a major
' issue, it would be better to use them instead.
'
' e.g.
'
' If (Msg = WM_SETFOCUS) Then
'
' instead of
'
' If (MsgSpy1.MessageName = "WM_SETFOCUS") Then
Sub chk3dEnabled_Click (Value As Integer)
' Enable/disable the Message Spy control.
MsgSpy1.Enabled = Value
End Sub
Sub DisplayMCIStatus (ByVal XPos As Integer)
Dim ButtonWidth As Integer
ButtonWidth = MMControl1.Width / 9
Select Case XPos
Case 0 To ButtonWidth - 1
pnl3dMCIStatus = "Previous"
Case ButtonWidth To (2 * ButtonWidth) - 1
pnl3dMCIStatus = "Next"
Case (2 * ButtonWidth) - 1 To (3 * ButtonWidth) - 1
pnl3dMCIStatus = "Play"
Case (3 * ButtonWidth) - 1 To (4 * ButtonWidth) - 1
pnl3dMCIStatus = "Pause"
Case (4 * ButtonWidth) - 1 To (5 * ButtonWidth) - 1
pnl3dMCIStatus = "Back"
Case (5 * ButtonWidth) - 1 To (6 * ButtonWidth) - 1
pnl3dMCIStatus = "Step"
Case (6 * ButtonWidth) - 1 To (7 * ButtonWidth) - 1
pnl3dMCIStatus = "Stop"
Case (7 * ButtonWidth) - 1 To (8 * ButtonWidth) - 1
pnl3dMCIStatus = "Record"
Case (8 * ButtonWidth) - 1 To (9 * ButtonWidth) - 1
pnl3dMCIStatus = "Eject"
End Select
End Sub
Sub Form_Load ()
' Subclass ALL the controls on the form.
Dim i As Integer
For i = 0 To controls.Count - 1
MsgSpy1 = controls(i).hWnd
Next i
' Subclass the form itself.
MsgSpy1 = frmMsgSpyDemoPro.hWnd
End Sub
Sub MsgSpy1_MsgReceived (hWnd As Integer, Msg As Integer, WParam As Integer, LParam As Long)
' The control or form window name.
Dim WindowName As String
' Save the message name.
Dim MessageName As String
MessageName = MsgSpy1.MessageName
' If the message is for a control...
If MsgSpy1.IsControl Then
' Save the control's name.
WindowName = MsgSpy1.ControlName
' Process the message...
Select Case MessageName
Case "WM_SETFOCUS"
' Got focus message.
pnl3dMessage = WindowName + " got focus"
Case "WM_MOUSEMOVE"
' Mouse is over the control.
' Display the control's name and
' the mouse coordinates.
pnl3dMessage = "Mouse is over " & WindowName
pnl3dXPos = Str$(MsgSpy1.LOWORD)
pnl3dYPos = Str$(MsgSpy1.HIWORD)
' Display the control's Tag
' property.
pnl3dControlTag.Caption = MsgSpy1.Control.Tag
' Process the MCI control.
If TypeOf MsgSpy1.Control Is MMControl Then
DisplayMCIStatus MsgSpy1.LOWORD
Else
pnl3dMCIStatus = ""
End If
End Select
Else ' MsgSpy1.IsForm = True
' Save the form's name.
WindowName = MsgSpy1.FormName
' If the mouse is over the form...
If (MessageName = "WM_MOUSEMOVE") Then
' Display the form's name and the
' mouse coordinates.
pnl3dMessage = "Mouse is over " & WindowName
pnl3dXPos = Str$(MsgSpy1.LOWORD)
pnl3dYPos = Str$(MsgSpy1.HIWORD)
' Display the form's Tag property.
pnl3dControlTag.Caption = MsgSpy1.Form.Tag
' The mouse isn't over the MCI control.
pnl3dMCIStatus = ""
End If
End If
' If all message are being tracked...
If chk3dTrackAll Then
' Display the message (event) parameters.
pnl3dhWnd = Str$(hWnd)
pnl3dMsg = Str$(Msg)
pnl3dWParam = Str$(WParam)
pnl3dLParam = Str$(LParam)
' Display the window and message details
' in the debug window.
If MessageName <> "" Then
Debug.Print WindowName & ", " & MessageName & ", " & WParam & ", " & MsgSpy1.HIWORD & ", " & MsgSpy1.LOWORD
End If
End If
End Sub