这些指令是代码和工作的一部分。但我不明白他们的语法。我只知道" \"表示代码继续下一行。有谁能够帮我?为什么会有&#34 ;;"。什么" ADDPOPUPMENU"意思是什么大写?
#define ADDPOPUPMENU(hmenu, string) \
HMENU hSubMenu = CreatePopupMenu(); \
AppendMenu(hmenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, string);
// Add a menu item
#define ADDMENUITEM(hmenu, ID, string) \
AppendMenu(hSubMenu, MF_STRING, ID, string);
答案 0 :(得分:0)
代码定义了两个独立的宏:
#define ADDPOPUPMENU(hmenu, string) \
HMENU hSubMenu = CreatePopupMenu(); \
AppendMenu(hmenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, string);
// Add a menu item
#define ADDMENUITEM(hmenu, ID, string) \
AppendMenu(hSubMenu, MF_STRING, ID, string);
预处理器#define
语句只是定义文本替换。所以这样的代码:
ADDPOPUPMENU(MyMenu, "Name")
ADDMENUITEM(MyMenu, MyID, "Item")
在编译阶段开始之前的预处理阶段将替换为以下内容:
HMENU hSubMenu = CreatePopupMenu();
AppendMenu(MyMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, "Name");
AppendMenu(hSubMenu, MF_STRING, MyID, "Item");