|
楼主 |
发表于 2024-10-17 20:54
|
显示全部楼层
Private Sub UserForm_Initialize()
Dim IStyle As Long, Hwnd As Long
Dim arr, ii%, img As New ImageList, xr%, xnod$, mypath$, myfiles$, m%, i%, j%
'******获取窗口句柄******
If Val(Application.Version) < 9 Then
Hwnd = FindWindow("ThunderXFrame", Me.Caption)
Else
Hwnd = FindWindow("ThunderDFrame", Me.Caption)
End If
'******去除窗体标题栏******
IStyle = GetWindowLong(Hwnd, GWL_STYLE)
IStyle = IStyle And Not WS_CAPTION
SetWindowLong Hwnd, GWL_STYLE, IStyle
DrawMenuBar Hwnd
'******去除窗体四周的边框******
IStyle = GetWindowLong(Hwnd, GWL_EXSTYLE) And Not WS_EX_DLGMODALFRAME
SetWindowLong Hwnd, GWL_EXSTYLE, IStyle
On Error Resume Next
arr = Array("肉食品", "蔬菜", "蛋奶品", "粮食", "水产品", "食用油", "调料", "其他")
img.ListImages.Add , "kk", LoadPicture(ThisWorkbook.Path & "\lg.jpg") '添加KEY为KK的图片
m = 2
mypath = ThisWorkbook.Path & "\菜品\"
myfiles = Dir(mypath & "*.jpg")
Do While myfiles <> ""
img.ListImages.Add , """" & Mid(myfiles, 1, Len(myfiles) - 4) & """", LoadPicture(mypath & myfiles)
m = m + 1
myfiles = Dir
Loop
m = 2
Set TreeView1.ImageList = img
TreeView1.Nodes.Clear
With Sheets("常用菜品信息")
For i = 1 To 8
xnod = .Cells(1, i)
TreeView1.Nodes.Add , , xnod, xnod, "kk" '添加KEY为KK的图片
xr = .Cells(100, i).End(xlUp).Row
For j = 2 To xr
TreeView1.Nodes.Add xnod, 4, .Cells(j, i), .Cells(j, i), """" & .Cells(j, i) & """" '利用KEY添加图片
' m = m + 1
Next
Next
End With
End Sub
|
|