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

📄 statusui.cpp

📁 输入法源代码自由拼音输入法源代码(T9)
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    HWND    hStatusWnd,
    LPPOINT lpptCursor)
{
    HWND           hUIWnd;
    HIMC           hIMC;
    LPINPUTCONTEXT lpIMC;

    hUIWnd = GetWindow(hStatusWnd, GW_OWNER);
    hIMC = (HIMC)GetWindowLong(hUIWnd, IMMGWLP_IMC);
    if (!hIMC) {
        return;
    }

    lpIMC = (LPINPUTCONTEXT)ImmLockIMC(hIMC);
    if (!lpIMC) {
        return;
    }

    if (!lpIMC->fOpen) {
        ImmSetOpenStatus(hIMC, TRUE);
    } else if (PtInRect(&sImeG.rcImeIcon, *lpptCursor)) {
        DWORD fdwConversion;

        ///////鼠标单击
        if (lpIMC->fdwConversion & (IME_CMODE_CHARCODE|IME_CMODE_EUDC)) {
        // change to native mode
        fdwConversion = (lpIMC->fdwConversion | IME_CMODE_NATIVE) &
        ~(IME_CMODE_CHARCODE | IME_CMODE_EUDC);
    } else if (lpIMC->fdwConversion & IME_CMODE_NATIVE) {
        // change to alphanumeric mode
        fdwConversion = lpIMC->fdwConversion & ~(IME_CMODE_CHARCODE |
        IME_CMODE_NATIVE | IME_CMODE_EUDC);

    }
    ImmSetConversionStatus(hIMC, fdwConversion, lpIMC->fdwSentence);
    } else if (PtInRect(&sImeG.rcImeName, *lpptCursor)) {
        RECT  rcWnd;  
        SetCursor(LoadCursor(NULL, IDC_SIZEALL));
        SystemParametersInfo(SPI_GETWORKAREA, 0, &sImeG.rcWorkArea, 0);
			   
        SetCapture(hStatusWnd);
              SetWindowLong(hStatusWnd, UI_MOVE_XY,
              MAKELONG(lpptCursor->x, lpptCursor->y));
        GetWindowRect(hStatusWnd, &rcWnd);
        SetWindowLong(hStatusWnd, UI_MOVE_OFFSET,
              MAKELONG(lpptCursor->x - rcWnd.left, lpptCursor->y - rcWnd.top));

        DrawDragBorder(hStatusWnd, MAKELONG(lpptCursor->x, lpptCursor->y),
             GetWindowLong(hStatusWnd, UI_MOVE_OFFSET));
    }else {
    MessageBeep((UINT)-1);
    //	__asm int 3;
    }

    ImmUnlockIMC(hIMC);
    return;
}

