home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / tool / various / vbasm / wininfo.frm < prev   
Text File  |  1994-06-18  |  8KB  |  244 lines

  1. VERSION 2.00
  2. Begin Form frmWinInfo 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "Window Spy"
  6.    ClientHeight    =   3495
  7.    ClientLeft      =   1770
  8.    ClientTop       =   3075
  9.    ClientWidth     =   5415
  10.    Height          =   3900
  11.    Left            =   1710
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   3495
  14.    ScaleWidth      =   5415
  15.    Top             =   2730
  16.    Width           =   5535
  17.    Begin TextBox txtWinInfo 
  18.       Height          =   285
  19.       Index           =   0
  20.       Left            =   2280
  21.       TabIndex        =   3
  22.       Top             =   840
  23.       Width           =   2895
  24.    End
  25.    Begin TextBox txtWinInfo 
  26.       Height          =   285
  27.       Index           =   5
  28.       Left            =   2280
  29.       TabIndex        =   13
  30.       Top             =   2640
  31.       Width           =   2895
  32.    End
  33.    Begin TextBox txtWinInfo 
  34.       Height          =   285
  35.       Index           =   4
  36.       Left            =   2280
  37.       TabIndex        =   11
  38.       Top             =   2280
  39.       Width           =   2895
  40.    End
  41.    Begin TextBox txtWinInfo 
  42.       Height          =   285
  43.       Index           =   3
  44.       Left            =   2280
  45.       TabIndex        =   9
  46.       Top             =   1920
  47.       Width           =   2895
  48.    End
  49.    Begin TextBox txtWinInfo 
  50.       Height          =   285
  51.       Index           =   2
  52.       Left            =   2280
  53.       TabIndex        =   7
  54.       Top             =   1560
  55.       Width           =   2895
  56.    End
  57.    Begin TextBox txtWinInfo 
  58.       Height          =   285
  59.       Index           =   1
  60.       Left            =   2280
  61.       TabIndex        =   5
  62.       Top             =   1200
  63.       Width           =   2895
  64.    End
  65.    Begin CommandButton cmdClose 
  66.       Cancel          =   -1  'True
  67.       Caption         =   "&Close"
  68.       Default         =   -1  'True
  69.       Height          =   375
  70.       Left            =   240
  71.       TabIndex        =   14
  72.       Top             =   3000
  73.       Width           =   4935
  74.    End
  75.    Begin Line Line1 
  76.       X1              =   120
  77.       X2              =   5280
  78.       Y1              =   720
  79.       Y2              =   720
  80.    End
  81.    Begin Label Label2 
  82.       Alignment       =   2  'Center
  83.       BackColor       =   &H00C0C0C0&
  84.       Caption         =   "Click mouse anywhere to close this window."
  85.       Height          =   255
  86.       Left            =   0
  87.       TabIndex        =   1
  88.       Top             =   360
  89.       Width           =   5415
  90.    End
  91.    Begin Label Label3 
  92.       Alignment       =   1  'Right Justify
  93.       BackColor       =   &H00C0C0C0&
  94.       Caption         =   "Window Text:"
  95.       Height          =   255
  96.       Left            =   120
  97.       TabIndex        =   2
  98.       Top             =   840
  99.       Width           =   2055
  100.    End
  101.    Begin Label Label8 
  102.       Alignment       =   1  'Right Justify
  103.       BackColor       =   &H00C0C0C0&
  104.       Caption         =   "Extended Style Flags:"
  105.       Height          =   255
  106.       Left            =   120
  107.       TabIndex        =   12
  108.       Top             =   2640
  109.       Width           =   2055
  110.    End
  111.    Begin Label Label7 
  112.       Alignment       =   1  'Right Justify
  113.       BackColor       =   &H00C0C0C0&
  114.       Caption         =   "Style Flags:"
  115.       Height          =   255
  116.       Left            =   120
  117.       TabIndex        =   10
  118.       Top             =   2280
  119.       Width           =   2055
  120.    End
  121.    Begin Label Label6 
  122.       Alignment       =   1  'Right Justify
  123.       BackColor       =   &H00C0C0C0&
  124.       Caption         =   "Parent Window:"
  125.       Height          =   255
  126.       Left            =   120
  127.       TabIndex        =   8
  128.       Top             =   1920
  129.       Width           =   2055
  130.    End
  131.    Begin Label Label5 
  132.       Alignment       =   1  'Right Justify
  133.       BackColor       =   &H00C0C0C0&
  134.       Caption         =   "Window Handle:"
  135.       Height          =   255
  136.       Left            =   120
  137.       TabIndex        =   6
  138.       Top             =   1560
  139.       Width           =   2055
  140.    End
  141.    Begin Label Label4 
  142.       Alignment       =   1  'Right Justify
  143.       BackColor       =   &H00C0C0C0&
  144.       Caption         =   "Class Name:"
  145.       Height          =   255
  146.       Left            =   120
  147.       TabIndex        =   4
  148.       Top             =   1200
  149.       Width           =   2055
  150.    End
  151.    Begin Label Label1 
  152.       Alignment       =   2  'Center
  153.       BackColor       =   &H00C0C0C0&
  154.       Caption         =   "Move mouse over the window you want information about."
  155.       Height          =   255
  156.       Left            =   0
  157.       TabIndex        =   0
  158.       Top             =   120
  159.       Width           =   5415
  160.    End
  161. End
  162. Option Explicit
  163.  
  164. 'Keep track of the current window to eliminate unecessary updates
  165. Dim currWindow As Integer
  166.  
  167. Sub cmdClose_Click ()
  168.     Unload Me
  169. End Sub
  170.  
  171. Sub cmdClose_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
  172.     Dim i As Integer, xyPos As Long, hWnd As Integer
  173.     Dim buff As String * 256
  174.  
  175.     'Get mouse position in screen pixels
  176.     xyPos = GetMessagePos()
  177.  
  178.     'Get handle to window under mouse cursor
  179.     hWnd = WindowFromPoint(xyPos)
  180.     If hWnd <> currWindow Then
  181.         'If window has changed, display new information
  182.         i = GetWindowText(hWnd, buff, 256)
  183.         txtWinInfo(0) = Left$(buff, i)
  184.         i = GetClassName(hWnd, buff, 256)
  185.         txtWinInfo(1) = Left$(buff, i)
  186.         txtWinInfo(2) = "&H" & Right$("000" & Hex$(hWnd), 4)
  187.         txtWinInfo(3) = "&H" & Right$("000" & Hex$(GetParent(hWnd)), 4)
  188.         txtWinInfo(4) = "&H" & Right$("0000000" & Hex$(GetWindowLong(hWnd, GWL_STYLE)), 8)
  189.         txtWinInfo(5) = "&H" & Right$("0000000" & Hex$(GetWindowLong(hWnd, GWL_EXSTYLE)), 8)
  190.         currWindow = hWnd
  191.     End If
  192. End Sub
  193.  
  194. Sub cmdClose_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
  195.     Unload Me
  196. End Sub
  197.  
  198. Sub Form_Load ()
  199.     Dim i As Integer, j As Long
  200.  
  201.     currWindow = 0
  202.  
  203.     'Center form on screen
  204.     Move (Screen.Width - Width) / 2, (Screen.Height - Height) / 2
  205.  
  206.     'Prevent user from editing text boxes
  207.     For i = 0 To 5
  208.         j = SendMessage(txtWinInfo(i).hWnd, EM_SETREADONLY, True, 0&)
  209.     Next i
  210.  
  211.     'To correctly handle pressing of the close button, we'll have all
  212.     'mouse messages sent to the close button. The button's MouseMove
  213.     'event will update the display of window information, and when a
  214.     'MouseUp event occurs, we unload this form
  215.     j = SetCapture(cmdClose.hWnd)
  216.  
  217.     'This is needed because the main form has set an hourglass cursor
  218.     Screen.MousePointer = 0
  219.  
  220. End Sub
  221.  
  222. Sub Form_Paint ()
  223.     Dim i As Integer, X As Long, Y As Long
  224.  
  225.     'Since some programmers may not have the 3D panel
  226.     'control, we'll just draw our own 3D shading
  227.     X = Screen.TwipsPerPixelX: Y = Screen.TwipsPerPixelY
  228.  
  229.     'Clear any previously-drawn lines
  230.     Line (0, 0)-(ScaleWidth, ScaleHeight), backcolor, BF
  231.  
  232.     'And make each text box look "sunken"
  233.     For i = 0 To 5
  234.         CurrentX = txtWinInfo(i).Left - X
  235.         CurrentY = txtWinInfo(i).Top + txtWinInfo(i).Height
  236.         Line -Step(0, -(txtWinInfo(i).Height + Y)), RGB(92, 92, 92)
  237.         Line -Step(txtWinInfo(i).Width + X, 0), RGB(92, 92, 92)
  238.         Line -Step(0, txtWinInfo(i).Height + Y), RGB(255, 255, 255)
  239.         Line -Step(-(txtWinInfo(i).Width + X), 0), RGB(255, 255, 255)
  240.     Next i
  241.  
  242. End Sub
  243.  
  244.