| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 565 人关注过本帖
标题:一个问题不知道问哪里.-->走刀口→超转移
取消只看楼主 加入收藏
atomhdp
Rank: 1
等 级:新手上路
帖 子:97
专家分:0
注 册:2005-10-2
收藏
 问题点数:0 回复次数:1 
一个问题不知道问哪里.-->走刀口→超转移

我做的一个程序,用了系统自带控件listview视图为报表视图,怎么使标题不能随用户改变宽度大小.

好像要用sendmessage, 不过我不知道消息类型, 随便用什么语言给个例子就行了. (看到这里人气比较旺)

搜索更多相关主题的帖子: 刀口 
2007-02-25 11:06
atomhdp
Rank: 1
等 级:新手上路
帖 子:97
专家分:0
注 册:2005-10-2
收藏
得分:0 

找了半天终于找到一个VB版的. 发出来共享一下. 版主转移.
Option Explicit

Private Sub Command1_Click()
Call LockHead(ListView1.hwnd)
End Sub

Private Sub Command2_Click()
Call UnLockHead(ListView1.hwnd)
End Sub

Private Sub Form_Load()
Dim i As Long
ListView1.ColumnHeaders.Add , , "asdf", ListView1.Width / 4
ListView1.ColumnHeaders.Add , , "qwre", ListView1.Width / 4
ListView1.ColumnHeaders.Add , , "zxcv", ListView1.Width / 4
For i = 0 To 30
ListView1.ListItems.Add , , CStr(i)
Next i
End Sub


===================
模块
===================
Option Explicit

Public Type NMHDR
hwndFrom As Long
idFrom As Long
code As Long
End Type

Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public 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
Public Const GWL_WNDPROC = (-4)
Public Const WM_NOTIFY = &H4E

Public Const HDN_FIRST = -300
Public Const HDN_DIVIDERDBLCLICKA = HDN_FIRST - 5
Public Const HDN_DIVIDERDBLCLICKW = HDN_FIRST - 25
Public Const HDN_BEGINTRACKA = HDN_FIRST - 6
Public Const HDN_BEGINTRACKW = HDN_FIRST - 26

Private lpPrevWndFunc As Long

Public Function WindowProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case uMsg
Case WM_NOTIFY
Dim x As NMHDR

CopyMemory x, ByVal lParam, Len(x)

If x.code = HDN_BEGINTRACKA Or x.code = HDN_BEGINTRACKW Or _
x.code = HDN_DIVIDERDBLCLICKA Or _
x.code = HDN_DIVIDERDBLCLICKW Then
WindowProc = 1
Exit Function
End If
End Select

WindowProc = CallWindowProc(lpPrevWndFunc, hwnd, uMsg, wParam, lParam)
End Function

Public Sub LockHead(ByVal hwnd As Long)
lpPrevWndFunc = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub

Public Sub UnLockHead(ByVal hwnd As Long)
SetWindowLong hwnd, GWL_WNDPROC, lpPrevWndFunc
End Sub


2007-02-25 13:24
快速回复:一个问题不知道问哪里.-->走刀口→超转移
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023526 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved