LockListViewhead

xiaoxiao2021-03-06  61

Option expedition

Private submmand1_click ()

Call LocklistViewhead (listview1.hwnd)

End Sub

Private sub fascist2_click ()

Call unlockhead (ListView1.hwnd)

End Sub

Private sub flow_load ()

DIM I as long

Listview1.view = 3

Listview1.columnheaders.add,, "asdf", listview1.width / 3

Listview1.columnheaders.add,, "qwre", listview1.width / 3

Listview1.columnheaders.add,, ".......", listview1.width / 3

End Sub

Option expedition

Public Type NMHDR

HWndfrom as long

IDFROM As Long

Code as long

End Type

Public Declare Function SetWindowlong Lib "User32" Alias ​​"SetWindowlonga" (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 Hwndfunc As Long, Byval Hwnd As Long, Byval Msg As Long, Byval WParam 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 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 thenwindowproc = 1

EXIT FUNCTION

END IF

End SELECT

WindowProc = CallWindowProc (lpprevwndfunc, hwnd, umsg, wparam, lparam)

END FUNCTION

Public Sub LocklistViewhead (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

转载请注明原文地址:https://www.9cbs.com/read-112816.html

New Post(0)