设置TreeView背景色
以下为在Csdn上找到的Treeview资源管理器代码,怎样改变其背景色?
用:SendMessage SysTreeWindow,TVM_SETBKCOLOR,0,byval RGB(255,255,255)来改变背景色是可以,但图标有白底。
请问怎样使图标背景透明?
Option Explicit
'资源管理器树型目录模块TreeView
Private Const BIF_STATUSTEXT = &H4&
Private Const BIF_RETURNONLYFSDIRS = 1
Private Const MAX_PATH = 260
Private Const WM_USER = &H400
Private Const BFFM_INITIALIZED = 1
Private Const BFFM_SELCHANGED = 2
Private Const BFFM_SETSELECTION = (WM_USER + 102)
Private Const WM_MOVE = &H3
Private Const GWL_WNDPROC = (-4)
Private Const GWL_STYLE As Long = (-16)
Private lpPrevWndProc As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal X As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Any) As Long
Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function SetTextColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As Long) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Const GW_NEXT = 2
Private Const GW_CHILD = 5
Private Const WM_CLOSE = &H10
Private Const TVM_SETBKCOLOR = 4381&
Private Const TVM_SETTEXTCOLOR = 4382&
Private Type BrowseInfo
hwndOwner As Long
pIDLRoot As Long
pszDisplayName As Long
lpszTitle As Long
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type
Public NewForm As Form
Public m_CurrentDirectory As String
Public DialogContainer As Object
Dim DialogWindow As Long
Dim SysTreeWindow As Long
Dim CancelbuttonWindow As Long
Public Sub BrowseForFolder(StartDir As String)
Dim lpIDList As Long
Dim szTitle As String
Dim sBuffer As String
Dim tBrowseInfo As BrowseInfo
m_CurrentDirectory = StartDir & vbNullChar
With tBrowseInfo
.hwndOwner = GetDesktopWindow
.lpszTitle = lstrcat(szTitle, "")
.ulFlags = BIF_RETURNONLYFSDIRS + BIF_STATUSTEXT
.lpfnCallback = GetAddressofFunction(AddressOf BrowseCallbackProc)
End With
lpIDList = SHBrowseForFolder(tBrowseInfo)
End Sub
Private Function BrowseCallbackProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal lp As Long, ByVal pData As Long) As Long
Dim lpIDList As Long
Dim ret As Long
Dim sBuffer As String
Dim hwnda As Long, ClWind As String * 14, ClCaption As String * 100
On Error Resume Next
DialogWindow = hwnd
Select Case uMsg
Case BFFM_INITIALIZED
Call MoveWindow(DialogWindow, -Screen.Width, 0, 480, 480, True)
Call SendMessage(hwnd, BFFM_SETSELECTION, 1, m_CurrentDirectory)
hwnda = GetWindow(hwnd, GW_CHILD)
Do While hwnda <> 0
GetClassName hwnda, ClWind, 14
If Left(ClWind, 6) = "Button" Then
GetWindowText hwnda, ClCaption, 100
If UCase(Left(ClCaption, 6)) = "CANCEL" Then
CancelbuttonWindow = hwnda
End If
End If
If Left(ClWind, 13) = "SysTreeView32" Then
SysTreeWindow = hwnda
<span style="color: #FF0000;">SendMessage SysTreeWindow, TVM_SETBKCOLOR, 0, ByVal vbBlack</span>
SendMessage SysTreeWindow, TVM_SETTEXTCOLOR, 0, ByVal vbWhite
End If
hwnda = GetWindow(hwnda, GW_NEXT)
Loop
GrabTV DialogContainer
Case BFFM_SELCHANGED
sBuffer = Space(MAX_PATH)
ret = SHGetPathFromIDList(lp, sBuffer)
m_CurrentDirectory = Left(sBuffer, InStr(sBuffer, Chr(0)) - 1)
NewForm.PathChange
End Select
BrowseCallbackProc = 0
End Function
Private Function GetAddressofFunction(add As Long) As Long
GetAddressofFunction = add
End Function
Private Sub GrabTV(mNewOwner As Object)
Dim R As RECT
SetParent SysTreeWindow, mNewOwner.hwnd
GetWindowRect mNewOwner.hwnd, R
SizeTV 0, 0, mNewOwner.ScaleWidth, mNewOwner.ScaleHeight
DialogHook
End Sub
Public Sub CloseUp()
SetParent SysTreeWindow, DialogWindow
SendMessage DialogWindow, WM_CLOSE, 1, ByVal 0&
DestroyWindow DialogWindow
End Sub
Private Sub TaskbarHide()
ShowWindow DialogWindow, 0
DialogUnhook
End Sub
Public Sub Main()
Set NewForm = Form1
NewForm.Show
Set DialogContainer = NewForm.PicBrowse
BrowseForFolder "c:\"
End Sub
Private Sub DialogHook()
lpPrevWndProc = SetWindowLong(DialogWindow, GWL_WNDPROC, AddressOf WindowProc)
End Sub
Private Sub DialogUnhook()
SetWindowLong DialogWindow, GWL_WNDPROC, lpPrevWndProc
End Sub
Private Function WindowProc(ByVal mHwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case uMsg
Case WM_MOVE
TaskbarHide
End Select
WindowProc = CallWindowProc(lpPrevWndProc, mHwnd, uMsg, wParam, lParam)
End Function
Public Sub SizeTV(mLeft As Long, mTop As Long, mWidth As Long, mHeight As Long)
Dim lby As Long
Call MoveWindow(SysTreeWindow, mLeft, mTop, mWidth, mHeight, True)
lby = GetWindowLong(SysTreeWindow, GWL_STYLE)
Call SetWindowLong(SysTreeWindow, GWL_STYLE, lby And Not &H2)
End Sub
Public Sub ChangePath(mPath As String)
m_CurrentDirectory = mPath
Call SendMessage(DialogWindow, BFFM_SETSELECTION, 1, m_CurrentDirectory)
End Sub
设置TreeView背景色的更多相关文章
- 设置Treeview背景色的问题1
有没有哪位兄弟在VB中使用sendmessage对TreeView改变背景色?我现在遇到一个问题,如果把linestyle设为1 的时候,展开节点的时候root部位会 有一个下拉的白色块,如果设为1 ...
- Android Material适配 为控件设置指定背景色和点击波纹效果
Android Material适配 为控件设置指定背景色和点击波纹效果,有需要的朋友可以参考下. 大部分时候,我们都需要为控件设置指定背景色和点击效果 4.x以下可以使用selector,5.0以上 ...
- C# WinForm设置TreeView选中节点
这里假定只有两级节点,多级方法类似.遍历节点,根据选中节点文本找到要选中的节点.treeView.SelectedNode = selectNode; /// <summary> /// ...
- React Native 设置RGBA背景色
React Native 设置RGBA背景色: 可以先用Mac自带吸色工具,获取RGB值,然后设置背景如下: backgroundColor: 'rgba(52, 52, 52, 0.8)', 透明度 ...
- 由设置body线性背景色引发的问题-----当声明文档类型时,对body设置线性背景色,页面背景色无法整体线性过渡
问题:当声明文档类型时,对body设置线性背景色,页面背景色无法整体线性过渡 不声明文档类型时,对body设置线性背景色 <HTML> <head> <meta char ...
- CSS布局与定位——height百分比设置无效/背景色不显示
CSS布局与定位——height百分比设置无效/背景色不显示 html元素属性width和height的值有两种表达方式,一是固定像素如“100px”,一是百分比如“80%”, 使用百分比的好处是元素 ...
- JS---案例:点击按钮设置div背景色渐变
案例:点击按钮设置div背景色渐变 背景色渐变:设置透明度 <div id="dv"></div> <input type="button& ...
- Java 为 Excel 中的行设置交替背景色
在制作Excel表格时,通过将数据表中上下相邻的两行用不同的背景色填充,可以使各行的数据看起来更清楚,避免看错行,同时也能增加Excel表格的美观度.本文将介绍如何在Java程序中为 Excel 奇数 ...
- 使用POI设置excel背景色
HSSFCellStyle setBorder1 = workbook.createCellStyle(); HSSFFont font1 = workbook.createFont(); font1 ...
随机推荐
- redux基础(1)
redux ps:每个案例都是接着上一个案例写的 主要以案例讲解如何使用,具体概念请参考如下: 基本概念参考1 基本概念参考2 案例源码戳这里 一.Store.Action.Reducer简介 Sto ...
- Linux High Availabi RHCS
-----本文大纲 简介 术语 环境配置 实现过程 命令行管理工具 ------------- 一.简介 RHCS 即 RedHat Cluster Suite ,中文意思即红帽集群套件.红帽集群套件 ...
- 多线程_java多线程环境下栈信息分析思路
导读:Java多线程开发给程序带来好处的同时,由于多线程程序导致的问题也越来越多,而且对问题的查找和分析解决对于菜鸟程序原来是是件头疼的事.下面我就项目中使用多线程开发程序过程中遇到的问题做详细的分析 ...
- ant design Modal遮罩层颜色加深 解决方案
1.原因 页面中存在多个Modal同时渲染及弹出(在table里使用Modal就会出现这种问题) 2.解决方案 不让多个Modal同时渲染就行了,设置Modal的visible属性为this.stat ...
- 快速搭建简单的LBS程序——地图服务
很多时候,我们的程序需要提供需要搭建基于位置的服务(LBS),本文这里简单的介绍一下其涉及的一些基本知识. 墨卡托投影 地图本身是一个三维图像,但在电脑上展示时,往往需要将其转换为二维的平面图形,需要 ...
- Bandwagon Host – 64M内存 1.5G硬盘 100G流量 年3.99美金
BandwagonHost(习惯称作搬瓦工),属于IT7公司旗下的产品,搬瓦工虽然是新起的商家, 但是有实力雄厚的公司背景在一定程度上还是可以放心使用的. 很多用户在选择这款低价VPS的时候都担心是否 ...
- 调试查看CLR运行代码
SOS (Son of Strike)调试扩展可以让我们在调试过程中查看CLR运行代码.SOS.dll随.NET一起安装,对于.NET 4.0来说,SOS.dll的所在位置是:C:\Windows\M ...
- fundamentals5
PROTOBUF的DELPHI开源框架fundamentals5 GITHUB: https://github.com/fundamentalslib/fundamentals5 # Fundamen ...
- 纯文本抽出程序库DMC TEXT FILTER
因需而生,红樱枫为文本转换市场领航 --纯文本抽出程序库DMC TEXT FILTER,从需求中把握平衡 在高度数字化的今天,数字图书馆已经成为非常多人查询资料的有效途径.然而即使在畅通的宽带搜寻中一 ...
- Access control configuration prevents your request from being allo
我发现在在XP环境下我输入网易的220.181.28.42也找不到网页,就跟在LINUX下一样 都揭示: 错误 您所请求的网址(URL)无法获取 --------------------------- ...