How to Create an AppMenu Item
AppMenus are just new Items added to Workbench's Tools menu and you can add/remove them as you like. Their use is various: you can, for example, iconify a program, closing its window, and to show just an AppItem, another use is to link to Tools menu some items rappresenting various application status.
In this article, we will show you how to create simply AppMenuItems, for further informations, please cunsult Autodocs "Workbench.library".
Code is fully commented, if you like, save this HTML page as TEXT and import the source inside Blitz.
;------------- BEGINNING OF BLITZ BASIC II ----------------------- ; First of all we initialize three variables which we will use as pointers: ; ; *myport - Pointer to our Message Port ; *appitem - AppMenuItem pointer ; *appmsg - AppMenuItem's message pointer DEFTYPE.l *myport,*appitem,*appmsg FindScreen 0 ; We need it for BeepScreen below. *myport=CreateMsgPort("Fabio") ; Here we create our MessagePort tit$="Fabio Soft Item" ; This is our AppItem's Title *appitem=AddAppMenuItemA_(0,0,&tit$,*myport,0) ; Add AppItem to WB Tools If *appitem = 0 Then End ; If we failed, this is the end... WaitPort_ *myport ; Waiting for the user to select our ; AppMenu Item... BeepScreen 0 ; Here we flash the screen ; (Just to show user something has ; happened.) RemoveAppMenuItem_ *appitem ; As the command say, we remove appitem Repeat ; Here we clear our Message Port ; from still queued messages *appmsg=GetMsg_(*myport) ; Here I get a message If *appmsg ; if it exists... ReplyMsg_ *appmsg ; I reply to that message EndIf Until *appmsg=0 ; Until the end DeleteMsgPort *myport ; Here we remove our message port End ; End of program ;----------------- END OF BLITZ BASIC II CODE ---------------------
Written By: Fabio Rotondo e-mail: fsoft@intercom.it C.so Vercelli 9 28100 Novara ITALY tel: (ITA) - (0)321 459676