📄 theme1.frm
字号:
VERSION 5.00
Begin VB.Form Theme1
Caption = "Create a Thematic Map"
ClientHeight = 3435
ClientLeft = 1815
ClientTop = 3540
ClientWidth = 6690
LinkTopic = "Form2"
PaletteMode = 1 'UseZOrder
ScaleHeight = 3435
ScaleWidth = 6690
Begin VB.Data Data1
Caption = "Data1"
Connect = "Access"
DatabaseName = "C:\Program Files\MapInfo Mapx\Data\mapstats.mdb"
DefaultCursorType= 0 'DefaultCursor
DefaultType = 2 'UseODBC
Exclusive = 0 'False
Height = 615
Left = 240
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "Asia"
Top = 2760
Visible = 0 'False
Width = 1140
End
Begin VB.ComboBox Combo2
Height = 315
Left = 2760
TabIndex = 7
Top = 2280
Width = 3615
End
Begin VB.ListBox List1
Height = 1230
Left = 2760
MultiSelect = 1 'Simple
TabIndex = 5
Top = 720
Width = 3495
End
Begin VB.CommandButton Command2
Caption = "Cancel"
Height = 375
Left = 3240
TabIndex = 4
Top = 2880
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "OK"
Height = 375
Left = 1680
TabIndex = 3
Top = 2880
Width = 1455
End
Begin VB.ComboBox Combo1
Height = 315
Left = 2760
TabIndex = 0
Text = "Combo1"
Top = 240
Width = 3615
End
Begin VB.Label Label3
Caption = "Theme Type:"
Height = 255
Left = 360
TabIndex = 6
Top = 2160
Width = 2295
End
Begin VB.Label Label2
Caption = "Choose Variable(s) to Theme:"
Height = 255
Left = 240
TabIndex = 2
Top = 600
Width = 2175
End
Begin VB.Label Label1
Caption = "Choose DataSet to Theme:"
Height = 255
Left = 240
TabIndex = 1
Top = 240
Width = 2055
End
End
Attribute VB_Name = "Theme1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' 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 Combo1_Click()
' fill in list box with field names
List1.Clear
For Each Field In Data1.Recordset.Fields
List1.AddItem Field.Name
Next
End Sub
Private Sub Command1_Click()
' This code looks a bit hairy, but is quite straight forward.
' We are simply setting the themtype variable based on what's
' selected in the list and combo box.
' Then, we are filling in a field array with the field number
' of the selected fields to map, and passing that to Themes.Add
Dim thmtype As Integer
If List1.SelCount = 0 Then
GoTo done
ElseIf List1.SelCount = 1 Then
If Combo2.ListIndex = 0 Then
thmtype = miThemeRanged
ElseIf Combo2.ListIndex = 1 Then
thmtype = miThemeGradSymbol
ElseIf Combo2.ListIndex = 2 Then
thmtype = miThemeDotDensity
Else
thmtype = miThemeIndividualValue
End If
Else
If Combo2.ListIndex = 0 Then
thmtype = miThemePieChart
Else
thmtype = miThemeBarChart
End If
End If
Dim flds As New MapXLib.Fields
flds.Add 1 'add first col because contain geocolumn
Dim i As Integer
For i = 1 To List1.ListCount
If List1.Selected(i - 1) Then
flds.Add i
End If
Next
Dim ds As Dataset
Set ds = Main.Map1.Datasets.Add(miDataSetDAO, Data1.Recordset.Clone, , "GEONAME", , "Asia", flds)
' Now create theme. Fill out fieldarray with fields to shade.
Dim fieldarray() As Integer
ReDim fieldarray(1 To flds.Count - 1)
For i = 2 To flds.Count
fieldarray(i - 1) = i
Next
ds.Themes.Add thmtype, fieldarray
done:
Unload Me
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
On Error GoTo err_refresh
Data1.Refresh
On Error GoTo 0
Combo1.AddItem "Asia Information"
Combo1.ListIndex = 0
Exit Sub
err_refresh:
' Try to find mapstats.mdb based on the app location.
If Dir$(App.Path + "\..\..\..\data\mapstats.mdb") <> "" Then
Data1.DatabaseName = App.Path + "\..\..\data\mapstats.mdb"
Resume
Else
MsgBox "Cannot find file mapstats.mdb, Please check the README file.", vbOKOnly, "Error"
End
End If
End Sub
Private Sub list1_Click()
' We want to set the combo box of theme types
' based on the number of data columns selected.
Combo2.Clear
If List1.SelCount = 0 Then
' do nothing
ElseIf List1.SelCount = 1 Then
Combo2.AddItem "Ranges"
Combo2.AddItem "Graduated Symbol"
Combo2.AddItem "Dot Density"
Combo2.AddItem "Individual Value"
If Data1.Recordset.Fields(List1.ListIndex).Type = dbText Then
Combo2.ListIndex = 3
Else
Combo2.ListIndex = 0
End If
Else
Combo2.AddItem "Pie"
Combo2.AddItem "Bar"
Combo2.ListIndex = 0
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -