| 发表于:2007-09-24 18:17:24 楼主 |
我的动态添加菜单的代码如下,请问如何修改:(现在运行的结果是所有的三级菜单都一样子了) option explicit dim conn as new adodb.connection dim rs as new adodb.recordset dim rss as new adodb.recordset private sub form_load() set rs = new adodb.recordset conn.open "dbq= " & app.path & "\mnudate.mdb " & ";driver={microsoft access driver (*.mdb)};pwd= " rs.open ( "select distinct 父用户组 from 表1 "), conn, 1, 3 dim smnu as string '//父用户组菜单项 hmenu = createmenu() hmenupopup = createpopupmenu() hmenupopup1 = createpopupmenu() hmenupopup2 = createpopupmenu() result = appendmenu(hmenu, mf_popup, hmenupopup, "&file ") result = appendmenu(hmenupopup, mf_string, 300, "&save ") result = appendmenu(hmenupopup, mf_string, 200, "&saveas ") result = appendmenu(hmenupopup, mf_popup, hmenupopup1, "&new ") '//添加父用户组 while not rs.eof smnu = rs( "父用户组 ") result = appendmenu(hmenupopup1, mf_popup, hmenupopup2, smnu) call xmnus(smnu) rs.movenext wend rs.close oldwinproc = getwindowlong(me.hwnd, gwl_wndproc) setwindowlong me.hwnd, gwl_wndproc, addressof onmenu end sub private sub form_mousedown(button as integer, shift as integer, x as single, y as single) dim r as rect dim p as pointapi if button = vbrightbutton then getcursorpos p trackpopupmenu hmenupopup, 0, p.x, p.y, 0, me.hwnd, r end if end sub private sub form_unload(cancel as integer) setwindowlong me.hwnd, gwl_wndproc, oldwinproc end sub private function xmnus(smnu as string) '//添加子用户组 set rss = new adodb.recordset dim xmnu as string '//子用户组菜单项 rss.open ( "select distinct 子用户组 from 表1 where 父用户组= ' " & smnu & " ' "), conn, 1, 3 while not rss.eof xmnu = rss( "子用户组 ") result = appendmenu(hmenupopup2, mf_string, 500, xmnu) rss.movenext wend rss.close end function |
|
|
|
|