📄 clsr_p.cls
字号:
bCancel = 1
Exit Sub
End If
If mblnNotRespondKeyPress Then
Exit Sub
End If
End If
If Msg = WM_KEYDOWN Then
If Not (frmName.refInput.ReferVisible Or frmName.refInput1.ReferVisible Or frmName.refInput2.ReferVisible Or frmName.dtmInput.IsDropDown = 1) Then
If wParam = 38 Or wParam = 40 Then
mblnReadOnly = (Not My.blnMayChange) Or frmName.chkPrint(1).Value = 1 '权限控制
If mblnReadOnly Then
If My.bytRegion = FNote Then
If wParam = 38 Then
If frmName.grdCol.Row = 1 Then
mblnKeyDown = True
End If
ElseIf wParam = 40 Then
If frmName.grdCol.Row = frmName.grdCol.Rows - 1 Then
mblnKeyDown = True
End If
End If
Else
mblnKeyDown = True
End If
Else
mblnKeyDown = True
End If
ElseIf wParam = 37 Then ' left
If My.bytRegion = FField Or My.bytRegion = FHead Or My.bytRegion = FNote Or My.bytRegion = FGrid Or My.bytRegion = FcmdFooter Or My.bytRegion = FFooter Then
If Not ctrInput Is Nothing Then
If ctrInput.Name = "picInput" Then
If NewQ.SelStart = 0 Then
mblnKeyDown = True
End If
Else
If ctrInput.SelStart = 0 Then
mblnKeyDown = True
End If
End If
Else
mblnKeyDown = True
End If
Else
mblnKeyDown = True
End If
ElseIf wParam = 39 Then 'right
If My.bytRegion = FField Or My.bytRegion = FHead Or My.bytRegion = FNote Or My.bytRegion = FGrid Or My.bytRegion = FcmdFooter Or My.bytRegion = FFooter Then
If Not ctrInput Is Nothing Then
If ctrInput.Name = "picInput" Then
If NewQ.SelStart = Len(NewQ.Text) Then
mblnKeyDown = True
End If
Else
If ctrInput.SelStart = Len(ctrInput.Text) Then
mblnKeyDown = True
End If
End If
Else
mblnKeyDown = True
End If
Else
mblnKeyDown = True
End If
ElseIf wParam = 27 Then
mblnKeyDown = True
End If
End If
If wParam = 9 Or wParam = 13 Then
mblnKeyDown = True
End If
End If
If Msg = WM_KEYUP Then
If mblnKeyDown = False Then Exit Sub
mblnKeyDown = False
If wParam = 13 Then
If GetKeyState(17) < 0 Then
Exit Sub
End If
End If
If wParam = 37 Or wParam = 38 Or wParam = 39 Or wParam = 40 Or wParam = 9 Or wParam = 13 Then 'TAB键处理程序
If Not m_bBusy Then
m_bBusy = True
ShiftDown = GetKeyState(16) 'Shift 状态
TabOrder (wParam)
m_bBusy = False
End If
ElseIf wParam = 27 Then
Reload
End If
End If
End Sub
Private Sub mclsSubClass_WndProc(Msg As Long, wParam As Long, lParam As Long, Result As Long)
Dim lngX As Long, lngY As Long
Dim sinX As Single, sinY As Single
Dim lngCnt As Long
Dim i As Integer, mOldRow As Integer, mOldCol As Integer
Dim intRow As Integer
Static blnColDrag As Boolean
lngX = (lParam Mod (2 ^ 16)) * Screen.TwipsPerPixelX
lngY = (lParam \ (2 ^ 16)) * Screen.TwipsPerPixelY
sinX = lngX
sinY = lngY
If Msg = WM_LBUTTONUP Then
mclsSubClass.CallWndProc Msg, wParam, lParam
'确保第0列不被拖出
If blnColDrag Then
'If frmName.GrdCol.ColWidth(0) > 0 Then frmName.GrdCol.ColWidth(0) = 0
frmName.grdCol.ColWidth(0) = frmName.TextWidth("12345")
For i = 1 To frmName.grdCol.Cols - 1
If ColProperty(i).blnUsable = False Then
If frmName.grdCol.ColWidth(i) <> 0 Then frmName.grdCol.ColWidth(i) = 0
Else
If ColProperty(i).lngCtrType = TRefer Or ColProperty(i).lngCtrType = TRecList Or ColProperty(i).lngCtrType = tdate Then
If frmName.grdCol.ColWidth(i) < 500 Then frmName.grdCol.ColWidth(i) = 500
Else
If frmName.grdCol.ColWidth(i) < 100 Then frmName.grdCol.ColWidth(i) = 100
End If
End If
Next i
blnColDrag = False
With frmName.grdCol
My.blnRefresh = False
If My.bytRegion = FGrid Or My.bytRegion = FPicture Then
If My.bytIndex <> .col Then
.col = My.bytIndex
End If
If My.lngOldRow <> .Row Then
.Row = My.lngOldRow
End If
GrdInputButtonLocal .Row, .col
End If
TotalRowAdjust
My.blnRefresh = True
End With
End If
Exit Sub
End If
If Msg = WM_LBUTTONDOWN Then '鼠标左键按下
With frmName.grdCol
If .MouseRow < .FixedRows Then '点中固定行
'判断鼠标是否点中列线以便拖动
i = .MouseCol
If lngX >= .ColPos(i) + .ColWidth(i) - 50 Or lngX <= .ColPos(i) + 50 Then
blnColDrag = True
End If
End If
End With
mclsSubClass.CallWndProc Msg, wParam, lParam
Exit Sub
End If
If Msg = WM_PAINT Then
'取Paint事件矩形区域
If My.blnRefresh Then
'取Paint事件矩形区域
If Not m_pBusy Then
m_pBusy = True
GetUpdateRect frmName.grdCol.hWnd, GridClipRect, False
mclsSubClass.CallWndProc Msg, wParam, lParam
If frmName.grdCol.Visible Then
DrawGridLine
DrawReadOnlyCol
' Debug.Print Time
End If
m_pBusy = False
End If
End If
Else
mclsSubClass.CallWndProc Msg, wParam, lParam
End If
End Sub
Private Sub mclsHook_WndProc(Msg As Long, wParam As Long, lParam As Long, Result As Long)
Dim MinMax As MINMAXINFO
If Msg = WM_GETMINMAXINFO Then
CopyMemory MinMax, ByVal lParam, Len(MinMax)
MinMax.ptMinTrackSize.x = lngDefaultWidth \ Screen.TwipsPerPixelX
MinMax.ptMinTrackSize.y = lngDefaultHeight \ Screen.TwipsPerPixelY
MinMax.ptMaxTrackSize.x = 1800
MinMax.ptMaxTrackSize.y = 1600
CopyMemory ByVal lParam, MinMax, Len(MinMax)
Result = 0
Exit Sub
End If
If Msg = WM_PAINT Then
If My.blnRefresh Then
'取Paint事件矩形区域
GetUpdateRect frmName.hWnd, FormClipRect, False
mclsHook.CallWndProc Msg, wParam, lParam
If frmName.lblHead(5).Visible Then DrawTotalBox
End If
Else
mclsHook.CallWndProc Msg, wParam, lParam
End If
End Sub
Private Sub DrawGridLine()
Dim intI As Integer
Dim hdc As Long
Dim lngL As Long
Dim lngLeft As Long
Dim lngRight As Long
Dim lngTop As Long
Dim lngButton As Long
Dim lngWidth As Long
Dim lngHeight As Long
My.blnRefresh = False
With frmName.grdCol
hdc = GetDC(.hWnd)
'画GRID网格线
'画竖线
lngWidth = .width
lngHeight = .Height
intI = 1
lngLeft = .ColPos(intI) - Screen.TwipsPerPixelX
DrawALine hdc, lngLeft, 0, lngLeft, lngHeight, GridClipRect.Left, GridClipRect.top, GridClipRect.Right, GridClipRect.Bottom, SeparateLineColor
lngLeft = .ColPos(intI) + .ColWidth(intI) - Screen.TwipsPerPixelX
DrawALine hdc, lngLeft, 0, lngLeft, lngHeight, GridClipRect.Left, GridClipRect.top, GridClipRect.Right, GridClipRect.Bottom, SeparateLineColor
For intI = .LeftCol To .Cols - 1
lngLeft = .ColPos(intI) + .ColWidth(intI) - Screen.TwipsPerPixelX
If lngLeft >= lngWidth Then
Exit For
' ElseIf .ColWidth(intI) = 0 Or (Not .ColIsVisible(intI)) Then
Else
DrawALine hdc, lngLeft, 0, _
lngLeft, lngHeight, _
GridClipRect.Left, GridClipRect.top, GridClipRect.Right, GridClipRect.Bottom, SeparateLineColor
End If
Next intI
'画按纽
If My.bytRegion = FGrid And False Then
For intI = .LeftCol To .Cols - 1
If (Not ColProperty(intI).blnReadOnly) And (ColProperty(intI).lngCtrType = TRefer Or ColProperty(intI).lngCtrType = tdate) And .ColIsVisible(intI) And .ColWidth(intI) <> 0 And .ColPos(intI) + .ColWidth(intI) < .width Then
DrawAButton hdc, .ColPos(intI) + .ColWidth(intI) - intButtonWidth - 2 * Screen.TwipsPerPixelX, _
.RowPos(.Row) + 1 * Screen.TwipsPerPixelY, intButtonWidth, .RowHeight(0) - 2 * Screen.TwipsPerPixelY, 0, _
GridClipRect.Left, GridClipRect.top, GridClipRect.Right, GridClipRect.Bottom
End If
Next intI
End If
lngHeight = .RowHeight(0)
For intI = 1 To 40
'画水平线
If .RowHeight(0) * intI > .Height Then Exit For
If .Row > 0 And (intI = .Row - .TopRow + 1 Or intI = .Row + 1 - .TopRow + 1) Then
DrawBLine hdc, 0, lngHeight * intI - Screen.TwipsPerPixelY, _
lngWidth, lngHeight * intI - Screen.TwipsPerPixelY, _
CLng(RGB(0, 0, 255))
Else
DrawBLine hdc, 0, lngHeight * intI - Screen.TwipsPerPixelY, _
lngWidth, lngHeight * intI - Screen.TwipsPerPixelY, _
SeparateLineColor
End If
Next intI
End With
'画作废图片
If frmName.chkPrint(1).Value = 1 Then
With frmName.grdCol
DrawAIcon .hWnd, .Left + (.width - 140 * Screen.TwipsPerPixelX) \ 2, .RowHeight(0) + (.Height - .RowHeight(0) - 70 * Screen.TwipsPerPixelY) \ 2, 1024
End With
End If
ReleaseDC frmName.grdCol.hWnd, hdc
My.blnRefresh = True
End Sub
Private Sub DrawReadOnlyCol()
Dim intLeft As Integer
Dim i As Integer
Dim intR As Integer
Dim x1 As Long, x2 As Long, y1 As Long, y2 As Long
With frmName.grdCol
If .RowIsVisible(.Rows - 1) = False Then GoTo EndDraw
intLeft = 1
If intLeft = 0 Then intLeft = 1
For i = intLeft To .Cols - 1
If ColProperty(i).blnReadOnly And .ColIsVisible(i) And .ColWidth(i) <> 0 Then
If .RowPos(.Rows - 1) + .RowHeight(.Rows - 1) < .Height Then
For intR = 1 To 30
x1 = .ColPos(i)
y1 = .RowPos(.Rows - 1) + .RowHeight(0) * intR
If y1 > .Height Then Exit For
x2 = .ColPos(i) + .ColWidth(i) - 2 * Screen.TwipsPerPixelX
y2 = y1 + .RowHeight(0) - 2 * Screen.TwipsPerPixelY
DrawABox .hWnd, x1, y1, x2, y2, _
RGB(192, 192, 192), RGB(192, 192, 192)
Next intR
End If
End If
Next i
End With
EndDraw:
If frmName.chkPrint(1).Value = 1 Then
With frmName.grdCol
DrawAIcon .hWnd, .Left + (.width - 140 * Screen.TwipsPerPixelX) \ 2, .RowHeight(0) + (.Height - .RowHeight(0) - 70 * Screen.TwipsPerPixelY) \ 2, 1024
End With
End If
End Sub
Private Sub DrawShadow(Optional ByVal blnErase As Boolean = False)
Dim lngColor As Long
Dim intI As Integer
With frmName
'画阴影
If blnErase = True Then
lngColor = RGB(192, 192, 192)
Else
lngColor = RGB(128, 128, 128)
End If
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -