从数据库加载菜单 [英] Loading menus from database

查看:91
本文介绍了从数据库加载菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我一次更改了菜单项的数量,我需要知道剩余的菜单数.我正在考虑一个函数,该函数将通过顶部菜单(hMenu)并遍历整个菜单(包括子菜单),相应地增加一个变量,并在命中0(或没有菜单)时退出循环剩下的项目).

有人知道如何执行此操作吗?在此先感谢.

Let''s say I change the number of menu items at one point, and I need to know the number of menus left. I am thinking of a function that would go through the top menu (hMenu) and loop through the entire menu(including submenus), increases a variable accordingly, and breaks out of the loop when a 0 is hit (or when there are no menu items left).

Anyone has any idea how to do this? Thanks in advance.

推荐答案

我写了一篇文章(针对C ++),可能会有所帮助.它从数据库中检索菜单项,并根据检索到的菜单项构建桌面应用程序的整个菜单结构.它可以帮助您提出设计,所以在这里是:

动态地构建菜单和/或工具栏 [
I wrote an article (for C++) that might be of help. It retrieved menu items from a database and built the entire menu structur for a desktop application from the retrieved menu items. It may help you come up with a design, so here it is:

Dynamically Build Your Menu and/or Toolbar[^]

The key is having your table structure adequately defined to alow for sub menus. I used a numeric menu id for every menu item, and each database record had a column for ParentID so I could associate a menu item with it''s parent. A ParentID of 0 indicated a top-lovel menu item.


这篇关于从数据库加载菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