home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / QBAS / 5PAK20.ZIP / NUMW20.ZIP / SAMPLE.ZIP / GENERAPP.FRM next >
Text File  |  1993-08-03  |  6KB  |  186 lines

  1. VERSION 2.00
  2. Begin Form NumWin_Form 
  3.    Caption         =   "NumWin  Test"
  4.    ClientHeight    =   5160
  5.    ClientLeft      =   1200
  6.    ClientTop       =   1845
  7.    ClientWidth     =   5025
  8.    Height          =   5850
  9.    Left            =   1140
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   5160
  12.    ScaleWidth      =   5025
  13.    Top             =   1215
  14.    Width           =   5145
  15.    Begin Numwin NumWin1 
  16.       Left            =   720
  17.       Top             =   120
  18.    End
  19.    Begin CommandButton BTN_Exit 
  20.       Caption         =   "Exit"
  21.       Height          =   375
  22.       Left            =   3720
  23.       TabIndex        =   2
  24.       Top             =   240
  25.       Width           =   1215
  26.    End
  27.    Begin TextBox Text2 
  28.       Height          =   4215
  29.       Left            =   120
  30.       MultiLine       =   -1  'True
  31.       ScrollBars      =   3  'Both
  32.       TabIndex        =   1
  33.       Text            =   "Text2"
  34.       Top             =   840
  35.       Width           =   4815
  36.    End
  37.    Begin CommandButton Btn_Refresh 
  38.       Caption         =   "Refresh"
  39.       Height          =   375
  40.       Left            =   2400
  41.       TabIndex        =   0
  42.       Top             =   240
  43.       Width           =   1215
  44.    End
  45.    Begin Menu nmu_File 
  46.       Caption         =   "&File"
  47.       Begin Menu mnu_Exit 
  48.          Caption         =   "&Exit"
  49.       End
  50.    End
  51.    Begin Menu mnu_Edit 
  52.       Caption         =   "&Edit"
  53.       Begin Menu mnu_Cut 
  54.          Caption         =   "Cu&t"
  55.       End
  56.       Begin Menu mnu_Copy 
  57.          Caption         =   "&Copy"
  58.       End
  59.       Begin Menu mnu_Paste 
  60.          Caption         =   "&Paste"
  61.       End
  62.       Begin Menu mnu_submenu 
  63.          Caption         =   "SubMenu"
  64.          Begin Menu mnu_submenu1 
  65.             Caption         =   "SubMenu 1"
  66.          End
  67.          Begin Menu mnu_submenu2 
  68.             Caption         =   "SubMenu 2"
  69.          End
  70.       End
  71.    End
  72. End
  73. Option Explicit
  74.  
  75. ' The Action parameter
  76. Const NUMWIN_REFRESH = 10
  77.  
  78. ''
  79. '' some of the APIs which might be useful
  80. Declare Function GetClassName Lib "User" (ByVal hWnd As Integer, ByVal lpClassName As String, ByVal nMaxCount As Integer) As Integer
  81.  
  82. '' a constant for use with GetWindowWord and GetModuleFileName
  83. Const GWW_HINSTANCE = (-6)
  84. Declare Function GetWindowWord Lib "User" (ByVal hWnd As Integer, ByVal nIndex As Integer) As Integer
  85. Declare Function GetModuleFileName Lib "Kernel" (ByVal hModule As Integer, ByVal lpFilename As String, ByVal nSize As Integer) As Integer
  86.  
  87. Sub BTN_Exit_Click ()
  88.     mnu_Exit_Click
  89. End Sub
  90.  
  91. Sub Btn_Refresh_Click ()
  92. ' PURPOSE: Fill the array with current values
  93. '''''''''''''''''''''''''''''''''''''''''''''''''
  94.     
  95.     Text2.Text = ""
  96.     NumWin1.Action = NUMWIN_REFRESH '10
  97.  
  98. End Sub
  99.  
  100. Sub Form_Load ()
  101. ' PURPOSE: Just load
  102. ''''''''''''''''''''''''''''''''''
  103.     top = 0
  104.     Left = 0
  105.  
  106. End Sub
  107.  
  108. Sub Form_Resize ()
  109.     If Me.WindowState = 0 Then
  110.         Me.Height = 5815
  111.         Me.Width = 5175
  112.     End If
  113. End Sub
  114.  
  115. Sub mnu_Exit_Click ()
  116.     End
  117. End Sub
  118.  
  119. Sub NumWin1_NumWinClick (Count As Integer)
  120. ' PURPOSE: Put all the window handles and window text in the text box
  121. ' COMMENTS: Three arrays are passed back from NUMWIN.VBX
  122. '           They are;
  123. '           1. HwndArray the hwnds of all windows.
  124. '           2. HwndParArray the parent hwnds.
  125. '               if zero then hwnd is a top level window.
  126. '           3. WinTextArray the window text appearing in
  127. '               the window bar.
  128. '           The variable Count returned is the total window count
  129. '
  130. '           Shows some of the things that can be done with APIs.
  131. '           Declares are in the module.
  132. '
  133. '           This test print out is somewhat long and in much more detail
  134. '           than is normally needed. Choose the data appropiate for your
  135. '           program.
  136. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  137. Dim Msg As String
  138. Dim CRLF As String
  139. Dim ndex As Integer
  140. Dim cbBuf As String * 64
  141. Dim cbCount As Integer
  142. Dim hInstance As Integer
  143.  
  144.     '' inits
  145.     CRLF = Chr$(13) + Chr$(10)
  146.     Msg = ""
  147.     '' go through all the hWnds
  148.     For ndex = 1 To Count
  149.         ''
  150.         '' the hWnd
  151.         Msg = Msg + "hWnd = " + Str$(NumWin1.HwndArray(ndex)) + CRLF
  152.         ''
  153.         '' parent of window
  154.         '' if hwnd parent = 0 then it is a top level window
  155.         '' use this technique to find all top level windows
  156.         If NumWin1.HwndParArray(ndex) = 0 Then
  157.             Msg = Msg + "Parent = " + "[TOPLEVEL WINDOW]" + CRLF
  158.             ''
  159.             '' this is for top level windows only
  160.             hInstance = GetWindowWord(NumWin1.HwndArray(ndex), GWW_HINSTANCE)
  161.             cbCount = GetModuleFileName(hInstance, cbBuf, 64)
  162.             cbBuf = Left$(cbBuf, cbCount)
  163.             Msg = Msg + "ModuleName = " + cbBuf + CRLF
  164.         Else
  165.             Msg = Msg + "Parent = " + Str$(NumWin1.HwndParArray(ndex)) + CRLF
  166.         End If
  167.         ''
  168.         '' the class name contains additional information about the window
  169.         '' use the API call to get the ClassName
  170.         cbCount = GetClassName(NumWin1.HwndArray(ndex), cbBuf, 64)
  171.         cbBuf = Left$(cbBuf, cbCount)
  172.         Msg = Msg + "Class Name = " + cbBuf + CRLF
  173.         ''
  174.         '' window text
  175.         If Len(NumWin1.WinTextArray(ndex)) <> "0" Then
  176.             Msg = Msg + "Text = " + NumWin1.WinTextArray(ndex) + CRLF + CRLF
  177.         Else
  178.             Msg = Msg + "Text = <NONE>" + CRLF + CRLF
  179.         End If
  180.     Next ndex
  181.  
  182.     Text2.Text = "Number of Windows = " + Str$(Count) + CRLF + CRLF + Msg
  183.  
  184. End Sub
  185.  
  186.