您的位置:程序门 -> vb -> 基础类



mshflexgrid控件 用户更改列宽width时触发哪个事件?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


mshflexgrid控件 用户更改列宽width时触发哪个事件?
发表于:2007-05-20 21:36:59 楼主
如题??
发表于:2007-05-21 09:17:061楼 得分:0
http://community.csdn.net/expert/topic/5512/5512291.xml?temp=.1943476
发表于:2007-05-21 09:43:052楼 得分:0
不会触发任何事件
mshflexgrid1.colwidth(index)=x
发表于:2007-05-21 10:09:583楼 得分:0
看不懂这个贴
http://community.csdn.net/expert/topic/5512/5512291.xml?temp=.1943476
发表于:2007-05-21 10:21:044楼 得分:0
自己顶
发表于: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
发表于:2007-05-22 08:16:506楼 得分:0
这个过程有问题,  
一运行   程序全部都自动关闭了!!!!
发表于:2007-05-22 11:36:217楼 得分:0
这个过程有问题,  
一运行   程序全部都自动关闭了!!!!
======================================
这段代码肯定没问题,测试好了才贴的
你新建一个工程,把代码粘贴上试试吧


快速检索

最新资讯
热门点击