⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 list_17_08.c

📁 This source code has been tested under OpenWindows 2.0, Sun s X11/NeWS server. For Xlib programs th
💻 C
字号:
/*************************************************************************                                                                    ****  listing_17_08.c                                                   ****                                                                    ****  Digital clock program, implemented using a label updated by a     ****  timeout callback.                                                 ****                                                                    *************************************************************************/#include <time.h>#include <Xm/Label.h>void	TimeoutCB();			/* FORWARD Definitions	      */Widget	appshell,	the_label;void main( argc, argv )    int     argc;    char    *argv[];{    appshell = XtInitialize( argv[0], "Listing_17_08", NULL, 0, &argc, argv );    the_label = XmCreateLabel( appshell, "TheLabel", NULL, 0 );    XtManageChild( the_label );    XtAddTimeOut( 1000, TimeoutCB, the_label );    XtRealizeWidget( appshell );    XtMainLoop();}void TimeoutCB( w, id )    Widget	    w;			/* Note implicit caddr_t cast */    XtIntervalId    *id;		/* Ignored		      */{    long	    clock;		/* The raw time value...      */    struct tm	    *the_time;		/* Converted to localtime...  */    char	    lcl_str[256];       /* Converted to text...       */    XmString	    xms;		/* Converted for the widget   */    Arg		    the_arg;    XtAddTimeOut( 1000, TimeoutCB, the_label );    clock    = time( NULL );    the_time = localtime( &clock );    sprintf( lcl_str, "%02d:%02d:%02d", the_time->tm_hour,					the_time->tm_min,					the_time->tm_sec );    xms = XmStringCreate( lcl_str, XmSTRING_DEFAULT_CHARSET );    XtSetArg( the_arg, XmNlabelString, xms );    XtSetValues( w, &the_arg, 1 );    XmStringFree( xms );}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -