|
源码如下:
/*********************************************************
*
* filembutton.c
* project:Motif Widgets example programs
* description:This program creates a PushButton widget.
* **********************************************/
/* include files */
#include <X11/Intrinsic.h>
#include <Xm/Xm.h>
#include <Xm/PushB.h>
/* functions defined in this program */
void activateCB(Widget,XtPointer,XtPointer);
XmString btn_text;
int main(int argc,char** argv)
{
Widget toplevel;
Widget mybutton;
XtAppContext app_context;
Arg args[10];
int n=0;
toplevel = XtAppInitialize(&app_context, "XMdemos",NULL,0,
&argc,argv,NULL,NULL,0);
btn_text = XmStringCreateLtoR("请按这里!",XmSTRING_ISO8859_1);
XtSetArg(args[n],XmNlabelString,btn_text); n++;
XtSetArg(args[n],XmNwidth,250);n++;
XtSetArg(args[n],XmNheight,150);n++;
mybutton = XtCreateManagedWidget("button",xmPushButtonWidgetClass,
toplevel,args,n);
XtAddCallback(mybutton,XmNactivateCallback,activateCB,NULL);
XtManageChild(mybutton);
XtRealizeWidget(toplevel);
XtAppMainLoop(app_context);
return 0;
}
void activateCB(Widget w,XtPointer client_data,XtPointer call_data)
{
printf("PushButton selected.\n");
// XmStringFree(btn_text);
}
:-( |
|