7 //#include "/workbench.h"
8 #include <workbench/startup.h>
12 #include <clib/dos_protos.h>
13 #include <clib/exec_protos.h>
14 #include <clib/wb_protos.h>
16 #include <pragmas/exec_sysbase_pragmas.h>
17 #include <pragmas/dos_pragmas.h>
18 #include <pragmas/wb_pragmas.h>
20 /****************************************************************************/
22 extern struct Library
*SysBase
;
23 extern struct Library
*DOSBase
;
25 /****************************************************************************/
27 struct Library
* WorkbenchBase
;
29 /****************************************************************************/
32 main(int argc
,char ** argv
)
34 struct MsgPort
* mp
= NULL
;
35 struct AppMenu
* menu
= NULL
;
36 struct AppMenuItem
* item1
= NULL
;
37 struct AppMenuItem
* item2
= NULL
;
38 struct AppMenuItem
* item3
= NULL
;
39 struct AppMenuItem
* sub
= NULL
;
40 struct AppMessage
* am
;
45 WorkbenchBase
= OpenLibrary("workbench.library",45);
46 if(WorkbenchBase
== NULL
)
48 Printf("Couldn't open workbench.library V45.\n");
55 Printf("Couldn't create MsgPort.\n");
62 menu
= (struct AppMenu
*)AddAppMenuItem(0,
63 (ULONG
)"new top menu",
66 WBAPPMENUA_GetTitleKey
,&key
,
70 Printf("Couldn't create menu.\n");
74 Printf("Key=%08lx\n", key
);
78 Printf("Can't get a key for the menu\n");
82 item1
= AddAppMenuItem(1,
84 "This is the first menu item",
86 WBAPPMENUA_UseKey
,key
,
90 Printf("Couldn't create first menu item.\n");
94 item2
= AddAppMenuItem(2,
96 "This is the second menu item",
98 WBAPPMENUA_UseKey
,key
,
102 Printf("Couldn't create second menu item.\n");
107 item3
= AddAppMenuItem(3,
108 (ULONG
)"menu item 3",
109 "This is the third menu item, and it has a subitem",
111 WBAPPMENUA_UseKey
,key
,
112 WBAPPMENUA_GetKey
,&key2
,
116 Printf("Couldn't create third level menu item.\n");
120 Printf("Key2=%08lx\n", key2
);
124 Printf("Can't get a key for the submenu\n");
128 sub
= AddAppMenuItem(4,
129 (ULONG
)"sub menu item",
130 "This is the sub menu item",
132 WBAPPMENUA_UseKey
,key2
,
136 Printf("Couldn't create sub menu item.\n");
145 while((am
= (struct AppMessage
*)GetMsg(mp
)) != NULL
)
147 if(am
->am_UserData
!= (ULONG
)NULL
)
148 Printf("%s\n",am
->am_UserData
);
156 Printf("removing the two; press ^C to continue... ");
158 Wait(SIGBREAKF_CTRL_C
);
160 RemoveAppMenuItem(item1
);
163 RemoveAppMenuItem(item2
);
166 Printf("removing the submenu; press ^C to continue... ");
168 Wait(SIGBREAKF_CTRL_C
);
170 RemoveAppMenuItem(item3
);
173 RemoveAppMenuItem(sub
);
179 RemoveAppMenuItem(item1
);
182 RemoveAppMenuItem(item2
);
185 RemoveAppMenuItem(item3
);
188 RemoveAppMenuItem(sub
);
191 RemoveAppMenuItem((struct AppMenuItem
*)menu
);
195 while((am
= (struct AppMessage
*)GetMsg(mp
)) != NULL
)
196 ReplyMsg((struct Message
*)am
);
201 if(WorkbenchBase
!= NULL
)
203 CloseLibrary(WorkbenchBase
);
204 WorkbenchBase
= NULL
;