⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmqueryresults.frm

📁 GIS地理信息系统开发。大名鼎鼎的MAPX+VisualBasic6.0软件开发
💻 FRM
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmQueryResults 
   Caption         =   "Query Results"
   ClientHeight    =   4785
   ClientLeft      =   5235
   ClientTop       =   2580
   ClientWidth     =   4335
   Icon            =   "frmQueryResults.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   4785
   ScaleWidth      =   4335
   Begin VB.CommandButton OKButton 
      Caption         =   "OK"
      Default         =   -1  'True
      Height          =   375
      Left            =   3000
      TabIndex        =   1
      Top             =   120
      Width           =   1215
   End
   Begin MSComctlLib.TreeView QueryTree 
      Height          =   4575
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   2775
      _ExtentX        =   4895
      _ExtentY        =   8070
      _Version        =   393217
      LabelEdit       =   1
      Style           =   6
      Appearance      =   1
   End
End
Attribute VB_Name = "frmQueryResults"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

' This sample application and corresponding sample code is provided
' for example purposes only.  It has not undergone rigorous testing
' and as such should not be shipped as part of a final application
' without extensive testing on the part of the organization releasing
' the end-user product.

Private Sub Form_Load()
    Dim i As Integer
    Dim lyr As Layer
    Dim ftr As Feature
    Dim ds As Dataset
    Dim fld As MapXLib.Field
    Dim lyrNode As Node
    Dim ftrNode As Node
    
    ' This function performs a query of all the features selected on the map.
    ' It does this by looping through every selected feature in every layer.
    ' Then, for a given item, it loops over every field in every dataset of
    ' that given layer, and retrieves the value of that field.
    For Each lyr In fMainForm.Map1.Layers
        ' Avoid layers that have nothing selected in them
        If lyr.Selection.Count <> 0 Then
            ' Most of the MapInfo tables have some data of their own; we
            ' want to retrieve this data, in addition to the data added by
            ' other datasets.  We do this by adding the table itself as a
            ' dataset.
            fMainForm.Map1.Datasets.Add miDataSetLayer, lyr, "Temporary Dataset"
            
            ' Inside the following loops, we will be performing a bunch of
            ' "field.name" and "dataset.value" calls.  Putting a BeginAccess
            ' call here will lock the table so that all of these operations
            ' can be sped up.
            lyr.BeginAccess miAccessRead
            
            ' The parent node is the layer name
            Set lyrNode = QueryTree.Nodes.Add(, tvwFirst, lyr, lyr.Name)
            lyrNode.Expanded = True
            
            For Each ftr In lyr.Selection
                ' The children of the layer are the individual features
                Set ftrNode = QueryTree.Nodes.Add(lyrNode, tvwChild, lyr.Name & ftr.Name & Str$(ftr.FeatureID), ftr.Name)
                
                For Each ds In lyr.Datasets
                    For Each fld In ds.Fields
                        ' Each feature has data attached to it; add this data as a child of
                        ' the feature
                        If ds.Value(ftr, fld.Name) <> vbNull Then
                           QueryTree.Nodes.Add ftrNode, tvwChild, , fld.Name & ": " & ds.Value(ftr, fld.Name)
                        End If
                    Next
                Next
            Next
            
            ' Release the lock that we placed on the table up above.
            lyr.EndAccess miAccessEnd
            
            ' Now, the layer as a dataset is no longer needed
            fMainForm.Map1.Datasets.Remove "Temporary Dataset"
        End If
    Next
End Sub

Private Sub Form_Resize()
    ' Avoid resizing to zero
    If Me.ScaleHeight > 240 And QueryTree.Width > 1515 Then
        ' Resize the query results so that they take up (almost) all of the
        ' window.
        QueryTree.Height = Me.ScaleHeight - 240
        QueryTree.Width = Me.ScaleWidth - 1515
        OKButton.Left = Me.ScaleWidth - 1290
    End If
End Sub

Private Sub OKButton_Click()
    Unload Me
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -