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


    /*----------------------------------------------------------- 
        函数 _GetSP : 区位码输入法 
    -----------------------------------------------------------*/ 
    #include  
 
    extern void _Cdecl _ClearPrompt(int clear_mode); 
 
    unsigned _Cdecl _GetSP(h) 
    unsigned h;                  /* 进入该输入法时的编码串首码 */ 
    { 
        unsigned i=0,code=0; 
 
        /*-- 如果 h 为数字,按区位码首码处理 -------------------*/ 
        if(h>='0' && h<='9') 
        { 
 
            /*-- 清提示行 -------------------------------------*/ 
            _ClearPrompt(1); 
 
            /*-- 对区位码的码长(4)循环 ------------------------*/ 
            while(i<4) 
            { 
 
                /*-- 显示首码,处理首码 ------------------------*/ 
                outxyc(16+i,_PromptLine+7,_PmtColor,h); 
                code=code*10+h-'0'; 
                i++; 
 
                /*-- 接收其余各码,如果不是数字键 --------------*/ 
                while(i<4 && ((h=geth())<'0' || h>'9')) 
                { 
 
                    /*-- 如果输入了退格键,作废当前码 ----------*/ 
                    if(i>0 && (h==Backspace || h==KEY_Left)) 
                    { 
                        _Block(16+(--i),_PromptLine+7,1,CHAR_HIGH,_PmtBk); 
                        code/=10; 
                    } 
 
                    /*-- 如果要切换输入法 ---------------------*/ 
                    else if(h<=KEY_Alt_F1 && h>=KEY_Alt_F10) 
                    { 
                        ungeth(h); 
                        return 0; 
                    } 
 
                    /*-- 如果要作废当前的输入码 ---------------*/ 
                    else if(h==KEY_ENTER) 
                    { 
                        _ClearPrompt(1); 
                        return 0; 
                    } 
 
                    /*-- 其他各键均不合法 ---------------------*/ 
                    else 
                        putch(Beep); 
                } 
            } 
 
            /*-- 生成汉字的机内码,并将对应的汉字在提示行显示 --*/ 
            h = (code/100+160)|(code%100+160)<<8; 
            outxyh(29,_PromptLine+7,_PmtColor,h); 
        } 
 
        /*-- 返回汉字的机内码 ---------------------------------*/ 
        return h; 
    }