[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

2973.0. "problems using XtGetValues" by STKHLM::BERGGREN (Nils Berggren SWAS/Telecom,Sweden) Thu Jun 21 1990 09:10

Hi,

I have a tiny testprogram that tries to retrieve the height of a window via
XtSetArg and XtGetValues.  I get different answers when run under the debugger
and without the debugger???

Furthermore, trying to get the name of the window doesn't work at all!

What am I doing wrong???
Here's the code  (it's only 25 lines):

#include <decw$include/stringdefs.h>
#include <decw$include/dwtappl.h>

main(argc, argv)
    int argc;
    char *argv[];
{
    Widget 	toplevel, window;
    int		height;
    char        name[50]; 
    Arg         args[2];
    
    toplevel = XtInitialize(argv[0], "NoName", NULL, 0, &argc, argv);

    window = DwtWindow(toplevel, "window_name", 0,0,800, 700, NULL); 
    XtManageChild (window);

    XtSetArg( args[0], XtNname,    name);  
    XtSetArg( args[1], XtNheight,   &height);
    XtGetValues(window, args, 2  );

    printf("Windowname=%s   height=%d\n", name, height); 
 
    XtRealizeWidget(toplevel);
    XtMainLoop();
}
T.RTitleUserPersonal
Name
DateLines
2973.1GetValues wants address of pointerR2ME2::OBRYANThu Jun 21 1990 15:2520
re:.0

>    char        name[50]; 

>    XtSetArg( args[0], XtNname,    name);  

>    XtGetValues(window, args, 2  );

GetValues always produces "string addresses" for resources which are strings.
You need to supply the *address of a pointer* as the arg value, not the address 
of memory in your program.

    char  *name;	/* If XtNname is a compound, make 'char' DwtCompString*/

    XtSetArg( args[0], XtNname, &name );  

BTW, do not attempt to Free this memory... the widget owns it.

Good luck
2973.2tried it - no success!STKHLM::BERGGRENNils Berggren SWAS/Telecom,SwedenMon Jun 25 1990 06:5714
re: .1

I tried:

	char  *name;
 
	XtSetArg(args[0], XtNname, &name);
	XtGetValues(...)

but it didn't work either...

What to do?	
		
		/Nils
2973.3DWTERM::MESSENGERMon Jun 25 1990 11:3810
    Try this:
    
    char *name;
    Dimension height;
    
    XtSetArg(args[0], XtNtitle, &name);
    XtSetArg(args[1], XtNheight, &height);
    XtGetValues(...);
    
    				-- Bob
2973.4XtNtitle - No success...STKHLM::BERGGRENNils Berggren SWAS/Telecom,SwedenTue Jun 26 1990 04:074
Tried it and no success.  The pointer is untouched at the
XtGetValues-call.

   / Nils
2973.5HANNAH::MESSENGERBob MessengerTue Jun 26 1990 11:2210
Re: .4

Can you read the height consistently by declaring it as Dimension instead of
int?

I was wrong about XtNtitle; window widgets don't have a title.  I'm not sure
if it's possible to read the widget name with XtGetValues, though; "name" isn't
listed as a supported resource.  Maybe one of the toolkit gurus can help.

				-- Bob
2973.6XtNheight worksSTKHLM::BERGGRENNils Berggren SWAS/Telecom,SwedenWed Jun 27 1990 06:185
re: 5.

Yes, I get the height OK.

     /Nils
2973.7XtNname is not usedR2ME2::VANGILDERJim V., DECwindows ToolkitsWed Jun 27 1990 10:244
Despite the fact that XtNname is defined, it is not a supported
resource in any of the XUI widgets.