TreeView树控件兼容性问题之奇葩偏方-红尘如烟
Access软件网QQ交流学习群(群号码198465573),欢迎您的加入!
首页 >技术文章> Access数据库-窗体/数据页


TreeView树控件兼容性问题之奇葩偏方

发表时间:2017/3/20 10:12:44 评论(9) 浏览(5964)  评论 | 加入收藏 | 复制
   
摘 要:自从Win7开始,不论是Win8、Win10,MSCOMCTL.OCX通用控件库中的控件就经常出现兼容性问题。即开发环境下的版本号和使用环境下的版本号,哪怕只有很小的差别,像6.1.9834和6.1.9818这样,都会出现异常不能使用。
正 文:

    Windows系统自带的通用控件库 MSCOMCTL.OCX 是一个很好的东西,尤其是TreeView树控件,用来处理多层级的树形结构数据非常有用。由于在Access中没有类似的控件,没有其它代替解决办法。甚至不像ListView可以用列表框或者子窗体代替,Toolbar可以用按钮、菜单代替。


    但自从Win7开始,不论是Win8、Win10,MSCOMCTL.OCX通用控件库中的控件就经常出现兼容性问题。即开发环境下的版本号和使用环境下的版本号,哪怕只有很小的差别,像6.1.9834和6.1.9818这样,都会出现异常不能使用。


    我们这里仍然以TreeView控件为例,不包括本身控件库安装有问题不能使用的情况,一般可能会遇到的兼容性问题有会以下两类:


  • 不能响应键盘、鼠标事件。可以正常加载数据到树控件,但不论是鼠标还是键盘,均无法触发相应的事件,比如在NodeClick事件中写了相应处理代码,但点击之后没有任何反应。

  • 键盘、鼠标事件一触发就报错。点击鼠标、按键,甚至鼠标在树控件上移动,事件可以响应,但一触发就报错,导致不能正常使用。

    这些问题发生的频率非常高!尤其是当一些在实际中已经在用的Access程序来说,遇到实在让人火冒三丈,因为业务部门等着马上要用呢!这是在坑爹呢还是在坑爹呢!


    对于这个问题有什么解决办法呢?总结下来不外乎下面几种:


  1. 修改控件库。这个控件库是微软的,第一优先是希望微软能在更新系统时解决掉该问题,但从Win7到Win10,该问题仍然顽固地存在,看来微软是指望不上了。而我们不可能去修改控件库,甚至通过一些破解手段修改了,但会导致签名失效,还是不便于使用。

  2. 不使用树控件。但正如本文一开头说的那样,有些多层数据的展示和处理,在用过了树控件之后,现在要让人不用,实在难受。就像习惯了电气化的现代人,突然没电了,要点油灯、蜡烛照明,这!这!这!这日子不过了!

  3. 使用其它第三方树控件。其它第三方树控件的问题在于,有可能是要额外付费的。即使找到免费的了,由于属性方法事件等接口不同,还需要重新编写程序。另外使用第三方控件需要安装,而一些规范化的企业里面,是禁止用户自行安装软件的。


    看到这里你是不是感到绝望了?是不是感觉自己被掏空了?感觉不会再爱了?

    这么想地话,你还是太年轻,图样图森破!

    世上无难事,只怕有些人!要相信希望总会有的,奇迹是会出现的,在那个迷茫的午夜,上帝向你走来,赐给了你一道光!

    上帝说:解决这个问题,需要用到这一招如来神掌,我现在就将如来神掌的秘籍传授给你!


------------------------------------------如来神掌秘籍分割线------------------------------------


1. Ctrl+G打开立即窗口,输入以下代码并回车,将窗体另存为文本文件。

SaveAsText acForm, "Form1", CurrentProject.Path & "\Form1.txt"


注意不要直接把代码原样抄去就用,
要把Form1改成你实际的窗体名称!
要把Form1改成你实际的窗体名称!
要把Form1改成你实际的窗体名称!

重要的事情说三遍。



2. 用记事本打开刚才生成的文件文件 Form1.txt,找到树控件所在的位置(如果内容比较多,可以搜索树控件名称)。

3. 将从 OleData = Begin 这一行开始,直到 End 结束的OleData部分全部选中:

