示例#1
0
void MoveCandWindow(HWND hUIWnd,LPUIEXTRA lpUIExtra, LPINPUTCONTEXT lpIMC)
{
	if (!IsWindow(lpUIExtra->uiCand.hWnd))
		CreateCandWindow( hUIWnd, lpUIExtra);

	if (IsWindow(lpUIExtra->uiCand.hWnd))
	{
	    LPCANDIDATEINFO lpCandInfo;
	    LPCANDIDATELIST lpCandList;
		HDC hDC;
		HFONT oldFont;
		SIZE sz;
		LPTSTR lpStr;

		sz.cx = 0;
		sz.cy = 0;

		if (lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo))
		{
			lpCandList = (LPCANDIDATELIST)((LPSTR)lpCandInfo  + lpCandInfo->dwOffset[0]);
			if( lpCandList->dwCount <= 0) {
				ShowWindow(lpUIExtra->uiCand.hWnd, SW_HIDE);
				ImmUnlockIMCC(lpIMC->hCandInfo);
				return;
			}
			lpStr = GETLPCANDSTR(lpCandList,1);
			hDC = GetDC(lpUIExtra->uiCand.hWnd);
			oldFont = SelectObject(hDC, hUIFont);
			GetTextExtentPoint(hDC,lpStr,_tcslen(lpStr),&sz);
			SelectObject(hDC, oldFont);
			ReleaseDC(lpUIExtra->uiCand.hWnd,hDC);
			if(_tcslen(lpStr))	sz.cx += 3*sz.cx/_tcslen(lpStr);
			ImmUnlockIMCC(lpIMC->hCandInfo);
		}
		if(wConversionSet & CONVERSION_SET_SHAPE) {	
			sz.cx = sizeCand[1].cx;
			sz.cy = sizeCand[1].cy;
		}
		else{
			if(sz.cx < lpUIExtra->uiCand.sz.cx)
					sz.cx = lpUIExtra->uiCand.sz.cx;
			sz.cy = lpUIExtra->uiCand.sz.cy;
		}

		GetCandPosFromCompWnd(lpUIExtra,&sz);

		MoveWindow(lpUIExtra->uiCand.hWnd,
			lpUIExtra->uiCand.pt.x,
			lpUIExtra->uiCand.pt.y,
			sz.cx,
			sz.cy,
			TRUE);
		ShowWindow(lpUIExtra->uiCand.hWnd,SW_SHOWNOACTIVATE);
		InvalidateRect(lpUIExtra->uiCand.hWnd,NULL,FALSE);
	}
}
示例#2
0
LRESULT WINAPI UIWndProc(
				HWND hWnd,
				UINT message,
				WPARAM wParam,
				LPARAM lParam)
{
	
    HIMC           hUICurIMC;
    LPINPUTCONTEXT lpIMC;
    LPUIEXTRA      lpUIExtra;
    HGLOBAL        hUIExtra;
    LONG           lRet = 0L;
	
	DebugLog(1,(DebugLogFile,"UIWnd\n"));
	
    hUICurIMC = (HIMC)GetWindowLong(hWnd,IMMGWL_IMC);
	
    //
    // Even if there is no current UI. these messages should not be pass to 
    // DefWindowProc().
    //
    if (!hUICurIMC)
    {
        switch (message)
        {
		case WM_IME_STARTCOMPOSITION:
		case WM_IME_ENDCOMPOSITION:
		case WM_IME_COMPOSITION:
		case WM_IME_NOTIFY:
		case WM_IME_CONTROL:
		case WM_IME_COMPOSITIONFULL:
		case WM_IME_SELECT:
		case WM_IME_CHAR:
			return 0L;
		default:
			break;
        }
    }
	
    switch (message)
    {
	case WM_CREATE:
		DebugLog(1,(DebugLogFile,"UIWnd:WM_CREATE\n"));
		
		//
		// Allocate UI's extra memory block.
		//
		hUIExtra = GlobalAlloc(GHND,sizeof(UIEXTRA));
		lpUIExtra = (LPUIEXTRA)GlobalLock(hUIExtra);

		lpUIExtra->uiComp.pt.x = -1;
		lpUIExtra->uiComp.pt.y = -1;

		CreateCompWindow(hWnd,lpUIExtra);
		CreateCandWindow(hWnd,lpUIExtra);

		GlobalUnlock(hUIExtra);
		SetWindowLong(hWnd,IMMGWL_PRIVATE,(DWORD)hUIExtra);
		break;
		
	case WM_IME_SETCONTEXT:
		DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_SETCONTEXT\n"));
		if (wParam)
		{
			
			hUIExtra = (HGLOBAL)GetWindowLong(hWnd,IMMGWL_PRIVATE);
			lpUIExtra = (LPUIEXTRA)GlobalLock(hUIExtra);
			
			if (hUICurIMC)
			{
				//
				// input context was chenged.
				// if there are the child windows, the diplay have to be
				// updated.
				//
				lpIMC = ImmLockIMC(hUICurIMC);
				if (lpIMC)
				{
					MoveCandWindow(hWnd,lpUIExtra,lpIMC);
					MoveCompWindow(hWnd,lpUIExtra,lpIMC);
				}
				else
				{
					HideCandWindow(lpUIExtra);
					HideCompWindow(lpUIExtra);
				}
				ImmUnlockIMC(hUICurIMC);
			}
			else   // it is NULL input context.
			{
				HideCandWindow(lpUIExtra);
				HideCompWindow(lpUIExtra);
				
			}
			GlobalUnlock(hUIExtra);
		}
		break;
		
	case WM_IME_STARTCOMPOSITION:
		DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_STARTCOMPOSITION\n"));
		//
		// Start composition! Ready to display the composition string.
		//
		break;
		
	case WM_IME_COMPOSITION:
		DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_COMPOSITION\n"));
		
		//
		// Update to display the composition string.
		//
		lpIMC = ImmLockIMC(hUICurIMC);
		hUIExtra = (HGLOBAL)GetWindowLong(hWnd,IMMGWL_PRIVATE);
		lpUIExtra = (LPUIEXTRA)GlobalLock(hUIExtra);
		MoveCompWindow(hWnd,lpUIExtra,lpIMC);
		MoveCandWindow(hWnd,lpUIExtra,lpIMC);
		GlobalUnlock(hUIExtra);
		ImmUnlockIMC(hUICurIMC);
		break;
		
	case WM_IME_ENDCOMPOSITION:
		DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_ENDCOMPOSITION\n"));
		
		//
		// Finish to display the composition string.
		//
		hUIExtra = (HGLOBAL)GetWindowLong(hWnd,IMMGWL_PRIVATE);
		lpUIExtra = (LPUIEXTRA)GlobalLock(hUIExtra);
		HideCompWindow(lpUIExtra);
		HideCandWindow(lpUIExtra);
		GlobalUnlock(hUIExtra);
		break;
		
	case WM_IME_COMPOSITIONFULL:
		DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_COMPOSITIONFULL\n"));
		break;
		
	case WM_IME_SELECT:
		DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_SELECT\n"));
		break;
		
	case WM_IME_CONTROL:
		DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_CONTROL\n"));
		lRet = ControlHandle(hUICurIMC, hWnd,message,wParam,lParam);
		break;
		
		
	case WM_IME_NOTIFY:
		DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_NOTIFY\n"));
		lRet = NotifyHandle(hUICurIMC, hWnd,message,wParam,lParam);
		break;
		
	case WM_DESTROY:
		DebugLog(1,(DebugLogFile,"UIWnd:WM_DESTROY\n"));
		
		hUIExtra = (HGLOBAL)GetWindowLong(hWnd,IMMGWL_PRIVATE);
		lpUIExtra = (LPUIEXTRA)GlobalLock(hUIExtra);
		
		if (IsWindow(lpUIExtra->uiStatus.hWnd))
			DestroyWindow(lpUIExtra->uiStatus.hWnd);
		
		if (IsWindow(lpUIExtra->uiCand.hWnd))
			DestroyWindow(lpUIExtra->uiCand.hWnd);
		
		if (IsWindow(lpUIExtra->uiComp.hWnd))
			DestroyWindow(lpUIExtra->uiComp.hWnd);
		
		GlobalUnlock(hUIExtra);
		GlobalFree(hUIExtra);
		break;

	case WM_UI_COMPMOVE:
		hUIExtra = (HGLOBAL)GetWindowLong(hWnd,IMMGWL_PRIVATE);
		lpUIExtra = (LPUIEXTRA)GlobalLock(hUIExtra);
		lpUIExtra->uiComp.pt.x = (long)LOWORD(lParam);
		lpUIExtra->uiComp.pt.y = (long)HIWORD(lParam);
		GlobalUnlock(hUIExtra);
		break;

	default:
		return DefWindowProc(hWnd,message,wParam,lParam);
    }
    return lRet;
}
示例#3
0
LRESULT WINAPI UIWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	HIMC           hUICurIMC;
	LPINPUTCONTEXT lpIMC;
	LPUIEXTRA      lpUIExtra;
	HGLOBAL        hUIExtra;
	LONG           lRet = 0L;

	
	hUICurIMC = (HIMC)GetWindowLong(hWnd, IMMGWL_IMC);	
	//
	// Even if there is no current UI. these messages should not be pass to 
	// DefWindowProc().
	//
	if (!hUICurIMC)
	{
		switch (message)
		{
		case WM_IME_STARTCOMPOSITION:
		case WM_IME_ENDCOMPOSITION:
		case WM_IME_COMPOSITION:
		case WM_IME_NOTIFY:
		case WM_IME_CONTROL:
		case WM_IME_COMPOSITIONFULL:
		case WM_IME_SELECT:
		case WM_IME_CHAR:
			return 0L;
		default:
			break;
		}
	}

	switch (message)
	{
	case WM_CREATE:
		TRACE(TEXT("UIWnd:WM_CREATE\n"));				
		hUIExtra = GlobalAlloc(GHND, sizeof(UIEXTRA));
		lpUIExtra = (LPUIEXTRA)GlobalLock(hUIExtra);
		lpUIExtra->uiComp.pt.x = -1;
		lpUIExtra->uiComp.pt.y = -1;
		CreateCompWindow(hWnd, lpUIExtra);
		CreateCandWindow(hWnd, lpUIExtra);

		GlobalUnlock(hUIExtra);
		SetWindowLong(hWnd, IMMGWL_PRIVATE, (DWORD)hUIExtra);
		break;

	case WM_IME_SETCONTEXT:
		TRACE(TEXT("UIWnd:WM_IME_SETCONTEXT\n"));
		if (wParam)
		{
			hUIExtra = (HGLOBAL)GetWindowLong(hWnd, IMMGWL_PRIVATE);
			lpUIExtra = (LPUIEXTRA)GlobalLock(hUIExtra);
			if (hUICurIMC)
			{				
				lpIMC = ImmLockIMC(hUICurIMC);
				if (lpIMC)
				{
					MoveCandWindow(hWnd, lpUIExtra, lpIMC);
					MoveCompWindow(hWnd, lpUIExtra, lpIMC);
				}
				else
				{
					HideCandWindow(lpUIExtra);
					HideCompWindow(lpUIExtra);
				}
				ImmUnlockIMC(hUICurIMC);
			}
			else   
			{
				HideCandWindow(lpUIExtra);
				HideCompWindow(lpUIExtra);
			}
			GlobalUnlock(hUIExtra);
		}
		break;

	case WM_IME_STARTCOMPOSITION:
		TRACE(TEXT("UIWnd:WM_IME_STARTCOMPOSITION\n"));
		
		break;

	case WM_IME_COMPOSITION:
		TRACE(TEXT("...UIWnd:WM_IME_COMPOSITION\n"));
		lpIMC = ImmLockIMC(hUICurIMC);
		hUIExtra = (HGLOBAL)GetWindowLong(hWnd, IMMGWL_PRIVATE);
		lpUIExtra = (LPUIEXTRA)GlobalLock(hUIExtra);
		MoveCompWindow(hWnd, lpUIExtra, lpIMC);
		MoveCandWindow(hWnd, lpUIExtra, lpIMC);
		GlobalUnlock(hUIExtra);
		lpUIExtra = NULL;
		ImmUnlockIMC(hUICurIMC);
		break;

	case WM_IME_ENDCOMPOSITION:
		TRACE(TEXT("UIWnd:WM_IME_ENDCOMPOSITION\n"));
		hUIExtra = (HGLOBAL)GetWindowLong(hWnd, IMMGWL_PRIVATE);
		lpUIExtra = (LPUIEXTRA)GlobalLock(hUIExtra);
		HideCompWindow(lpUIExtra);
		HideCandWindow(lpUIExtra);
		GlobalUnlock(hUIExtra);
		break;

	case WM_IME_COMPOSITIONFULL:
		TRACE(TEXT("UIWnd:WM_IME_COMPOSITIONFULL\n"));
		break;

	case WM_IME_SELECT:
		TRACE(TEXT("UIWnd:WM_IME_SELECT\n"));
		break;

	case WM_IME_CONTROL:
		TRACE(TEXT("UIWnd:WM_IME_CONTROL\n"));
		lRet = ControlHandle(hUICurIMC, hWnd,message,wParam,lParam);
		break;


	case WM_IME_NOTIFY:
		TRACE(TEXT("UIWnd:WM_IME_NOTIFY\n"));
		lRet = NotifyHandle(hUICurIMC, hWnd, message, wParam, lParam);
		break;

	case WM_DESTROY:
		TRACE(TEXT("UIWnd:WM_DESTROY\n"));

		hUIExtra = (HGLOBAL)GetWindowLong(hWnd, IMMGWL_PRIVATE);
		lpUIExtra = (LPUIEXTRA)GlobalLock(hUIExtra);

		if (IsWindow(lpUIExtra->uiStatus.hWnd))
		{
			DestroyWindow(lpUIExtra->uiStatus.hWnd);
		}

		if (IsWindow(lpUIExtra->uiCand.hWnd))
		{
			DestroyWindow(lpUIExtra->uiCand.hWnd);
		}

		if (IsWindow(lpUIExtra->uiComp.hWnd))
		{
			DestroyWindow(lpUIExtra->uiComp.hWnd);
		}

		GlobalUnlock(hUIExtra);
		GlobalFree(hUIExtra);
		break;

	case WM_UI_COMPMOVE:
		hUIExtra = (HGLOBAL)GetWindowLong(hWnd,IMMGWL_PRIVATE);
		lpUIExtra = (LPUIEXTRA)GlobalLock(hUIExtra);
		lpUIExtra->uiComp.pt.x = (long)LOWORD(lParam);
		lpUIExtra->uiComp.pt.y = (long)HIWORD(lParam);
		GlobalUnlock(hUIExtra);
		break;

	default:
		return DefWindowProc(hWnd,message,wParam,lParam);
	}
	return lRet;
}