/**********************************************************************/
/* PaintStatusWindow()                                                */
/**********************************************************************/
void PASCAL PaintStatusWindow(
    HDC  hDC,
    HWND hStatusWnd)
{
    HWND           hUIWnd;
    HIMC           hIMC;
    LPINPUTCONTEXT lpIMC;
    LPPRIVCONTEXT  lpImcP;
    HGDIOBJ        hOldFont;
    HBITMAP        hImeIconBmp;
    HBITMAP        hOldBmp;
    HDC            hMemDC;

    hUIWnd = GetWindow(hStatusWnd, GW_OWNER);

    hIMC = (HIMC)GetWindowLong(hUIWnd, IMMGWLP_IMC);
    if (!hIMC) {
       MessageBeep((UINT)-1);
//	   __asm int 3;
       return;
    }

    if (!(lpIMC = (LPINPUTCONTEXT)ImmLockIMC(hIMC))) {
       MessageBeep((UINT)-1);
//	   __asm int 3;
       return;
    }

    // get lpImcP
    if(!(lpImcP = (LPPRIVCONTEXT)ImmLockIMCC(lpIMC->hPrivate))) {
        MessageBeep((UINT)-1);
//		__asm int 3;
        return;
    }

    //in case the IME index has been changed and the ImeName size is different
    {
       POINTS         ptPos;

       ptPos.x = (short)lpIMC->ptStatusWndPos.x;
       ptPos.y = (short)lpIMC->ptStatusWndPos.y;

       SetWindowPos(hStatusWnd, 
		   NULL,
           ptPos.x,
		   ptPos.y,
           sImeG.xStatusWi, 
		   sImeG.yStatusHi, 
           SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOZORDER);
    }

    // set font
    if (sImeG.fDiffSysCharSet) {
        LOGFONT lfFont;
        ZeroMemory(&lfFont, sizeof(lfFont));
        hOldFont = GetCurrentObject(hDC, OBJ_FONT);
        lfFont.lfHeight = -((12*GetDeviceCaps(hDC, LOGPIXELSY))/72);
        lfFont.lfCharSet = NATIVE_CHARSET;
        lstrcpy(lfFont.lfFaceName, TEXT("Simsun"));
        SelectObject(hDC, CreateFontIndirect(&lfFont));
    }

    // draw Ime Name

    if (lpIMC->fOpen) {
       SetTextColor(hDC, RGB(0x00, 0x00, 0x00));
    } else {
       SetTextColor(hDC, RGB(0x80, 0x80, 0x80));
    }

    SetBkColor(hDC, RGB(0xC0, 0xC0, 0xC0));
    DrawText(hDC, szImeName, lstrlen(szImeName),
         &sImeG.rcImeName, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
    
    DrawConvexRect(hDC,
    sImeG.rcImeName.left,
    sImeG.rcImeName.top,
    sImeG.rcImeName.right - 1,
    sImeG.rcImeName.bottom - 1);

    DrawConvexRectP(hDC,
    sImeG.rcImeName.left,
    sImeG.rcImeName.top,
    sImeG.rcImeName.right,
    sImeG.rcImeName.bottom);

    // load all bitmap

    if (!lpIMC->fOpen) {
       hImeIconBmp = LoadBitmap(hInst, szChinese);
    } else if (lpIMC->fdwConversion & IME_CMODE_NATIVE) {
       hImeIconBmp = LoadBitmap(hInst, szChinese);
    } else {
       hImeIconBmp = LoadBitmap(hInst, szEnglish);
    }

    ImmUnlockIMC(hIMC);
    ImmUnlockIMCC(lpIMC->hPrivate);

    hMemDC = CreateCompatibleDC(hDC);

    hOldBmp = (HBITMAP)SelectObject(hMemDC, hImeIconBmp);

    BitBlt(hDC, sImeG.rcImeIcon.left, sImeG.rcImeIcon.top,
           sImeG.rcImeIcon.right - sImeG.rcImeIcon.left,
           STATUS_DIM_Y,
           hMemDC, 0, 0, SRCCOPY);

    SelectObject(hMemDC, hOldBmp);

    DeleteDC(hMemDC);

    DeleteObject(hImeIconBmp);
    if (sImeG.fDiffSysCharSet) {
        DeleteObject(SelectObject(hDC, hOldFont));
    }
    return;
}

/**********************************************************************/
/* StatusWndProc()                                                    */
/**********************************************************************/
LRESULT CALLBACK StatusWndProc(
    HWND   hStatusWnd,
    UINT   uMsg,
    WPARAM wParam,
    LPARAM lParam)
{
    switch (uMsg) {
    case WM_DESTROY:
         DestroyStatusWindow(hStatusWnd);
         break;
    case WM_SETCURSOR:
   	  {
         POINT ptCursor;
         if (GetWindowLong(hStatusWnd, UI_MOVE_OFFSET) != WINDOW_NOT_DRAG) {
             SetCursor(LoadCursor(NULL, IDC_SIZEALL));
             break;
         }
			   
		 GetCursorPos(&ptCursor);
		 ScreenToClient(hStatusWnd, &ptCursor);
		 
		 if (PtInRect(&sImeG.rcStatusText, ptCursor)) {
            SetCursor(LoadCursor(hInst, szHandCursor));
		 }else{
		    SetCursor(LoadCursor(NULL, IDC_SIZEALL));
		 }
	  }
      break;
    case 	WM_LBUTTONDOWN:
	  {
         RECT  rcWnd;
         POINT ptCursor,ptSavCursor;
			   
		 if (GetWindowLong(hStatusWnd, UI_MOVE_OFFSET) != WINDOW_NOT_DRAG) {
            SetCursor(LoadCursor(NULL, IDC_SIZEALL));
            break;
		 }
		 
		 ptCursor.x = LOWORD(lParam); 
		 ptCursor.y = HIWORD(lParam); 
		 ptSavCursor = ptCursor;
		 if (PtInRect(&sImeG.rcStatusText, ptCursor)) {
              SetCursor(LoadCursor(hInst, szHandCursor));
              SetStatus(hStatusWnd, &ptCursor);
		 }else{
              SetCursor(LoadCursor(NULL, IDC_SIZEALL));
              SystemParametersInfo(SPI_GETWORKAREA, 0, &sImeG.rcWorkArea, 0);
			   
              SetCapture(hStatusWnd);
              SetWindowLong(hStatusWnd, UI_MOVE_XY,
                   MAKELONG(ptSavCursor.x, ptSavCursor.y));
              GetWindowRect(hStatusWnd, &rcWnd);
              SetWindowLong(hStatusWnd, UI_MOVE_OFFSET,
                   MAKELONG(ptSavCursor.x - rcWnd.left, ptSavCursor.y - rcWnd.top));
              DrawDragBorder(hStatusWnd, MAKELONG(ptSavCursor.x, ptSavCursor.y),
                   GetWindowLong(hStatusWnd, UI_MOVE_OFFSET));
		 }
   	   }
	   break;
     case 	WM_MOUSEMOVE:
	   {
          if (GetWindowLong(hStatusWnd, UI_MOVE_OFFSET) != WINDOW_NOT_DRAG) {
              POINT ptCursor;
              ptCursor.x = LOWORD(lParam); 
              ptCursor.y = HIWORD(lParam); 
              DrawDragBorder(hStatusWnd,
                 GetWindowLong(hStatusWnd, UI_MOVE_XY),
              GetWindowLong(hStatusWnd, UI_MOVE_OFFSET));
				
	          SetWindowLong(hStatusWnd, UI_MOVE_XY,
                 MAKELONG(ptCursor.x, ptCursor.y));
			
              DrawDragBorder(hStatusWnd, MAKELONG(ptCursor.x, ptCursor.y),
                 GetWindowLong(hStatusWnd, UI_MOVE_OFFSET));
	   } else {
          return DefWindowProc(hStatusWnd, uMsg, wParam, lParam);
	   }
     	   }
	   break; 	
     case 	WM_LBUTTONUP: 
	   if (GetWindowLong(hStatusWnd, UI_MOVE_OFFSET) != WINDOW_NOT_DRAG) {
	   	
	      LONG  lTmpCursor, lTmpOffset;
	      lTmpCursor = GetWindowLong(hStatusWnd, UI_MOVE_XY);

	      // calculate the org by the offset
	      lTmpOffset = GetWindowLong(hStatusWnd, UI_MOVE_OFFSET);

	      DrawDragBorder(hStatusWnd, lTmpCursor, lTmpOffset);
	      (*(LPPOINTS)&lTmpCursor).x -= (*(LPPOINTS)&lTmpOffset).x;
	      (*(LPPOINTS)&lTmpCursor).y -= (*(LPPOINTS)&lTmpOffset).y;
	      SetWindowLong(hStatusWnd, UI_MOVE_OFFSET, WINDOW_NOT_DRAG);
	      ReleaseCapture();
	      AdjustStatusBoundary((LPPOINTS)&lTmpCursor,
                GetWindow(hStatusWnd, GW_OWNER));

	      SendMessage(GetWindow(hStatusWnd, GW_OWNER), WM_IME_CONTROL,
                IMC_SETSTATUSWINDOWPOS, lTmpCursor);
	      } else {
               return DefWindowProc(hStatusWnd, uMsg, wParam, lParam);
	      }
	      break;
    case WM_IME_NOTIFY:
	      // get work area for changing
	      SystemParametersInfo(SPI_GETWORKAREA, 0, &sImeG.rcWorkArea, 0);
	      if (wParam == IMN_SETSTATUSWINDOWPOS) {
            SetStatusWindowPos(hStatusWnd);
	      }
         break;
    case WM_PAINT:
        {
         HDC         hDC;
         PAINTSTRUCT ps;
         hDC = BeginPaint(hStatusWnd, &ps);
         PaintStatusWindow(hDC, hStatusWnd);
         EndPaint(hStatusWnd, &ps);
       }
       break;
    case WM_MOUSEACTIVATE:
       return (MA_NOACTIVATE);
   default:
       return DefWindowProc(hStatusWnd, uMsg, wParam, lParam);
    }
    return (0L);
}


⌨️ 快捷键说明

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