Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!midway!ncar!bierstat.scd.ucar.edu!boote From: boote@bierstadt.scd.ucar.edu (Jeff W. Boote) Newsgroups: comp.windows.x.motif Subject: Re: Getting the filename from a FileSelectionDialog Message-ID: <10052@ncar.ucar.edu> Date: 25 Jan 91 21:22:21 GMT References: <9101251445.AA00797@alex.CSS.GOV> Sender: news@ncar.ucar.edu Reply-To: boote@bierstadt.scd.ucar.edu (Jeff W. Boote) Distribution: inet Organization: Scientific Computing Division / NCAR, Boulder Co. Lines: 47 >I'm sure this is an easy question for everyone but I haven't been able >to figure it out yet. How do you get the filename that the user picks >or types from a FileSelectionDialog? For instance, after the user clicks >on the "OK" button, I want to retrieve the name that was chosen. In your XmNokCallback routine the call_data parameter returns a pointer to the XmFileSelectionBoxCallbackStruct and the "value" member of this structure is the filename. This is how I normally do this. void send_fselectokCB(w, client_data, sboxstruct) Widget w; caddr_t client_data; XmFileSelectionBoxCallbackStruct *sboxstruct; { char *string; XtUnmanageChild(fileselect); XtRemoveGrab(fileselect); string = extractstring(sboxstruct->value); free(string); } where extractstring is: char *extractstring(str) XmString str; { XmStringContext context; XmStringCharSet charset; XmStringDirection direction; Boolean separator; static char *xm_string; XmStringInitContext (&context, str); XmStringGetNextSegment (context, &xm_string, &charset, &direction, &separator); XmStringFreeContext (context); return ((char *) xm_string); } -- Jeff W. Boote SCD/NCAR boote@ncar.ucar.edu Boulder, Colo