![]() |
The listSetting of the items by the methodUse addItem method to add items to the list with an string and position. If the position is omitted,add it to the last of the list. The following program is a sample adding item to the list.#include <WScom.h> #include <WSCfunctionList.h> #include <WSCbase.h> //---------------------------------------------------------- //Function for the event procedure //---------------------------------------------------------- #include <WSClist.h> extern WSClist* newlist_001; void btnep1(WSCbase* object){ //Delete all the items of the list. newlist_001->delAll(); //Add an item to the last of the list. newlist_001->addItem("item1"); newlist_001->addItem("item2"); newlist_001->addItem("item3"); newlist_001->addItem("item4"); //Add an item to the specified position of the list. newlist_001->addItem("item0",0);//0 :top newlist_001->addItem("item5",-1);//-1 :last //Update the modificated list. newlist_001->updateList(); } static WSCfunctionRegister op("btnep1",(void*)btnep1); Setting of the items by the propertythe property WSNdata can be used for setting the items of the list, if it is a comparatively little number of the items. In such case, set the property WSNdataSource to WS_DATA_SOURCE_NONE, and set the items which is punctuated with comma every one item to the proeprty WSNdata.#include <WScom.h> #include <WSCfunctionList.h> #include <WSCbase.h> //---------------------------------------------------------- //Function for the event procedure //---------------------------------------------------------- #include <WSClist.h> extern WSClist* newlist_001; void btnep1(WSCbase* object){ //Delete all the items of the list. newlist_001->delAll(); //Set the items of the list by the property newlist_001->setProperty(WSNdataSource,WS_DATA_SOURCE_NONE); newlist_001->setProperty(WSNdata,"item0\nitem1\nitem2\nitem3\nitem4"); } static WSCfunctionRegister op("btnep1",(void*)btnep1);It is possible to indicate the specified ICON by icon file name as following program. Set True to the proeprty WSNuseIcon and Set the items as following format. If it is ommited,the value of WSNiconPixmap is used for default icon. format: the ICON1 filename,the string2 of the item\n the ICON2 filename,the string2 of the item\n... void btnep1(WSCbase* object){ //Delete all the list of the list newlist_001->delAll(); //Set the items of the list by the property newlist_001->setProperty(WSNdataSource,WS_DATA_SOURCE_NONE); newlist_001->setProperty(WSNdata, "$(WSDIR)/sys/pixmaps/bi16.xpm,item1\nitem2\nitem3"); } static WSCfunctionRegister op("btnep1",(void*)btnep1); Setting of the items from the file directlyIt is possible to set the items from the file directly. In such case at first,set WS_DATA_SOURCE_FILE to the property WSNdataSource, and set the file name to the property WSNdataSourceName as following program.#include <WScom.h> #include <WSCfunctionList.h> #include <WSCbase.h> //---------------------------------------------------------- //Function for the event procedure //---------------------------------------------------------- #include <WSClist.h> extern WSClist* newlist_001; void btnep1(WSCbase* object){ //Delete all the items of the list newlist_001->delAll(); //Set the items from file directly newlist_001->setProperty(WSNdataSource,WS_DATA_SOURCE_FILE); newlist_001->setProperty(WSNdataSourceName,"data.txt"); } static WSCfunctionRegister op("btnep1",(void*)btnep1); //data.txt contains... $(WSDIR)/sys/pixmaps/bi16.xpm,item1 item2 item3 item4 $(WSDIR)/sys/pixmaps/bi16.xpm,item5 item6 item7 item8 Setting of the items from the other instanceIt is possible to set the items from the data source target property of the other instances. In such case, set WS_DATA_SOURCE_INSTANCE to the property WSNdataSource, and set the instance name to the proeprty WSNdataSourceName. In the following example, a WSCtextField instance are specified to the property WSNdataSourceName and then it sets the string data of it to the list.#include <WScom.h> #include <WSCfunctionList.h> #include <WSCbase.h> //---------------------------------------------------------- //Function for the event procedure //---------------------------------------------------------- #include <WSClist.h> extern WSClist* newlist_001; void btnep1(WSCbase* object){ //Delete all the items of the list newlist_001->delAll(); //Set the items from the other instances newlist_001->setProperty(WSNdataSource,WS_DATA_SOURCE_INSTANCE); newlist_001->setProperty(WSNdataSourceName,"newtext_000"); } static WSCfunctionRegister op("btnep1",(void*)btnep1);The following picture indicates the list(lower side) from the other instance of WSCtextField class( upper side). ![]() [The list data from the other instance] Document Release 3.0 For Use with Wide Studio Release 3.0, Summer 2002
|