![]() | Programming Guide | WideStudio Index Table of contents |
Sample:1 (Hello World)
Here, you create a project,an application window and event procedures. The following is a rudimentary sample which displays "Hello World" by pushing the button of the window,
The source code is ws/samples/C/hello/hello.prj. You can load the project and build by the application builder.
- Creating a project
Select the [New project] of the [Project] menu, and input "hello" for the project name,and check the [Normal application].- Creating a application window
Select the [New window] of the [File] menu, and Check the [Normal window],and check [Add to project], and input the window name "newwin000".- Placing the instances
Place the WSCvbtn instance on the created application window. Select the [ObjectBox] of the [View] menu, to display the object box dialog.
The next, clicking the [Commands] tab on the object box dialog,and dragging and dropping the WSCvbtn class shown as BTN from the dialog to the application window, it creates the new instance of WSCvbtn.
you can adjust the properties of the instance by the inspector.
[A view of the application window]
- Creating the event procedure
At first, select the button instance by the inspector, and select [Mew procedures] of sub-menu:[Procedures] of [Edit] menu.
Here, set "btn_proc" for the function name and WSEV_ACTIVATE trigger.
To create a template file of the event procedure, push the button [Template].- Editing the event procedure
The next, you edit the template event procedure. you can execute the source code editor by selecting [Edit] of sub-menu:[Procedures] of [Edit] menu to edit the event procedure which is focused on the inspector. Here, the following procedure shows that it shows "Hello World" at the first clicking, it exits the application at the second clicking.#include <WScom.h> #include <WSCfunctionList.h> #include <WSCbase.h> //---------------------------------------------------------- //Function for the event procedure //---------------------------------------------------------- void btn_proc(WSCbase* object){ //do something... static long cnt = 0; if (cnt == 0){ object->setProperty(WSNlabelString,"Hello World."); cnt++; }else{ exit(0); } } static WSCfunctionRegister op("btn_proc",(void*)btn_proc);
- Saving the project
You can save the project by [Save project] of [Project] menu.- Building the project
You can build the project by [Build all] of [Build] menu. After building, execute the application!
[Executing the application]
Copyright(C) WideStudio Development Team, 1999-2005 | Last modified: Jan 05, 2005 |