www.pudn.com > xp_combox.zip > frmpopup.frm
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Begin VB.Form frmpopup
Appearance = 0 'Flat
BackColor = &H00DAE0E4&
BorderStyle = 0 'None
Caption = "Form1"
ClientHeight = 1905
ClientLeft = 0
ClientTop = 0
ClientWidth = 2625
LinkTopic = "Form1"
ScaleHeight = 1905
ScaleWidth = 2625
ShowInTaskbar = 0 'False
StartUpPosition = 3 'Windows Default
Begin ComctlLib.ListView lsw
Height = 1575
Left = 120
TabIndex = 0
Top = 120
Width = 2295
_ExtentX = 4048
_ExtentY = 2778
View = 3
LabelWrap = -1 'True
HideSelection = -1 'True
_Version = 327682
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 0
NumItems = 0
End
End
Attribute VB_Name = "frmpopup"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'# Email to :zhujinyong@totalise.co.uk
Option Explicit
Public selectedtext As String
Public isclick As Boolean
Private text As String
Dim crlClick As Boolean
Private Sub Form_Initialize()
lsw.View = lvwReport
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim IsMouseOver1 As Boolean
IsMouseOver1 = False
IsMouseOver1 = X >= 0 And Y >= 0 And X <= ScaleWidth And Y <= ScaleHeight
If IsMouseOver1 Then
'SetCapture Me.hWnd
Else
'ReleaseCapture
lsw.Visible = False
Unload Me
Exit Sub
End If
End Sub
Private Sub Form_Load()
lsw.View = lvwReport
If HideColumnHeaders = True Then
lsw.HideColumnHeaders = True
Else
lsw.HideColumnHeaders = False
End If
Call NewStyle
lsw.Visible = True
crlClick = False
End Sub
Private Sub Form_Resize()
lsw.Move 0, 0, ScaleWidth, ScaleHeight - 10
End Sub
Private Sub Form_Unload(Cancel As Integer)
lsw.Visible = False
Unload Me
End Sub
Private Sub lsw_DblClick()
selectedtext = text
lsw.Visible = False
Unload Me
End Sub
Private Sub lsw_ItemClick(ByVal Item As ComctlLib.ListItem)
crlClick = True
isclick = True
text = Item.text
'Check whether Record is "Null"
If text = "-" Then text = ""
End Sub
Private Sub lsw_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then
lsw.Visible = False
Unload Me
End If
End Sub
Private Sub lsw_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then selectedtext = text: lsw.Visible = False: Unload Me
End Sub
Private Function NewStyle()
Dim lStyle1 As Long
Dim lStyle2 As Long
Dim lStyle3 As Long
Dim lS1 As Long
Dim ls2 As Long
Dim ls3 As Long
Dim lS4 As Long
Dim lhWnd As Long
'# Flat ScrollBar
lStyle3 = SendMessageByLong(frmpopup.lsw.hWnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)
ls3 = LVS_EX_FLATSB
lStyle3 = lStyle3 Or ls3
SendMessageByLong frmpopup.lsw.hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, lStyle3
'# Full Row Select
lStyle1 = SendMessageByLong(frmpopup.lsw.hWnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)
lS1 = LVS_EX_FULLROWSELECT
lStyle1 = lStyle1 Or LVS_EX_TWOCLICKACTIVATE
lStyle1 = lStyle1 And Not LVS_EX_ONECLICKACTIVATE
lStyle1 = lStyle1 Or lS1
SendMessageByLong frmpopup.lsw.hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, lStyle1
'# Add Gridline
lStyle2 = SendMessageByLong(frmpopup.lsw.hWnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)
ls2 = LVS_EX_GRIDLINES
lStyle2 = lStyle2 Or LVS_EX_TWOCLICKACTIVATE
lStyle2 = lStyle2 And Not LVS_EX_ONECLICKACTIVATE
lStyle2 = lStyle2 Or ls2
SendMessageByLong frmpopup.lsw.hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, lStyle2
' Set the Buttons mode of the ListView's header control:
lhWnd = SendMessageByLong(frmpopup.lsw.hWnd, LVM_GETHEADER, 0, 0)
If (lhWnd <> 0) Then
lS4 = GetWindowLong(lhWnd, GWL_STYLE)
lS4 = lS4 And Not HDS_BUTTONS
SetWindowLong lhWnd, GWL_STYLE, lS4
End If
End Function