Getting information for a specific gadget. ------------------------------------------ The following #defines are taking from VisualArts.h file included with Visual Arts. #define GetString(gad) (((struct StringInfo *)gad->SpecialInfo)->Buffer) #define GetUndoString(gad) (((struct StringInfo *)gad->SpecialInfo)->UndoBuffer) #define GetNumber(gad) (((struct StringInfo *)gad->SpecialInfo)->LongInt) gad - is the gadget structure name to pass to. 1. GetString() function will return the string for the GadTool STRING_KIND eg: #define ID_name 1 //defined by Visual Arts #define ID_age 2 //defined by Visual Arts struct Gadget *DemoGadgets[5]; //defined by Visual Arts char myvar[80]; strcpy(myvar, GetString(DemoGadgets[ID_name])); this will copy the string in DemoGadget into myvar. Note that the contants 'ID_name' and DemoGadgets[] is defined by Visual Arts. 2. GetNumber() function will return the number for the GadTool INTEGER_KIND eg: #define ID_name 1 //defined by Visual Arts #define ID_age 2 //defined by Visual Arts struct Gadget *DemoGadgets[5]; //defined by Visual Arts int myinteger; myinteger = GetNumber(DemoGadgets[ID_age]); this will copy the string in DemoGadget into myvar. Note that the contants 'ID_age' and DemoGadgets[] is defined by Visual Arts. 3. GetUndoString() function will return the undo string for the GadTool STRING_KIND. This is handy if the user types over the string gadget and you want to undo because they have entered a invalid entry. char undo[255]; //get the previous name strcpy(undo, GetUndoString(DemoGadgets[ID_name])); //set the string gadget back to the previous name GT_SetGadgetAttrs(DemoGadgets[ID_name], DemoWnd, NULL, GTST_String, undo, TAG_END); 4. Get the item selected from a ListView, Cycle, Popup and MX gadgets. example: //Visual Arts message object. This structure gets passed to every active //GadTool struct VAobject { struct Window *va_Window; //window the object originated struct Gadget *va_Gadget; //the gadget that sent this object struct IntuiMessage *va_IntuiMsg; //the IntuiMessage ULONG va_Flags; //user flags APTR va_UserData; //user data, function pointer etc.. }; /* for ListView, Cycle, Popup and MX gadgets the VAObject.va_IntuiMsg->Code always contain the item the user selected, and you have always check this field when the user selects the gadget. */ int listviewObj(struct VAobject VAObject) { int item; //get the item selected by the user item = VAObject.va_IntuiMsg->Code; //get the item here!!!! printf("you selected item %d\n", item); return(1L); } 5. Get from check boxes int SmokerObj(struct VAobject VAObject) { if (VAObject.va_Gadget->Flags & GFLG_SELECTED) //check if its checked printf("this person is a smoker\n"); else printf("this person does not smoke\n"); return(1L); } /* Check Box Cool! */ 6. Setting GadTools. For GadTools always use the GT_SetGadgetAttrs() function and never use the anyother method. to disable any GadTool use. Note you can't disable listview and mx //disable gadget GT_SetGadgetAttrs(DemoGadgets[ID_save], DemoWnd, NULL, GA_Disabled, TRUE, TAG_END); a. string gadgets GT_SetGadgetAttrs(DemoGadgets[ID_name], DemoWnd, NULL, GTST_String, "Joe Blow", TAG_END); GT_SetGadgetAttrs(DemoGadgets[ID_name], DemoWnd, NULL, GTST_String, myname, TAG_END); b. integer gadgets GT_SetGadgetAttrs(DemoGadgets[ID_age], DemoWnd, NULL, GTIN_Number, "Joe Blow", TAG_END); GT_SetGadgetAttrs(DemoGadgets[ID_age], DemoWnd, NULL, GTST_Number, yourage, TAG_END); c. checkbox gadgets //no check mark GT_SetGadgetAttrs(DemoGadgets[ID_smoker], DemoWnd, NULL, GTCB_Checked, FALSE, TAG_END); //check mark GT_SetGadgetAttrs(DemoGadgets[ID_smoker], DemoWnd, NULL, GTCB_Checked, TRUE, TAG_END); d. mx gadgets eg: 0 - Male 1 - Female //set it to Female GT_SetGadgetAttrs(DemoGadgets[ID_sex], DemoWnd, NULL, GTMX_Active, 1 , TAG_END); //set it to Male GT_SetGadgetAttrs(DemoGadgets[ID_sex], DemoWnd, NULL, GTMX_Active, 0 , TAG_END); e. cycle gadgets eg: Canada = 0 China = 1 . . USA = 5 //set the cycle to be USA GT_SetGadgetAttrs(DemoGadgets[ID_country], DemoWnd, NULL, GTCY_Active, 5 , TAG_END); f. slider min = 10000 max = 50000 //set the level to 30000 GT_SetGadgetAttrs(DemoGadgets[ID_salary], DemoWnd, NULL, GTSL_Level, 30000 , TAG_END); g. scroller top = 1 total = 10 //set the top to start displaying from 5 GT_SetGadgetAttrs(DemoGadgets[ID_salary], DemoWnd, NULL, GTSC_Top, 5 , TAG_END); h. listview //defined by Visual Arts in your project header file .h struct List *DemoLists[2]; //this will attach list 1 GT_SetGadgetAttrs(DemoGadgets[ID_names], DemoWnd, NULL, GTLV_Label, DemoLists[1] , TAG_END); To better understand GadTools you should read the RKM in the GadTool section. It is very informative.