|
VMM Basic can create windows and controls, this tutorial will explain how create a window and manage
the events.
For this application we will need a variable to store the event on out window, it will be called Event,
of long type, and other variable to store a state variable to quit the game, byte typed.
Then we open our window with OpenWindow() on position 10,10 with a size of 320x240, about the style, it will be
visible and with the system menu using FnOr() command, checking that the command succeeds:
If OpenWindow(0, 10, 10, 320, 240, "My window", FnOr(#VMB_WINDOW_VISIBLE, #VMB_WINDOW_SYSTEMMENU)) != 0 |
Now we add a repeat block of code until user want to quit our program, processing the event with WaitEvent(), and
MessageID():
Repeat
WaitEvent()
Event = MessageID()
If Event = #VMB_EVENT_CLOSE
Quit = #True
EndIf
Until Quit = #True
|
Now we must to put the EndIf of open window command and end our program:
Exercise:
Add commands necesary to move the window to initial position when user move the window on a horizontal position bigger than 400 pixels.
|
|