www.pudn.com > cwin.rar > GETXYP.C


    /*----------------------------------------------------------- 
        函数 getxyp : 口令录入编辑 
    -----------------------------------------------------------*/ 
    #include  
    #include  
    #include  
 
    unsigned _Cdecl getxyp(col,line,width,pass) 
    int col;             /* 编辑窗口左上角列坐标(以字节为单位) */ 
    int line;            /* 编辑窗口左上角行坐标(以象素为单位) */ 
    int width;           /* 编辑窗口宽度                       */ 
    char *pass;          /* 被编辑的口令字符串                 */ 
    { 
        char buff[21]; 
        unsigned h; 
        int pos         = 0; 
        int _EndEdit    = NO; 
        int old_c       = _TextColor; 
        int old_b       = _Background; 
        int have_cursor = iscursorlight(); 
        int mouselight  = ismouselight(); 
        int modified    = NO; 
 
        /*-- 设置工作缓冲区 -------------------*/ 
        if(width>20) 
            width = 20; 
        memset(pass,' ',width); 
        pass[width] = 0; 
        memset(buff,' ',width); 
        buff[width] = 0; 
 
        /*-- 显示编辑区 -----------------------*/ 
        set_text_color(_EditColor); 
        set_background(_EditBk); 
        _TextCol  = col; 
        _TextLine = line; 
        if(mouselight) 
            delight_mouse(); 
        putnstr(pass,width); 
        if(mouselight) 
            light_mouse(); 
        _TextCol    = col; 
 
        /*-- 编辑字符串 -----------------------*/ 
        if(!have_cursor) 
            lightcursor(); 
        while(_EndEdit==NO) 
        { 
            /*-- 接收一个键盘码 -------------------------------*/ 
            h = geth(); 
 
            /*-- 根据键盘码编辑 -------------------------------*/ 
            if(mouselight) 
                delight_mouse(); 
            switch(h) 
            { 
                case KEY_Left: 
                    if(pos) 
                    { 
                        pos--; 
                        _TextCol-=_Xtimes; 
                    } 
                    else 
                        _EndEdit = YES; 
                    break; 
                case KEY_Right: 
                    if(pos >= width-1) 
                        _EndEdit = YES; 
                    else 
                    { 
                        pos++; 
                        _TextCol+=_Xtimes; 
                    } 
                    break; 
                case KEY_Home: 
                    if(pos) 
                    { 
                        pos     = 0; 
                        _TextCol= col; 
                    } 
                    else 
                        _EndEdit=YES; 
                    break; 
                case KEY_End: 
                    if(pos