如何修改外部程序中的LISTVIEW及TREEVIEW控件中的TEXT(急!请各位大侠赐教!)(100分)

  • 主题发起人 主题发起人 weitajn
  • 开始时间 开始时间
W

weitajn

Unregistered / Unconfirmed
GUEST, unregistred user!
是这样的,有一个外部程序,它拥有一个SysListView32的控件,现在通过枚举窗体,我已经找到此控件的句柄了,请问,如何我想修改其中一列的文字该怎么办?我查了一下帮助,好像要用到LVM_FINDITEM,LVM_GETITEM,LVM_SETITEM等这些消息,但都是英文资料,我看得很吃力,没有理解好!请各位大侠帮忙!必当高分相报,如果不够,可以再加!
 
请注意:这是一个SysListView32控件,不是DELPHI的ListView组件,我发现上面三则消息好像对ListView有用,但对SysListView32则不起作用!不知为什么?那SysListView32相对应的消息值又是什么呢?我用Spy++没有跟踪到,只发现有LVM_GETITEMCOUNT,LVM_DELALLITEM等消息.那么我想修改一个外部程序中的SysListView32控件中ITEM的值,是否就不能用消息的方式进行呢?那也该用什么方式呢?困惑中.....
 
ListView就是SysListView32
 
&nbsp; Windows中的桌面图标的排列方式是否让你感到厌倦而想按照自己的想法排列图标。是否想改变桌面图标文字的背景而不在图标文字下出现一个个难看的色块。这里我要介绍如何通过VB来对桌面的图标进行彻底的改变。 <br><br>其实在Windows下的桌面以及任务栏等都是窗口对象,我们可以利用Windows API函数FindWindow和FindWindowEx来获得它们的句柄,然后再调用其它相应的API函数来控制它们。而放置桌面图标的窗口是一个ListView对象,利用SendMessage函数向该窗口发送相应的消息,就可以对图标进行修改了。下面是具体的程序实现。 <br><br>首先在VB中建立一个新的工程,在Form1中加入三个CommandButton控件,然后在Form1的代码窗口中加入以下代码: <br><br>Option Explicit<br>Private Type POINTAPI<br>x As Long<br>y As Long<br>End Type<br>Private Declare Function FindWindow Lib ″user32″ Alias ″FindWindowA″ _<br>(ByVal lpClassName As String, ByVal lpWindowName As String) As Long<br>Private Declare Function FindWindowEx Lib ″user32″ Alias ″FindWindowExA″ _<br>(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, _<br>ByVal lpsz2 As String) As Long<br>Private Declare Function UpdateWindow Lib ″user32″ (ByVal hwnd As Long) As Long<br>Private Declare Function SendMessage Lib ″user32″ Alias ″SendMessageA″ (ByVal _<br>hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) _<br>As Long<br>Private Declare Function SendMessageP Lib ″user32″ Alias ″SendMessageA″ (ByVal _<br>hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) _<br>As Long<br>Private Declare Function GetSysColor Lib ″user32″ (ByVal nIndex As Long) As Long<br>Private Declare Function SetSysColors Lib ″user32″ (ByVal nChanges As Long, _<br>lpSysColor As Long, lpColorValues As Long) As Long<br>Const LVM_FIRST = &H1000<br>Const LVM_GETITEMCOUNT = LVM_FIRST + 4<br>Const LVM_SETTEXTCOLOR = LVM_FIRST + 36<br>Const LVM_REDRAWITEMS = LVM_FIRST + 21<br>Const LVM_SETTEXTBKCOLOR = LVM_FIRST + 38<br>Const LVM_SETITEMPOSITION = LVM_FIRST + 15<br>Const COLOR_DESKTOP = 1<br>注释:RestoreColor函数回复默认的图标文字颜色和背景<br>Sub RestoreColor()<br>Dim lColor As Long<br>lColor = GetSysColor(COLOR_DESKTOP)<br>SetSysColors 1, COLOR_DESKTOP, lColor<br>End Sub<br>Sub SetIconText(clFore, clBack As Long, bTrans As Boolean)<br>Dim hWindow As Long<br>Dim lItemCount As Long<br>注释:通过三步查找到放置桌面图表的窗口<br>hWindow = FindWindow(″Progman″, ″Program Manager″)<br>hWindow = FindWindowEx(hWindow, 0, ″SHELLDLL_DefView″, ″")<br>hWindow = FindWindowEx(hWindow, 0, ″SysListView32″, ″")<br>If bTrans Then 注释:透明背景<br>SendMessage hWindow, LVM_SETTEXTBKCOLOR, 0, &HFFFFFFFF<br>Else 注释:非透明背景<br>SendMessage hWindow, LVM_SETTEXTBKCOLOR, 0, clBack<br>End If<br>注释:设置图标文字的颜色<br>SendMessage hWindow, LVM-SETTEXTCOLOR, 0, clFore<br>注释:重新绘制所有的图标<br>lItemCount = SendMessage(hWindow, LVM-GETITEMCOUNT, 0, 0)<br>SendMessage hWindow, LVM-REDRAWITEMS, 0, lItemCount - 1<br>注释:更新窗口<br>UpdateWindow hWindow<br>End Sub<br>Sub ArrangeDesktopIcon(iWidth As Integer, iHeight As Integer)<br>Dim hWindow As Long<br>Dim i1, i2, i, iCount As Integer<br>Dim po As POINTAPI<br>注释:通过三步查找到放置桌面图表的窗口<br>hWindow = FindWindow(″Progman″, ″Program Manager″)<br>hWindow = FindWindowEx(hWindow, 0, ″SHELLDLL-DefView″, ″″)<br>hWindow = FindWindowEx(hWindow, 0, ″SysListView32″, ″″)<br>i1 = 20: i2 = 20<br>iCount = SendMessage(hWindow, LVM-GETITEMCOUNT, 0, 0)<br>For i = 0 To iCount - 1<br>po.x = i1: po.y = i2<br>注释:发送LVM-SETITEMPOSITION消息排列图标<br>Call Send Message(h Window, LVM-SETITEMPOSITION, i, i2 * 65536 + i1)<br>i1 = i1 + iWidth<br>If i1 &gt; ((Screen.Width / 15) - 32) Then<br>i1 = 20<br>i2 = i2 + iHeight<br>End If<br>Next i<br>SendMessage hWindow, LVM-REDRAWITEMS, 0, iCount - 1<br>注释:更新窗口<br>UpdateWindow hWindow<br>End Sub<br>Private Sub Command1_Click()<br>注释:设置图标文字的颜色为蓝色,背景色为黑色,背景为透明<br>SetIconText vbBlue, vbBlack, True<br>End Sub<br>Private Sub Command2_Click()<br>RestoreColor<br>End Sub<br>Private Sub Command3_Click()<br>注释:以100x100像素为单位排列图标<br>ArrangeDesktopIcon 100, 100<br>End Sub<br>Private Sub Form_Load()<br>Command1.Caption = ″设置文字背景″<br>Command2.Caption = ″恢复文字背景″<br>Command3.Caption = ″排列桌面图标″<br>End Sub<br>运行程序,点击Command1,可以看到桌面图标的文本背景色变成了蓝色,如果你设置了桌面图片,还可以看到文字的背景变成了透明的而不是在下面有一个难看的色块,点击Command2可以恢复Windows的默认设置,点击Command3可以使你的桌面图标以横排的方式排列,不过前提是要将桌面图标的自动排列属性设置为False。 <br><br>以上程序在VB6,Windows98,Windows2000下运行通过。 <br>
 
不是,我是想修改SysListView32的文字TEXT.
 
要修改资源啊。。<br>http://www.hanzify.org/?Go=Show::List&amp;ID=2031<br>exescope<br>载下来一个,修改就行了。
 
to weitajn: 我在http://www.delphibbs.com/delphibbs/dispq.asp?lid=2471980 里面给你写了一个函数,不能用吗?
 
后退
顶部