4. 将上面选中的部分替换成下面这段:

                    OleData = Begin
                        0x000e0000d0cf11e0a1b11ae1000000000000000000000000000000003e000300 ,
                        0xfeff090006000000000000000000000001000000020000000000000000100000 ,
                        0x0400000001000000feffffff0000000003000000ffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffff52006f006f007400200045006e007400720079000000000000000000 ,
                        0x0000000000000000000000000000000000000000000000000000000000000000 ,
                        0x0000000016000500ffffffffffffffff01000000b69041c78985d111b16a00c0 ,
                        0xf0283628000000000000000000000000e0f6d2113487cd010700000040010000 ,
                        0x0000000043006f006e00740065006e0074007300000000000000000000000000 ,
                        0x0000000000000000000000000000000000000000000000000000000000000000 ,
                        0x0000000012000201ffffffff02000000ffffffff000000000000000000000000 ,
                        0x0000000000000000000000000000000000000000000000000200000091000000 ,
                        0x0000000003004100630063006500730073004f0062006a005300690074006500 ,
                        0x4400610074006100000000000000000000000000000000000000000000000000 ,
                        0x0000000026000200ffffffffffffffffffffffff000000000000000000000000 ,
                        0x000000000000000000000000000000000000000000000000000000005c000000 ,
                        0x0000000000000000000000000000000000000000000000000000000000000000 ,
                        0x0000000000000000000000000000000000000000000000000000000000000000 ,
                        0x0000000000000000ffffffffffffffffffffffff000000000000000000000000 ,
                        0x0000000000000000000000000000000000000000000000000000000000000000 ,
                        0x00000000fefffffffdfffffffffffffffffffffffffffffffffffffffeffffff ,
                        0xfeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffff52006f006f007400200045006e007400720079000000000000000000 ,
                        0x0000000000000000000000000000000000000000000000000000000000000000 ,
                        0x0000000016000500ffffffffffffffff01000000b69041c78985d111b16a00c0 ,
                        0xf0283628000000000000000000000000800c5a253487cd010500000040010000 ,
                        0x0000000043006f006e00740065006e0074007300000000000000000000000000 ,
                        0x0000000000000000000000000000000000000000000000000000000000000000 ,
                        0x0000000012000201ffffffff02000000ffffffff000000000000000000000000 ,
                        0x0000000000000000000000000000000000000000000000000200000091000000 ,
                        0x0000000003004100630063006500730073004f0062006a005300690074006500 ,
                        0x4400610074006100000000000000000000000000000000000000000000000000 ,
                        0x0000000026000200ffffffffffffffffffffffff000000000000000000000000 ,
                        0x000000000000000000000000000000000000000000000000000000005c000000 ,
                        0x0000000000000000000000000000000000000000000000000000000000000000 ,
                        0x0000000000000000000000000000000000000000000000000000000000000000 ,
                        0x0000000000000000ffffffffffffffffffffffff000000000000000000000000 ,
                        0x0000000000000000000000000000000000000000000000000000000000000000 ,
                        0x00000000fffffffffffffffffefffffffdfffffffefffffffeffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffff01000000feffffff0300000004000000feffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ,
                        0xffffffff5c000000000000000100000000000000000000000000000000000000 ,
                        0x2400000038000000000000000000000000000000000000000000000039333638 ,
                        0x323635452d383546452d313164312d384245332d303030304638373534444131 ,
                        0xe30b918fce119de300aa004bb85101860000900174b7010004cbcecce5ffffff ,
                        0x00ffffff2143341208000000602a0000a8230000b13cc16a010006003a000000 ,
                        0xbd000000e8030000090000002b82240b01efcdab000005000000000002000000 ,
                        0x0000000005000080bc2f58270a00000049006d006100670065004c0069007300 ,
                        0x740031000100000020001fdeecbd0100050099e613000352e30b918fce119de3 ,
                        0x00aa004bb85101860000900174b7010004cbcecce52c2c142b282724002b0000 ,
                        0x2b020000002c2c142b2b2827002b2b2b2b2b2b2b002c2c152b2b2b2800000000 ,
                        0x00000000002c2c162b2b2b2b28252424231c130a2c2c2c172b2b2b2b2b272722 ,
                        0x0e0d0b0a2c2c2c172b2b2b2b2b2b291f040601032c2c2c1a2b2b2b2b2b2b2b20 ,
                        0x0907052c2c2c2c17282727272727271f090c2c2c2c2c2c171818181817171814 ,
                        0x082c2c2c2cc000ffffc000ffffc000ffffc000ffffc000ffffc000ffffc000ff ,
                        0xffc000ffffc000ffffc000ffffc001ffffc001ffffc001ffffc003ffffc007ff ,
                        0xffc00fffff000000000000000000000000000000000000000000000000000000 ,
                        0x0000000000000000
                    End                    

    由于网页转码之类的问题,请点击这里下载该数据文件使用。

4. 回到Access立即窗口,再次输入以下代码并回车,将文本文件加载为窗体:

LoadFromText acForm, "Form1", CurrentProject.Path & "\Form1.txt"

    打完收工。

    重新打开有树控件的窗体,你会发现惹人厌的树控件不能正常使用的问题没有了!换台电脑,也不再出了!


郑重声明:

    该方法本公子亲测有效,也用来救了几次火。但由于测试样本有限,加上本公子也还没有完全弄懂原理,所以不保证百分之百有效!因此这里只当作一个偏方分享出来给大家,仅供参考。


Access软件网交流QQ群(群号:198465573)
 
 相关文章
微软建议用户避开64位Office 2010、不建议使用64位Ac...  【红尘如烟  2012/9/12】
【小偏方】office剪切板不正常时可参考下此贴  【何必见戴  2013/5/7】
三款ACCESS数据库修复工具  【麥田  2013/5/23】
修复Treeview树控件方法及工具  【麥田  2014/8/14】
修复ADO系统错误工具  【麥田  2016/7/23】
 
 访客评论
2018/3/8dulton
厉害了,收藏好,将来肯定用的着

2017/9/18创新开关
同一窗体,有的jpg格式图片可以显示,但照片的jpg格式就不能显示,为什么?用你提供的雇员和照片对应的示例运行,也是显示:不支持文件“d:\……\***.jpg”格式,或者文件太大。请尝试把文件转换成BMP或GIF格式。

2017/7/3Allen Lee
我问下,toolbar控件是不是也可以给个偏方呢

2017/3/23红尘如烟
@KevinFan 囧nz~ 大哥你好歹先把 Form1 改成你实际的窗体名称啊……

2017/3/22KevinFan
SaveAsText acForm, "Form1", CurrentProject.Path & "\Form1.txt",这句回车后就出错了,运行时错误:32584,当前数据库中不存在具有给定名称和类型的对象。

2017/3/21水若寒
强!收藏了,说不定下次遇到就用的着,谢谢分享!

2017/3/21张辰
大师厉害

2017/3/21轻风
如来神掌厉害呀

2017/3/20杜超
向大湿学习了

总记录:9篇  页次:1/1 9 1 :
 
 发表评论
评论内容 (必填)

常见问答
技术分类
相关资源
文章搜索
关于作者

红尘如烟

文章分类

文章存档

友情链接