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

📄 threadpro.cpp

📁 包含拼音和笔画输入的中文输入法,使用VC.NET2003开发.portable Chinese input method includes phonetic input and stroke, the
💻 CPP
字号:
#include "stdafx.h" 
#include "ThreadInfor.h"
#include  <atltime.h>




 UINT ThreadProc(LPVOID lpParam)
{  
   ThreadInfor * lpThreadInfor =  (ThreadInfor *) lpParam ;

   TCHAR aChar[9][3] ={{'A','B','C'},{'D','E','F'},{'G','H','I'},
					 {'J','K','L'},{'M','N','O'},{'P','Q','R'},
					 {'S','T','U'},{'V','W','X'},{'Y','Z',' '}}; 

  BtnMsg *pBtnMsg ;  
  int nClickGap = 1000 ;  //击键在500毫秒之内为连续击键 
  int nCharCount = 3 ; //字母的个数
  
 //  UINT nchar = 65 ; 
   while (*lpThreadInfor->lpKillThread == FALSE )
   {     
       
       
	   pBtnMsg = lpThreadInfor->pBtnMsg ; 
	   
	   
	   while(*(lpThreadInfor->lpLock) == TRUE )    
	   { 
          //在循环时,表示等待解锁
	   } 

	     //跳出循环时,锁已经解开了
	   //他自己加锁
        *(lpThreadInfor->lpLock) = TRUE  ;
       	 

		POSITION pos = pBtnMsg->GetHeadPosition( ) ;

		int  nSendCount = 0 ; //发送的次数 
		while( pos != NULL )
	   {   
           
		   CBtnMsg *  Btn = pBtnMsg->GetNext(pos ) ;
		   //当前位置
          POSITION CuurPos = pos ; 
		  int nCount = 0 ; //连续击键次数
          int nBtnPre = *(Btn->pBtnNo) ;  //前一次的按键序号
		  CFileTime ftPre  = *(Btn->pCurrTime) ;  //前一次的击键时间

          while( CuurPos != NULL )
		  {    
		    
               CBtnMsg *  tmpBtn = pBtnMsg->GetNext(CuurPos ) ; 
			   CFileTime ftCurr = *(tmpBtn ->pCurrTime) ; //本次的击键时间
               int nBtnCurr =  *(tmpBtn ->pBtnNo) ; //当前按键序号 
               CFileTimeSpan  tSpan = ftCurr - ftPre ;   // 击键间隔

			   if (( nBtnPre != nBtnCurr ) || (tSpan > nClickGap*CFileTime::Millisecond  ) )    
			   {   
				   pBtnMsg->GetPrev(CuurPos ) ; //回退一个步
				   break ; 
              
			   }
			   else
			   {
                  nCount++ ;
                  nBtnPre = nBtnCurr ;
                  ftPre = ftCurr ;
               }

		  }
           nCount = nCount % nCharCount ; 
           
           if ( (nSendCount == 0 ) || (CuurPos != NULL ) ) 
		   {
 	   	      ::PostMessage(lpThreadInfor->hWnd , WM_KEYUP,aChar[nBtnPre-1][nCount] ,0) ;  
               nSendCount++ ; 
		   }
		    for ( int i =0 ; i<= nCount ; i++ ) 
			{   

		        CBtnMsg * ptemp =  pBtnMsg->RemoveHead(  )  ;   // 
				if (ptemp != NULL ) 
					delete ptemp ;
			}
          
		   pos = CuurPos ; //将 
		 // delete ptemp ; 

	   }
    
	   //解锁
		 *(lpThreadInfor->lpLock) = FALSE  ;

        ::Sleep(500) ;  

   }
  
   return 0 ;
	
} 


⌨️ 快捷键说明

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