📄 ftesttree.frm
字号:
"FROM Product " + _
"WHERE (((Product.PkID)="
Private Const mcSQL_DPRD2 As String = "))"
'## Find Group By Desc
Private Const mcSQL_FGRP As String = "SELECT DISTINCTROW PkID, Desc AS Desc1, GroupID " + _
"FROM [Group] " + _
"WHERE ((Active)=True) AND (Type=0) " + _
"ORDER BY GroupID, SeqNum, PkID"
'## Find Product By Desc
Private Const mcSQL_FPRD As String = "SELECT DISTINCTROW PkID, [Code] + ' - ' + [Desc] AS Desc1, GroupID " + _
"FROM [Product] " + _
"WHERE ((Active)=True) " + _
"ORDER BY Code"
Private moFindRS As ADODB.Recordset
Private moGrpRS As ADODB.Recordset
Private mbFindNext As Boolean
Private meFindMode As eFindMode
Private mcDB As cDB
Private mbIsBusy As Boolean
'===========================================================================
' Form Events
'
Private Sub chkDialog_Click(Index As Integer)
Dim bState As Boolean
bState = CBool(chkDialog(Index).Value = 1)
With moTree
Select Case Index
Case [Drag Drop]: .DragEnabled = bState
Case [Label Edit]: .Ctrl.LabelEdit = CByte(Abs(bState = False))
Case [HotTracking]: .Ctrl.HotTracking = bState
End Select
End With
'
'## mnuTree Pop-up Menu enable/disable checks
'
mnuTree(Index + 7).Checked = chkDialog(Index).Value '@@ v01.00.01 Adjust pop menu checks
End Sub
Private Sub cmdDialog_Click(Index As Integer)
'
'## Add/Rename/Move/Delete
'
Action Index
End Sub
Private Sub cmdDialog_GotFocus(Index As Integer)
pShowEvent ""
meFocus = [No Selection]
End Sub
Private Sub cmdMove_Click(Index As Integer)
With moTree
.ScrollView CByte(Index) '@@ cTREEVIEW.CLS (v01.00.01) example
.Ctrl.SetFocus
End With
End Sub
Private Sub Form_Load()
Set moTree = New cTreeView
Randomize Timer
With moTree
'
'## Hook treeview control
'
.HookCtrl tvwDialog
.Redraw False
'
'## Set TreeView features
'
With .Ctrl
.Style = tvwTreelinesPlusMinusPictureText
.BorderStyle = vbFixedSingle
.LineStyle = tvwRootLines
.Indentation = 10
.ImageList = imgDialog
.FullRowSelect = False
.HideSelection = False
.HotTracking = True
'##--- ADO Code Start ----------------------------------
'
'## Build TreeView data
'
pInitData
'
'##--- ADO Code End ------------------------------------
pShowNodeDetails .SelectedItem
End With
.ContextMenuMode = [After Click]
.DragEnabled = True
.Redraw True
End With
'
'## Set Textbox focus to nothing
'
meFocus = [No Selection]
optFind([Product]).Value = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set moTree = Nothing
End Sub
Private Sub mnuNode_Click(Index As Integer) '@@ v01.00.01
Set moSelectedNode = tvwDialog.SelectedItem '## Remember selected node
Select Case Index
Case [Add Node]
cmdDialog_Click Index '## Press Add button
txtDialog([Parent Node]).Text = moSelectedNode.Text '## Update screen with selected item
txtDialog([Node Text]).SetFocus '## Set focus to the next step
Case [Rename Node]
cmdDialog_Click Index '## Press Rename button
txtDialog([Node Text]).Text = moSelectedNode.Text '## Update screen with selected item
txtDialog([Parent Node]).SetFocus '## Set focus to the next step
Case [Move Node]
cmdDialog_Click Index '## Press Move button
txtDialog([Node Text]).Text = moSelectedNode.Text '## Update screen with selected item
txtDialog([Parent Node]).SetFocus '## Set focus to the next step
Case [Delete Node]
cmdDialog_Click [Delete Node] '## Press Delete button
txtDialog([Node Text]).Text = moSelectedNode.Text '## Update screen with selected item
cmdDialog_Click [Execute Mode] '## Press Go button & start delete action
End Select
End Sub
Private Sub mnuTree_Click(Index As Integer) '@@ v01.00.01
Select Case Index
Case 0 To 5 '## Home/PgUp/Up/ Down/PgDn/End
cmdMove_Click Index '## Press designated TreeView Scroll Button
Case 7 To 9 '## Enable/Disable Drag'n'Drop/Label Edit/Hot Tracking
With chkDialog(Index - 7)
.Value = Abs(Not CBool(.Value)) '## Flip value
End With
chkDialog_Click Index - 7 '## Raise chkDialog Event
End Select
End Sub
Private Sub tvwDialog_AfterLabelEdit(Cancel As Integer, NewString As String)
'
'## Note: TreeView events can also be directly handled from the form
'
'##--- ADO Code Start ----------------------------------
If NewString <> msNodeText Then
If Not pRenameRecord(tvwDialog.SelectedItem, NewString) Then
MsgBox "Unable to rename the selected node.", _
vbApplicationModal + vbExclamation + vbOKOnly, _
"Rename Node"
moSelectedNode.Text = msNodeText
End If
msNodeText = ""
End If
'##--- ADO Code End ------------------------------------
pShowEvent "*Rename*"
End Sub
Private Sub tvwDialog_BeforeLabelEdit(Cancel As Integer)
Set moSelectedNode = tvwDialog.SelectedItem
msNodeText = moSelectedNode.Text
pShowEvent "*Edit*"
End Sub
Private Sub tvwDialog_Collapse(ByVal Node As MSComctlLib.Node)
pShowNodeDetails Node
pShowEvent "*Collapsed*"
End Sub
Private Sub tvwDialog_Expand(ByVal Node As MSComctlLib.Node)
pShowNodeDetails Node
pShowEvent "*Expanded*"
'##--- ADO Code Start ----------------------------------
pExpandNode Node
'##--- ADO Code End ------------------------------------
End Sub
Private Sub tvwDialog_KeyUp(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyDelete '## Delete Node
Set moSelectedNode = tvwDialog.SelectedItem '## Remember selected node
cmdDialog_Click [Delete Node] '## Press Delete button
txtDialog([Node Text]).Text = moSelectedNode.Text '## Update screen with selected item
cmdDialog_Click [Execute Mode] '## Press Go button & start delete action
End Select
End Sub
Private Sub txtDialog_GotFocus(Index As Integer)
'
'## Reset Event Label
'
pShowEvent ""
'
'## Select all text in the selected Textbox control
'
pHiLite txtDialog(Index)
Select Case Index
'
'## First Textbox
'
Case [Node Text]
meFocus = [Node Text] '## Capture textbox focus
Select Case meMode
Case [Add Node]
'
'## Give user instructions
'
lblComments.Caption = "Enter the description of the new node."
Case [Rename Node]
lblComments.Caption = "Select/Click the node to be renamed."
Case [Move Node]
lblComments.Caption = "Select/Click the node to be moved."
Case [Delete Node]
lblComments.Caption = "Select/Click the node to be deleted."
End Select
'
'## Second Textbox
'
Case [Parent Node]
meFocus = [Parent Node] '## Capture textbox focus
Select Case meMode
Case [Add Node]
lblComments.Caption = "Select/Click the parent node."
Case [Rename Node]
lblComments.Caption = "Enter the new description of the selected node."
Case [Move Node]
lblComments.Caption = "Select/Click the destination node."
End Select
End Select
End Sub
Private Sub txtDialog_KeyPress(Index As Integer, KeyAscii As Integer)
Select Case Index
'
'## First Textbox
'
Case [Node Text]
Select Case meMode
Case [Rename Node], [Move Node], [Delete Node]
'
'## We only want the user to click on a node
'
KeyAscii = 0
Beep
End Select
'
'## Second Textbox
'
Case [Parent Node]
Select Case meMode
Case [Add Node], [Move Node]
'
'## We only want the user to click on a node
'
KeyAscii = 0
Beep
End Select
End Select
End Sub
Private Sub txtDialog_LostFocus(Index As Integer)
lblComments.Caption = ""
End Sub
'===========================================================================
' Form Events: Find controls
'
Private Sub cmdFind_Click(Index As Integer)
Dim oBusy As cHourglass
Set oBusy = New cHourglass
Select Case Index
Case [Find First]
If Not pFindFirst Then
Set oBusy = Nothing
MsgBox "No record found.", _
vbApplicationModal + vbInformation + vbOKOnly, _
"Find Record"
txtFind.SetFocus
Else
tvwDialog.SetFocus
End If
Case [Find Next]
If Not pFindNext Then
If mbFindNext Then
Set oBusy = Nothing
MsgBox "No further records found.", _
vbApplicationModal + vbInformation + vbOKOnly, _
"Find Record"
Else
Set oBusy = Nothing
MsgBox "No record found.", _
vbApplicationModal + vbInformation + vbOKOnly, _
"Find Record"
End If
txtFind.SetFocus
Else
tvwDialog.SetFocus
End If
Case [Find Previous]
If Not pFindPrevious Then
If mbFindNext Then
Set oBusy = Nothing
MsgBox "No further records found.", _
vbApplicationModal + vbInformation + vbOKOnly, _
"Find Record"
Else
Set oBusy = Nothing
MsgBox "No record found.", _
vbApplicationModal + vbInformation + vbOKOnly, _
"Find Record"
End If
txtFind.SetFocus
Else
tvwDialog.SetFocus
End If
End Select
End Sub
Private Sub optFind_Click(Index As Integer)
meFindMode = CByte(Abs(optFind([Product]).Value = True))
pFindReset
End Sub
Private Sub txtFind_Change()
pFindReset
cmdFind([Find First]).Enabled = (Len(txtFind.Text) > 0)
End Sub
Private Sub txtFind_GotFocus()
pHiLite txtFind
End Sub
'===========================================================================
' cTreeView Class Events
'
Private Sub moTree_ContextMenu(Node As MSComctlLib.Node, X As Single, Y As Single)
'
'## Right Button was pressed requesting a Context/Popup menu
'
Debug.Print ">> "; Me.Name; ".moTree::ContextMenu -> Node.Text = ";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -