www.pudn.com > cwin.rar > GETXYL.C
/*-----------------------------------------------------------
函数 getxyl : 编辑长整型数据
-----------------------------------------------------------*/
#include
#include
#include
#include
unsigned _Cdecl getxyl(col,line,width,value,limit1,limit2)
int col; /* 编辑窗口左上角列坐标(以字节为单位) */
int line; /* 编辑窗口左上角行坐标(以象素为单位) */
int width; /* 编辑窗口宽度 */
long *value; /* 指向待编辑的长整型数据的指针 */
long limit1; /* 待编辑数据的上限 */
long limit2; /* 待编辑数据的下限 */
{
char s[21]; /* 编辑缓冲区 */
char p[21]; /* 格式缓冲区 */
unsigned h; /* 编辑键 */
/*-- 检验数据值上、下限的合法性 -------*/
if(limit1 >= limit2)
return KEY_ESC;
if(width>20)
width = 20;
/*-- 构造格式缓冲区 -------------------*/
memset(p,'9',width);
*(p+width) = 0;
/*-- 对非法输入值循环 -----------------*/
while(1)
{
/*-- 如果数值溢出用星号表示 -------*/
if(*value==LONG_MAX)
{
memset(s,'*',width);
s[width] = 0;
}
/*-- 数据转换为字符串 -------------*/
else
sprintf(s,"%*ld",width,*value);
/*-- 调用通用数据编辑函数 ---------*/
h = getxya(col,line,width,s,p);
/*-- 如果作废编辑或编辑内容不变 ---*/
if(h==KEY_ESC || h==RIGHT_BUTTON)
break;
/*-- 字符串转换回长整型数据 -------*/
*value = atol(s);
if(*valuelimit2)
{
sound(900);
delay(100);
nosound();
}
/*-- 构造输出结果 ------------------*/
else
{
int havemouse = ismouselight();
sprintf(s,"%*ld",width,*value);
_TextCol = col;
if(havemouse)
delight_mouse();
putnstr(s,width);
if(havemouse)
light_mouse();
break;
}
}
/*-- 返回退出编辑状态的键盘码 ---------*/
return h;
}