![]() | Application Builder User's Guide | WideStudio/MWT Index Table of contents |
Creating an event procedure.
Instances triggers various kinds of events under execution. On WideStudio, it is possible to put some event procedures on the instance so that they will be executed with the event triggered. For example, let's create an event procedure which has the following function.
Indicating "Hello!" on the button by clicking it on the window. Set an event procedure to the instance so that it executes the procedure by clicking the instance: newvbtn_000. At first, select the instance: newvbtn_000 in the Inspector, then select the [Procedures] index tab of the application builder, and click the leftmost icon to create an event procedure. Input the procedure name, the function name, and the others in the dialog as follows.
[Creating an event procedure]
Procedure name: new_ep Function name: btn_ep Trigger: ACTIVATE The procedure name is used to identify the event procedure, therefore it can be any string including spaces. The function name is a name of C/C++ function for which the developer writes codes. The last one is the trigger (ACTIVATE will be executed normally by clicking the button). A template file of the source code for the event procedure is created. By clicking the event procedure created as above, the source code editor appears with the following template of the code for the event procedure. The developer can specify the default editor. Select ((menu:Project >> Project settings)) and input the path of the editor in the "project settings". The default editor is vi on the UNIX system and notepad.exe on the Window system.
[A event procedure]#include <WScom.h> #include <WSCfunctionList.h> #include <WSCbase.h> //----------------------------------------------- //Function for the event procedure //----------------------------------------------- void btn_ep(WSCbase* object){ object->setProperty(WSNlabelString, "Hello!"); //A } static WSCfunctionRegister op("btn_ep",(void*)btn_ep);The WSCbase* pointer "object" denotes the instance in this code. At //A, the string "Hello!" is set to the property "WSNlabelString" of the instance. Then, the instance shows the string "Hello!" when the function executed.
Copyright(C) WideStudio/MWT Development Team, 1999-2005 | Last modified: Jul 31, 2005 |