home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / VISUAL_B / CODIGO_1 / NUMWIN20 / GENERAPP.FRM (.txt) next >
Encoding:
Visual Basic Form  |  1993-12-23  |  6.1 KB  |  174 lines

  1. VERSION 2.00
  2. Begin Form NumWin_Form 
  3.    Caption         =   "NumWin  Test"
  4.    ClientHeight    =   5145
  5.    ClientLeft      =   1215
  6.    ClientTop       =   1860
  7.    ClientWidth     =   5010
  8.    Height          =   5835
  9.    Left            =   1155
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   5145
  12.    ScaleWidth      =   5010
  13.    Top             =   1230
  14.    Width           =   5130
  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.       Top             =   840
  34.       Width           =   4815
  35.    End
  36.    Begin CommandButton Btn_Refresh 
  37.       Caption         =   "Refresh"
  38.       Height          =   375
  39.       Left            =   2400
  40.       TabIndex        =   0
  41.       Top             =   240
  42.       Width           =   1215
  43.    End
  44.    Begin Menu nmu_File 
  45.       Caption         =   "&File"
  46.       Begin Menu mnu_Exit 
  47.          Caption         =   "&Exit"
  48.       End
  49.    End
  50.    Begin Menu mnu_Edit 
  51.       Caption         =   "&Edit"
  52.       Begin Menu mnu_Cut 
  53.          Caption         =   "Cu&t"
  54.       End
  55.       Begin Menu mnu_Copy 
  56.          Caption         =   "&Copy"
  57.       End
  58.       Begin Menu mnu_Paste 
  59.          Caption         =   "&Paste"
  60.       End
  61.       Begin Menu mnu_submenu 
  62.          Caption         =   "SubMenu"
  63.          Begin Menu mnu_submenu1 
  64.             Caption         =   "SubMenu 1"
  65.          End
  66.          Begin Menu mnu_submenu2 
  67.             Caption         =   "SubMenu 2"
  68.          End
  69.       End
  70.    End
  71. Option Explicit
  72. ' The Action parameter
  73. Const NUMWIN_REFRESH = 10
  74. '' some of the APIs which might be useful
  75. Declare Function GetClassName Lib "User" (ByVal hWnd As Integer, ByVal lpClassName As String, ByVal nMaxCount As Integer) As Integer
  76. '' a constant for use with GetWindowWord and GetModuleFileName
  77. Const GWW_HINSTANCE = (-6)
  78. Declare Function GetWindowWord Lib "User" (ByVal hWnd As Integer, ByVal nIndex As Integer) As Integer
  79. Declare Function GetModuleFileName Lib "Kernel" (ByVal hModule As Integer, ByVal lpFilename As String, ByVal nSize As Integer) As Integer
  80. Sub BTN_Exit_Click ()
  81.     mnu_Exit_Click
  82. End Sub
  83. Sub Btn_Refresh_Click ()
  84. ' PURPOSE: Fill the array with current values
  85. '''''''''''''''''''''''''''''''''''''''''''''''''
  86.     Text2.Text = ""
  87.     NumWin1.Action = NUMWIN_REFRESH '10
  88. End Sub
  89. Sub Form_Load ()
  90. ' PURPOSE: Just load
  91. ''''''''''''''''''''''''''''''''''
  92.     If Me.windowstate = 0 Then
  93.         top = 0
  94.         Left = 0
  95.     End If
  96. End Sub
  97. Sub Form_Resize ()
  98.     If Me.windowstate = 0 Then
  99.         Me.Height = 5815
  100.         Me.Width = 5175
  101.     End If
  102. End Sub
  103. Sub mnu_Exit_Click ()
  104.     End
  105. End Sub
  106. Sub NumWin1_NumWinClick (Count As Integer)
  107. ' PURPOSE: Put all the window handles and window text in the text box
  108. ' COMMENTS: Three arrays are passed back from NUMWIN.VBX
  109. '           They are;
  110. '           1. HwndArray the hwnds of all windows.
  111. '           2. HwndParArray the parent hwnds.
  112. '               if zero then hwnd is a top level window.
  113. '           3. WinTextArray the window text appearing in
  114. '               the window bar or control caption.
  115. '           The variable Count returned is the total window count
  116. '           Shows some of the things that can be done with APIs.
  117. '           Declares are in this module.
  118. '           This test print out is somewhat long and in much more detail
  119. '           than is normally needed. Choose the data appropiate for your
  120. '           program.
  121. ' IMPORTANT ... IMPORTANT ... IMPORTANT
  122. '   DATA IN THE ARRAYS IS ONLY VALID IN THIS SUB ROUTINE.
  123. '   ALWAYS USE THE NUMWINx.REFRESH COMMAND IMMEDIATELY BEFORE ACCESSING DATA.
  124. '   WINDOWS CAN UPDATE THE SCREEN AT ANY TIME AND DESTROY OR CREATE NEW WINDOWS.
  125. '   CAUTION IS ADVISED WHEN USING THIS DATA. IT IS PRUDENT PROGRAMMING PRACTICE TO
  126. '   ALWAYS TEST FOR VALIDITY BEFORE USE TO PREVENT PROBLEMS FROM OCCURRING.
  127. '   THE WINDOWS API IsWindow() CAN PERFORM A HWND VALIDITY TEST.
  128. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  129. Dim Msg As String
  130. Dim CRLF As String
  131. Dim ndex As Integer
  132. Dim cbBuf As String * 64
  133. Dim cbCount As Integer
  134. Dim hInstance As Integer
  135.     '' inits
  136.     CRLF = Chr$(13) + Chr$(10)
  137.     Msg = ""
  138.     '' go through all the hWnds
  139.     For ndex = 1 To Count
  140.         ''
  141.         '' the hWnd
  142.         Msg = Msg + "hWnd = " + Str$(NumWin1.HwndArray(ndex)) + CRLF
  143.         ''
  144.         '' parent of window
  145.         '' if hwnd parent = 0 then it is a top level window
  146.         '' use this technique to find all top level windows
  147.         If NumWin1.HwndParArray(ndex) = 0 Then
  148.             Msg = Msg + "Parent = " + "[TOPLEVEL WINDOW]" + CRLF
  149.             ''
  150.             '' this is for top level windows only
  151.             hInstance = GetWindowWord(NumWin1.HwndArray(ndex), GWW_HINSTANCE)
  152.             cbCount = GetModuleFileName(hInstance, cbBuf, 64)
  153.             cbBuf = Left$(cbBuf, cbCount)
  154.             Msg = Msg + "ModuleName = " + cbBuf + CRLF
  155.         Else
  156.             Msg = Msg + "Parent = " + Str$(NumWin1.HwndParArray(ndex)) + CRLF
  157.         End If
  158.         ''
  159.         '' the class name contains additional information about the window
  160.         '' use the API call to get the ClassName
  161.         cbCount = GetClassName(NumWin1.HwndArray(ndex), cbBuf, 64)
  162.         cbBuf = Left$(cbBuf, cbCount)
  163.         Msg = Msg + "Class Name = " + cbBuf + CRLF
  164.         ''
  165.         '' window text
  166.         If Len(NumWin1.WinTextArray(ndex)) <> "0" Then
  167.             Msg = Msg + "Text = " + NumWin1.WinTextArray(ndex) + CRLF + CRLF
  168.         Else
  169.             Msg = Msg + "Text = <NONE>" + CRLF + CRLF
  170.         End If
  171.     Next ndex
  172.     Text2.Text = "Number of Windows = " + Str$(Count) + CRLF + CRLF + Msg
  173. End Sub
  174.