www.pudn.com > 智能内码识别,支持屏幕取词翻译的程序.zip > CSWIN.CPP
// cswin.cpp : implementation file // #include "stdafx.h" #include#include "resource.h" #include "basicwin.h" #include "basicbut.h" #include "systemse.h" #include "menubutt.h" #include "activebu.h" #include "cswin.h" #include "cspublic.h" #include "cskernel.h" #ifdef _DEBUG #undef THIS_FILE static char BASED_CODE THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CCsWin CCsWin::CCsWin() { GetSomePrograms() ; //初始化窗口参数 //窗口按钮行数 m_nRowNum =GetPrivateProfileInt( "窗口参数" , "窗口按钮行数" , 1 , INI_FILE_NAME ) ; //动作按钮数目 m_nActiveButtonNum =min( GetPrivateProfileInt( "工具箱" , "工具数目" , 0 , INI_FILE_NAME ) , MAX_ACTIVE_BUTTON ) ; //计算浮动条的列数 m_nColNum =(m_nActiveButtonNum+1)/m_nRowNum ; if( (m_nActiveButtonNum+1)%m_nRowNum ) //不能整除 m_nColNum++ ; //计算主窗口的宽度与高度 m_nWidth =m_nColNum*BUTTON_WIDTH + 2 ; m_nTuiHuaWidth =m_nWidth ; //退化宽度 m_nHeight =m_nRowNum*BUTTON_HEIGHT + 2 ; //窗口左上角位置 m_LeftTopPos.x =GetPrivateProfileInt( "窗口参数" , "窗口左上角的x坐标" , 300 , INI_FILE_NAME ) ; if( m_LeftTopPos.x<0 || m_LeftTopPos.x>GetSystemMetrics(SM_CXSCREEN)-m_nWidth ) m_LeftTopPos.x =300 ; m_LeftTopPos.y =GetPrivateProfileInt( "窗口参数" , "窗口左上角的y坐标" , 0 , INI_FILE_NAME ) ; if( m_LeftTopPos.y<0 || m_LeftTopPos.y>GetSystemMetrics(SM_CYSCREEN)-m_nHeight ) m_LeftTopPos.x =0 ; //创建主窗口 VERIFY( CreateEx( WS_EX_TOPMOST , AfxRegisterWndClass( CS_SAVEBITS , 0 , 0 , AfxGetApp()->LoadIcon( IDI_ICON1 ) ) , "中文大观(作者:朱佳良)" , WS_POPUP , m_LeftTopPos.x , m_LeftTopPos.y , m_nWidth , m_nHeight , NULL , NULL ) ) ; m_bButtonIsDown =0 ; //初始鼠标键没有按下 m_nMoveStatus =0 ; //创建系统按钮 RECT rect={ 1 , 1 , 1+BUTTON_WIDTH , 1+BUTTON_HEIGHT } ; VERIFY( m_SystemButton.InitButton( //系统按钮 "中文大观系统按钮(作者:朱佳良)" , rect , this , 111 , IDB_BITMAP1 , IDR_MENU1 ) ) ; m_SystemButton.SetHint( "中文大观系统设置" , "いゅ芠╰参砞竚" , "ChineseScape System Setup" ) ; m_SystemButton.SetActiveMode( 0 ) ; //创建动作按钮 char sBuff[100] ; char sToolName[1000] ; for( int i=1 ; i<=m_nActiveButtonNum ; i++ ) { //得到某个工具执行文件名 wsprintf( sBuff , "工具%d" , i ) ; ::GetPrivateProfileString( "工具箱" , sBuff , "Error.error" , sToolName , 1000 , INI_FILE_NAME ) ; if( !_fstrcmp( "Error.error" , sToolName ) ) { wsprintf( sBuff , "cscape.ini 文件中的工具%d 的执行文件名有问题" , i ) ; MessageBox( sBuff , "中文大观" , MB_ICONSTOP ) ; } //创建该工具的按钮 if( i%m_nColNum ) //不能整除,说明没有换行 { rect.left +=BUTTON_WIDTH ; rect.right +=BUTTON_WIDTH ; } else //整除了,说明换行了 { rect.top +=BUTTON_HEIGHT ; rect.bottom +=BUTTON_HEIGHT ; rect.left =1 ; rect.right =1+BUTTON_WIDTH ; } VERIFY( m_ActiveButton[i-1].InitButton( sToolName , rect , this , 110+i , sToolName ) ) ; m_ActiveButton[i-1].SetHint( sToolName , sToolName , sToolName ) ; } m_nTuiHuaHeight =4 ; //退化以后的高度设为4 } CCsWin::~CCsWin() { KillTimer( TIMER1_ID ) ; //破坏时间器 SaveParams() ; DestroyWindow() ; } //判断浮动条的初始状态 void CCsWin::JudgeInitStatus( void ) { int nMainWinStatus =GetPrivateProfileInt( "窗口参数" , "浮动条状态" , 2 , INI_FILE_NAME ) ; //得到浮动条状态 int nLine =GetPrivateProfileInt( "窗口参数" , "退化显示" , 1 , INI_FILE_NAME ) ; switch( nMainWinStatus ) { case 0: //初始状态为隐藏 ShowWindow( SW_HIDE ) ; //隐藏浮动条 break ; case 1: //初始状态为退化状态 if( nLine ) //允许退化显示 HideSubWins() ; else //不允许退化显示 SetMainWinStatus( 2 ) ; //修改主窗口状态为正常显示 break ; default: //为正常显示 if( nLine ) //允许退化显示 //设上退化时间器 SetTimer( TIMER1_ID , TIME_TO_WAIT_FOR_LINE , NULL ) ; } } //显示所有子窗口 void CCsWin::ShowSubWins( void ) { //显示系统按钮 m_SystemButton.ShowWindow( SW_SHOW ) ; //显示所有动作按钮 for( int i=0 ; i SetCapture() ; //得到鼠标控制权 m_bButtonIsDown =1 ; //标记鼠标键已经按下 m_OldMousePos =p ; pWnd->ClientToScreen( &m_OldMousePos ) ; //转换成系统坐标 } //鼠标松开 void CCsWin::ButtonUp( void ) { m_bButtonIsDown =0 ; //表示鼠标键已经松开 ReleaseCapture() ; } //移动窗口 void CCsWin::MoveWindowToNewPos( CWnd *pWnd , CPoint p ) { CPoint screenPoint =p ; pWnd->ClientToScreen( &screenPoint ) ; //转化成屏幕坐标 //鼠标已经按下,并且位置也发生变化 if( m_bButtonIsDown && m_OldMousePos!=screenPoint ) { CPoint oldLeftTopPos =m_LeftTopPos ; //原来左上角的位置 int nOldRowNum =m_nRowNum ; int nOldColNum =m_nColNum ; //得到桌面窗口的大小 RECT rect ; GetDesktopWindow()->GetClientRect( &rect ) ; //重新计算左上角的位置 m_LeftTopPos.x +=( screenPoint.x - m_OldMousePos.x ) ; m_LeftTopPos.y +=( screenPoint.y - m_OldMousePos.y ) ; if( m_LeftTopPos.x > rect.right-m_nWidth ) m_LeftTopPos.x =rect.right - m_nWidth ; if( m_LeftTopPos.x < 0 ) m_LeftTopPos.x =0 ; if( m_LeftTopPos.y > rect.bottom-m_nHeight ) m_LeftTopPos.y =rect.bottom - m_nHeight ; if( m_LeftTopPos.y < 0 ) m_LeftTopPos.y =0 ; //判断飞条是否到了边界 if( screenPoint.y < BUTTON_HEIGHT/2 || //上面 screenPoint.y>rect.bottom-BUTTON_HEIGHT/2 ) //下面 { m_nRowNum =1 ; m_nColNum =m_nActiveButtonNum+1 ; if( screenPoint.y>rect.bottom-BUTTON_HEIGHT/2 ) //在下面 m_LeftTopPos.y =rect.bottom-BUTTON_HEIGHT-2; } else if( screenPoint.x < BUTTON_WIDTH/2 || //左边 screenPoint.x>rect.right-BUTTON_WIDTH/2 ) //右边 { m_nRowNum =m_nActiveButtonNum+1 ; m_nColNum =1 ; if( screenPoint.x>rect.right-BUTTON_WIDTH/2 ) //在右边 m_LeftTopPos.x =rect.right-BUTTON_WIDTH-2 ; } if( m_nRowNum!=nOldRowNum || m_nColNum!=nOldColNum ) ChangeLayout() ; ////行数或列数有改变 else if( m_LeftTopPos!=oldLeftTopPos ) //位置有改变,但行、列不变 //重新设置窗口的位置 SetWindowPos( (CWnd*)&wndTopMost , m_LeftTopPos.x , m_LeftTopPos.y , m_nWidth , m_nHeight , SWP_NOACTIVATE ) ; m_OldMousePos =screenPoint ; //记录原来的位置 } } //根本宽度、高度重要调整布局 void CCsWin::ChangeLayout( void ) { int nOldRight =m_LeftTopPos.x+m_nWidth-1 ; int nOldBottom =m_LeftTopPos.y+m_nHeight-1 ; //计算主窗口的宽度与高度 m_nWidth =m_nColNum*BUTTON_WIDTH + 2 ; m_nTuiHuaWidth =m_nWidth ; m_nHeight =m_nRowNum*BUTTON_HEIGHT + 2 ; //调整主窗口的宽度与高度 if( m_nMoveStatus == 3 ) //上拉伸 m_LeftTopPos.y =nOldBottom-m_nHeight+1 ; else if( m_nMoveStatus == 5 ) //左拉伸 m_LeftTopPos.x =nOldRight-m_nWidth+1 ; //得到桌面窗口的大小 CWnd *desktopWnd =GetDesktopWindow() ; RECT rect ; desktopWnd->GetClientRect( &rect ) ; if( m_LeftTopPos.x < 0 ) m_LeftTopPos.x =0 ; else if( m_LeftTopPos.x+m_nWidth>rect.right ) m_LeftTopPos.x =rect.right-m_nWidth ; if( m_LeftTopPos.y < 0 ) m_LeftTopPos.y =0 ; else if( m_LeftTopPos.y+m_nHeight>rect.bottom ) m_LeftTopPos.y =rect.bottom-m_nHeight ; ShowWindow( SW_HIDE ) ; //先隐藏主窗口 POINT point ={ 1 , 1 } ; //左上角坐标 //调整动作按钮的位置 for( int i=1 ; i<=m_nActiveButtonNum ; i++ ) { if( i%m_nColNum ) //不能整除,说明没有换行 point.x +=BUTTON_WIDTH ; else //整除了,说明换行了 { point.x =1 ; point.y +=BUTTON_HEIGHT ; } m_ActiveButton[i-1].MoveWindow( point.x , point.y , BUTTON_WIDTH , BUTTON_HEIGHT ) ; } //显示主窗口 SetWindowPos( (CWnd*)&wndTopMost , m_LeftTopPos.x , m_LeftTopPos.y , m_nWidth , m_nHeight , SWP_SHOWWINDOW |SWP_NOACTIVATE ) ; } //根据现在飞条的行与列计算下一步的行数 //nFlag为1,增加行,0减少行 //nFlag为1,是行,0是列 int CCsWin::GetNextRowOrColNum( int nFlag , int nFlag1 ) { if( nFlag ) //增加行 { if( m_nColNum==1 ) //只剩一列了,不用再拉了 { if( nFlag1 ) //是行 return m_nRowNum ; else return m_nColNum ; } } else //减少行 { if( m_nRowNum==1 ) //只有一行 { if( nFlag1 ) //是行 return m_nRowNum ; else return m_nColNum ; } } int nRowNum =m_nRowNum ; int nColNum ; do //当最后一行是空白时,进行循环。 { if( nFlag ) nRowNum++ ; //增加行数 else nRowNum-- ; //计算浮动条的列数 nColNum =(m_nActiveButtonNum+1)/nRowNum ; if( (m_nActiveButtonNum+1)%nRowNum ) //不能整除 nColNum++ ; }while( (nRowNum-1)*nColNum >= m_nActiveButtonNum+1 ) ; if( nFlag1 ) //是行 return nRowNum ; else return nColNum ; } //改变浮条大小时,增加行数 void CCsWin::AddRow( void ) { if( m_nColNum==1 ) //只剩一列了,不用再拉了 return ; do //当最后一行是空白时,进行循环。 { m_nRowNum++ ; //增加行数 //计算浮动条的列数 m_nColNum =(m_nActiveButtonNum+1)/m_nRowNum ; if( (m_nActiveButtonNum+1)%m_nRowNum ) //不能整除 m_nColNum++ ; }while( (m_nRowNum-1)*m_nColNum >= m_nActiveButtonNum+1 ) ; //改变布局 ChangeLayout() ; } //改变浮条大小时,减少行数 void CCsWin::SubRow( void ) { if( m_nRowNum==1 ) //只有一行 return ; do //当最后一行为空白时,进行循环 { m_nRowNum-- ; //减少行数 //计算浮动条的列数 m_nColNum =(m_nActiveButtonNum+1)/m_nRowNum ; if( (m_nActiveButtonNum+1)%m_nRowNum ) //不能整除 m_nColNum++ ; }while( (m_nRowNum-1)*m_nColNum >= m_nActiveButtonNum+1 ) ; //改变布局 ChangeLayout() ; } //增加一个动作按钮 void CCsWin::AddOneActionButton( LPCSTR lpcsName ) { if( m_nActiveButtonNum>=MAX_ACTIVE_BUTTON ) { AfxMessageBox( "The number of max active button is full!" ) ; return ; } m_nActiveButtonNum++ ; //增加一个动作按钮 if( m_nRowNum==1 ) //只有一行 m_nColNum++ ; else //列数不变,重新计算浮动条的行数 { m_nRowNum =(m_nActiveButtonNum+1)/m_nColNum ; if( (m_nActiveButtonNum+1)%m_nColNum ) //不能整除 m_nRowNum++ ; } //重新计算浮动条的宽度与高度 m_nWidth =m_nColNum*BUTTON_WIDTH + 2 ; m_nTuiHuaWidth =m_nWidth ; //退化宽度 m_nHeight =m_nRowNum*BUTTON_HEIGHT + 2 ; //判断x方向位置 if( m_nWidth>=::GetSystemMetrics(SM_CXSCREEN) ) m_LeftTopPos.x =0 ; else if( m_LeftTopPos.x+m_nWidth> ::GetSystemMetrics(SM_CXSCREEN) ) m_LeftTopPos.x =::GetSystemMetrics(SM_CXSCREEN)-m_nWidth ; //判断y方向位置 if( m_nHeight>=::GetSystemMetrics(SM_CYSCREEN) ) m_LeftTopPos.y =0 ; else if( m_LeftTopPos.y+m_nHeight> ::GetSystemMetrics(SM_CYSCREEN) ) m_LeftTopPos.y =::GetSystemMetrics(SM_CYSCREEN)-m_nHeight ; //创建该工具的按钮 RECT rect={ 1 , 1 , 1+BUTTON_WIDTH , 1+BUTTON_HEIGHT } ; for( int i=1 ; i<=m_nActiveButtonNum ; i++ ) { //创建该工具的按钮 if( i%m_nColNum ) //不能整除,说明没有换行 { rect.left +=BUTTON_WIDTH ; rect.right +=BUTTON_WIDTH ; } else //整除了,说明换行了 { rect.top +=BUTTON_HEIGHT ; rect.bottom +=BUTTON_HEIGHT ; rect.left =1 ; rect.right =1+BUTTON_WIDTH ; } } i-- ; VERIFY( m_ActiveButton[i-1].InitButton( lpcsName , rect , this , 110+i , lpcsName ) ) ; m_ActiveButton[i-1].SetHint( lpcsName , lpcsName , lpcsName ) ; SetWindowPos( (CWnd*)&wndTopMost , m_LeftTopPos.x , m_LeftTopPos.y , m_nWidth , m_nHeight , SWP_NOACTIVATE|SWP_SHOWWINDOW ) ; } //删除一个动作按钮 void CCsWin::DelOneActionButton( int n ) { if( n<0 || n>=m_nActiveButtonNum ) //传入数据不对 return ; // ShowWindow( SW_HIDE ) ; //破坏该动作按钮 m_ActiveButton[n].DestroyWindow() ; //按钮前移 char sButtonName[1000] ; RECT rect={ 1 , 1 , 1+BUTTON_WIDTH , 1+BUTTON_HEIGHT } ; for( int i=0 ; i GetSystemMetrics(SM_CXSCREEN)-m_nWidth ) m_LeftTopPos.x =300 ; m_LeftTopPos.y =GetPrivateProfileInt( "窗口参数" , "窗口左上角的y坐标" , 0 , INI_FILE_NAME ) ; if( m_LeftTopPos.y<0 || m_LeftTopPos.y>GetSystemMetrics(SM_CYSCREEN)-m_nHeight ) m_LeftTopPos.x =0 ; RECT rect={ 1 , 1 , 1+BUTTON_WIDTH , 1+BUTTON_HEIGHT } ; //创建动作按钮 char sBuff[100] ; char sToolName[1000] ; for( i=1 ; i<=m_nActiveButtonNum ; i++ ) { //得到某个工具执行文件名 wsprintf( sBuff , "工具%d" , i ) ; ::GetPrivateProfileString( "工具箱" , sBuff , "Error.error" , sToolName , 1000 , INI_FILE_NAME ) ; if( !_fstrcmp( "Error.error" , sToolName ) ) { wsprintf( sBuff , "cscape.ini 文件中的工具%d 的执行文件名有问题" , i ) ; MessageBox( sBuff , "中文大观" , MB_ICONSTOP ) ; } //创建该工具的按钮 if( i%m_nColNum ) //不能整除,说明没有换行 { rect.left +=BUTTON_WIDTH ; rect.right +=BUTTON_WIDTH ; } else //整除了,说明换行了 { rect.top +=BUTTON_HEIGHT ; rect.bottom +=BUTTON_HEIGHT ; rect.left =1 ; rect.right =1+BUTTON_WIDTH ; } VERIFY( m_ActiveButton[i-1].InitButton( sToolName , rect , this , 110+i , sToolName ) ) ; m_ActiveButton[i-1].SetHint( sToolName , sToolName , sToolName ) ; } SetWindowPos( (CWnd*)&wndTopMost , m_LeftTopPos.x , m_LeftTopPos.y , m_nWidth , m_nHeight , SWP_NOACTIVATE|SWP_SHOWWINDOW ) ; } //得到一些常用的Windows 程序 #define WIN_PROGRAMS_NUM1 7 #define NAME_LEN 20 #define WIN_PROGRAMS_NUM2 2 void CCsWin::GetSomePrograms( void ) { char sNames1[WIN_PROGRAMS_NUM1][NAME_LEN]={ "\\NOTEPAD.EXE" , "\\CALC.EXE" , "\\WINMINE.EXE" , "\\SOL.EXE" , "\\WRITE.EXE" , "\\WINFILE.EXE" , "\\EXPLORER.EXE" } ; char sNames2[WIN_PROGRAMS_NUM2][NAME_LEN]={ "\\MSPAINT.EXE" , "\\WORDPAD.EXE" } ; //判断是不是第一次运行 if( GetPrivateProfileInt( "系统参数" , "是不是第一次运行" , 0 , INI_FILE_NAME ) ) return ; //不是 m_nActiveButtonNum =0 ; //初始动作按钮数为0 char sProgramName[200] ; //得到Windows 所在路径 if( !::GetWindowsDirectory( sProgramName , sizeof( sProgramName ) ) ) return ; int nLen =strlen( sProgramName ) ; //得到其长度 char sBuff[100] ; for( int i=0 ; i (m_nHeight-1)+MOVE_TAB ) //往下拉 AddRow() ; else if( point.y<(m_nHeight-1)-MOVE_TAB ) //往上拉 SubRow() ; } else if( m_nRowNum>m_nInitRowNum ) //比原来行数多 { if( point.y > (m_nHeight-1)+MOVE_TAB ) //往下拉 AddRow() ; else if( point.y<=(GetNextRowOrColNum(0,1)*BUTTON_HEIGHT +1)+MOVE_TAB ) //往上拉 SubRow() ; } else //比原来的行数要少 { if( point.y >=(GetNextRowOrColNum(1,1)*BUTTON_HEIGHT+1)- MOVE_TAB ) //往下拉 AddRow() ; else if( point.y<(m_nHeight-1)-MOVE_TAB ) //往上拉 SubRow() ; } break ; case 3: //上拉伸 if( m_nRowNum == m_nInitRowNum ) //与原来的行数一样 { if( point.y<-MOVE_TAB ) //往上拉 AddRow() ; else if( point.y>MOVE_TAB ) //往下拉 SubRow() ; } else if( m_nRowNum > m_nInitRowNum ) //比原来的行数多 { if( point.y<-MOVE_TAB ) //往上拉 AddRow() ; else if( point.y >=((m_nRowNum-GetNextRowOrColNum(0,1))* BUTTON_HEIGHT+1)-MOVE_TAB ) SubRow() ; //往下拉 } else //比原来的行数少 { if( point.y <= -((GetNextRowOrColNum(1,1)-m_nRowNum)* BUTTON_HEIGHT+1)+MOVE_TAB ) //往上拉 AddRow() ; else if( point.y > MOVE_TAB ) //往下拉 SubRow() ; } break ; case 4: //右拉伸 if( m_nRowNum==m_nInitRowNum ) //与原来行数一样 { if( point.x > (m_nWidth-1)+MOVE_TAB ) //往右拉 SubRow() ; else if( point.x<(m_nWidth-1)-MOVE_TAB ) //往左拉 AddRow() ; } else if( m_nRowNum>m_nInitRowNum ) //比原来行数多 { if( point.x >=(GetNextRowOrColNum(0,0)*BUTTON_WIDTH+1)- MOVE_TAB ) //往右拉 SubRow() ; else if( point.x<(m_nWidth-1)-MOVE_TAB ) //往左拉 AddRow() ; } else //比原来的行数要少 { if( point.x > (m_nWidth-1)+MOVE_TAB ) //往右拉 SubRow() ; else if( point.x<=(GetNextRowOrColNum(1,0)*BUTTON_WIDTH +1)+MOVE_TAB ) //往左拉 AddRow() ; } break ; case 5: //左拉伸 if( m_nRowNum == m_nInitRowNum ) //与原来的行数一样 { if( point.x<-MOVE_TAB ) //往左拉 SubRow() ; else if( point.x>MOVE_TAB ) //往右拉 AddRow() ; } else if( m_nRowNum > m_nInitRowNum ) //比原来的行数多 { if( point.x <=-((GetNextRowOrColNum(0,0)-m_nColNum)* BUTTON_WIDTH+1)+MOVE_TAB ) //往左拉 SubRow() ; else if( point.x > MOVE_TAB ) //往右拉 AddRow() ; } else //比原来的行数少 { if( point.x<-MOVE_TAB ) //往左拉 SubRow() ; else if( point.x >=(m_nColNum-GetNextRowOrColNum(1,0))* BUTTON_WIDTH+1-MOVE_TAB ) AddRow() ; //往右拉 } break ; } CBasicWin::OnMouseMove(nFlags, point); } void CCsWin::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here if( GetMainWinStatus()==1 ) //浮动条处于退化状态 { RECT rect={ 0 , 0 , m_nTuiHuaWidth-1 , m_nTuiHuaHeight-1 } ; DrawTwoLineBox( dc.m_hDC , rect , 1 , RGB(192,192,192) ) ; //显示退化窗口 } else //是正常显示窗口 { RECT rect={ 0 , 0 , m_nWidth-1 , m_nHeight-1 } ; //黑笔 CPen *pOldPen =(CPen*)dc.SelectStockObject( BLACK_PEN ) ; dc.SelectStockObject( LTGRAY_BRUSH ) ; //浅灰刷 dc.Rectangle( rect.left , rect.top , rect.right+1 , rect.bottom+1 ) ; //浅灰笔 CPen LowGrayPen( PS_SOLID , 1 , RGB( 192 , 192 , 192 ) ) ; dc.SelectObject( &LowGrayPen ) ; //浅灰笔 dc.MoveTo( rect.right-1 , rect.top ) ; //画左上角外面的浅灰线 dc.LineTo( rect.left , rect.top ) ; dc.LineTo( rect.left , rect.bottom ) ; dc.SelectObject( pOldPen ) ; } // Do not call CWnd::OnPaint() for painting messages } void CCsWin::OnDestroy() { CBasicWin::OnDestroy(); // TODO: Add your message handler code here EndCs() ; PostQuitMessage(0); //结束中文大观 } //响应自定义消息函数,增/删动作按钮 LONG CCsWin::OnChangeActionButton( WPARAM wParam , LPARAM lParam ) { switch( wParam ) { case 1: //增加一个按钮 AddOneActionButton( (LPCSTR)lParam ) ; break ; case 2: //减少一个按钮 DelOneActionButton( (int)lParam ) ; break ; case 3: //保存参数 SaveParams() ; break ; default: //重新载入动作按钮 ReloadAllActionButtons() ; } return 1 ; } //响应自定义消息函数,安装/删除时间器 LONG CCsWin::OnSetTimer( WPARAM wParam , LPARAM lParam ) { if( wParam==1 ) //安装时间器 ShowSubWins() ; else //删除时间器 KillTimer( TIMER1_ID ) ; //破坏原来的时间器 return 1 ; } void CCsWin::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default if( nIDEvent==TIMER1_ID && !m_bButtonIsDown ) //鼠标没有按下 { KillTimer( TIMER1_ID ) ; //破坏原来的时间器 if( GetLineFlag() ) //允许退化显示 { //判断是否移出了窗口 CPoint point ; CRect clientRect ; GetCursorPos( (LPPOINT)&point ) ; //当前鼠标所在点 ScreenToClient( &point ) ; GetClientRect( &clientRect ) ; //得到该窗口大小 if( !clientRect.PtInRect( point ) && //已经移出该窗口 GetLineSwitch() ) //可以进行退化显示 { SetMainWinStatus( 1 ) ; //改为退化显示 HideSubWins() ; //隐藏所有子窗口 } else //设上新的时间器 SetTimer( TIMER1_ID , TIME_TO_WAIT_FOR_LINE , NULL ) ; } } CBasicWin::OnTimer(nIDEvent); } BOOL CCsWin::OnQueryEndSession() { if (!CBasicWin::OnQueryEndSession()) return FALSE; // TODO: Add your specialized query end session code here EndCs() ; return TRUE; } void CCsWin::EndCs( void ) { //摘掉所有钩子 HookOffAllHooks() ; if( GetFingerTranslate() ) HookFingerOff() ; //卸掉汉字系统 if( GetOutputCode()<5 || GetFingerTranslate() ) ToEnglish() ; UnloadZk( 1 ) ; //卸掉所有显示库 }