Notification in Blitz
 

OK, the "real" interface between Blitz and MUI can actually be narrowed down to just three commands, MUIAddTags, MUIDoMethod, and MUINotifyApp. MUIAddTags does just as it says, it adds MUI tags to MUI objects. You'll find as you use MUI that almost the entire thing is controlled with tags. Some of the tags are fairly general, and some are specific to particular types of object.A full list and explanation of them all is well beyond the scope of this tutorial. You can, however, get all details from the MUI autodocs, which you should always keep handy when programming for MUI.

The MUIDoMethod command actually sends a "command" to MUI, to have it do something. Again, this is very much tag orientated, and again, having the MUI autodocs handy is a must.

And finally, the MUINotifyApp command. Without this, it would be impossible for your Blitz code to react to MUI. Your code would just sit and wait for something which would never arrive.

So what does it do exactly? Well, if you have used Blitz to program anything that gets input from the user (other than Edit and Edit$), for example, a gadtools button being pressed, then you will be aware that the WaitEvent command will report the most recent event code to you. The MUI equivalent is MUIWaitEvent. This command does not, however, report any event. It will only report those that you tell it to.

If you want to test this, you can. Using the last example, comment out the line starting with MUINotifyApp, and then compile and run it. Now, you can't close the window, and your program is stuck in an endless loop. Chances are you'll have to reboot to get your system back, so off you go and reboot to get rid of your little test program and bring Blitz back to life.

You can add notification to almost any Blitz object, and you do it in a variety of ways. This example will show you how to set up a basic notification in MUI.

First, you need an image. Load up your favourite paint package, and draw a small image to use on your button, then save it to disk. Done that? OK, now compile and run the following code, remembering to change the path in im$ to the path and filename of your newly created image.

Code ; First, do a little bit of Blitz housekeeping
NoCli
FindScreen 0

; And load our image in to a blitz shape
im$="Path and filename of your image"
LoadShape 1,im$

;And set up a constant four our return code. This isn't necessary, but keeps things tidy
#BUTPRESSED=1
; Now we'll set up a procedure to initialise the MUI window.

Statement setmui{}

MUIApplicationTitle "Lesson2" ;Sets the MUI application name
MUIApplicationVersion "$VER: Lesson 2" ; Sets version information
MUIApplicationCopyright "(c) 2001, Steve Hargreaves" ;Sets copyright information
MUIApplicationAuthor "Steve Hargreaves" ;Sets Author information
MUIApplicationDescription "Demonstrate MUI Notification" ;And a description

MUIApplicationBase "LESS" ;This should be a unique identifier for your application

MUIAddApplicationTags #MUIA_Application_SingleTask,True

MUIAddTags 1,#MUIA_Frame,#MUIV_Frame_Button,#MUIA_InputMode,#MUIV_InputMode_RelVerify
; This is an example of adding tags to an object. Tags take the form
; Tag to be modified,Value. They are all built in to MUI. In the example
; The frame type (in this case a Button frame, but you can use any, (see MUIArea.doc for the list)
; and the input mode (this time it's a button type - MUIArea.doc again)
MUIImageButton 1,1
; The syntax - Obj No,Shape No.
MUICreateWindow 2,"Notify Example","WIND1",1
MUIAddSubWindow 2
If MUICreateApplication=False

End
EndIf

MUINotifyApp 1,#MUIA_Pressed,0,#BUTPRESSED

; The syntax is Obj No,Event,State/condition,Return Value

MUINotifyApp 2,#MUIA_Window_CloseRequest,1,#MUIV_Application_ReturnID_Quit

End Statement

;And now the main bit

setmui{}
MUIOpenWindow 2
Repeat

ev.l=MUIWaitEvent
Select ev
Case #BUTPRESSED
BeepScreen 0

Case #MUIV_Application_ReturnID_Quit

End
End Select
Forever

It's possible that, when you run this, the window will be too small to show the close gadget. If so, go to the debugger and click "Stop", then return to the window and click in it. Finally, close the debugger. This depends on the size of the image used for the button.

All the example does is a standard BeepScreen when the button is pressed, and closes the window if the close gadget is pressed. Since these are the only events we are interested in, these are the only ones that are reported to your program. Any other events are ignored.

However, MUI notification can do more than this, as the next section will demonstrate.

Previous:MUI in Blitz Programming contents Next: More advanced notification


News | Introduction | Search | List/Forum/IRC Webring | Contact
Installation | Troubleshooting | Programming | Archives | Links
Return to programming main
Page last modified: 6th February 2002