| 发表于:2007-05-21 23:30:115楼 得分:0 |
没有事件,需要用api 以下代码是我曾经用过的,稍微改了改,缺点是只能监测到mshflexgrid调整行高或者列宽,但是不能判定在调整哪一行哪一列 新建一个窗体form1,添加一个mshflexgrid1 代码: private sub form_load() dim i as long, j as long with mshflexgrid1 for i = 0 to .cols - 1 .textmatrix(0, i) = "第 " & i & "列 " next end with prevproc = setwindowlong(mshflexgrid1.hwnd, gwl_wndproc, addressof windowprocnew) end sub public sub adjustcolwidth(state as long) select case state case 0 debug.print "列宽、行高调整开始 " case 1 debug.print "列宽、行高调整中。。。 " case 2 debug.print "列宽、行高调整中结束 " end select end sub private sub form_unload(cancel as integer) setwindowlong mshflexgrid1.hwnd, gwl_wndproc, prevproc end sub '========================================= 然后添加一个模块,以下代码: option explicit public declare function getwindowlong lib "user32 " alias "getwindowlonga " (byval hwnd as long, byval nindex as long) as long public declare function setwindowlong lib "user32 " alias "setwindowlonga " (byval hwnd as long, byval nindex as long, byval dwnewlong as long) 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 prevproc as long private blnstart as boolean public lngoldmsg as long public function windowprocnew(byval hwnd as long, byval umsg as long, byval wparam as long, byval lparam as long) as long windowprocnew = callwindowproc(prevproc, hwnd, umsg, wparam, lparam) 'debug.print umsg, wparam, lparam if umsg = 513 and lngoldmsg = 32 then blnstart = true call form1.adjustcolwidth(0) end if if (umsg = 512) and (lngoldmsg = 132) and (wparam = 1) and blnstart then call form1.adjustcolwidth(1) end if if umsg = 512 and lngoldmsg = 132 and wparam = 0 and blnstart then blnstart = false call form1.adjustcolwidth(2) end if lngoldmsg = umsg end function | | |
|