📄 statusui.c
字号:
} else {
fdwConversion = lpIMC->fdwConversion ^ IME_CMODE_SYMBOL;
ImmSetConversionStatus(hIMC, fdwConversion, lpIMC->fdwSentence);
}
} else if (PtInRect(&sImeG.rcSKText, *lpptCursor)) {
DWORD fdwConversion;
LPPRIVCONTEXT lpImcP;
lpImcP = (LPPRIVCONTEXT)ImmLockIMCC(lpIMC->hPrivate);
if(lpImcP) {
if(!(lpImeL->hSKMenu)) {
lpImeL->hSKMenu = LoadMenu (hInst, TEXT("SKMENU"));
}
lpImeL->dwSKState[lpImeL->dwSKWant] =
lpImeL->dwSKState[lpImeL->dwSKWant]^1;
fdwConversion = lpIMC->fdwConversion ^ IME_CMODE_SOFTKBD;
ImmSetConversionStatus(hIMC, fdwConversion, lpIMC->fdwSentence);
ImmUnlockIMCC(lpIMC->hPrivate);
} else {
MessageBeep((UINT)-1);
}
} else {
MessageBeep((UINT)-1);
}
ImmUnlockIMC(hIMC);
return;
}
/**********************************************************************/
/* StatusSetCursor() */
/**********************************************************************/
void PASCAL StatusSetCursor(
HWND hStatusWnd,
LPARAM lParam)
{
POINT ptCursor, ptSavCursor;
RECT rcWnd;
if (GetWindowLong(hStatusWnd, UI_MOVE_OFFSET) != WINDOW_NOT_DRAG) {
SetCursor(LoadCursor(NULL, IDC_SIZEALL));
return;
}
GetCursorPos(&ptCursor);
ptSavCursor = ptCursor;
ScreenToClient(hStatusWnd, &ptCursor);
if (PtInRect(&sImeG.rcStatusText, ptCursor)) {
SetCursor(LoadCursor(hInst, szHandCursor));
if (HIWORD(lParam) == WM_LBUTTONDOWN) {
SetStatus(hStatusWnd, &ptCursor);
} else if (HIWORD(lParam) == WM_RBUTTONUP) {
if (PtInRect(&sImeG.rcSKText, ptCursor)) {
static BOOL fSoftkey= FALSE;
// prevent recursive
if (fSoftkey) {
// configuration already bring up
return;
}
fSoftkey = TRUE;
SoftkeyMenu(hStatusWnd, ptSavCursor.x, ptSavCursor.y);
fSoftkey = FALSE;
}else{
static BOOL fCmenu=FALSE;
// prevent recursive
if (fCmenu) {
// configuration already bring up
return;
}
fCmenu = TRUE;
ContextMenu(hStatusWnd, ptSavCursor.x, ptSavCursor.y);
fCmenu = FALSE;
}
}
return;
} else {
SetCursor(LoadCursor(NULL, IDC_SIZEALL));
if (HIWORD(lParam) == WM_LBUTTONDOWN) {
// start drag
SystemParametersInfo(SPI_GETWORKAREA, 0, &sImeG.rcWorkArea, 0);
} else {
return;
}
}
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));
return;
}
/**********************************************************************/
/* PaintStatusWindow() */
/**********************************************************************/
void PASCAL PaintStatusWindow(
HDC hDC,
HWND hStatusWnd)
{
HWND hUIWnd;
HIMC hIMC;
LPINPUTCONTEXT lpIMC;
LPPRIVCONTEXT lpImcP;
HGDIOBJ hOldFont;
HBITMAP hImeIconBmp, hShapeBmp, hSymbolBmp, hSKBmp;
HBITMAP hOldBmp;
HDC hMemDC;
hUIWnd = GetWindow(hStatusWnd, GW_OWNER);
hIMC = (HIMC)GetWindowLongPtr(hUIWnd, IMMGWLP_IMC);
if (!hIMC) {
MessageBeep((UINT)-1);
return;
}
if (!(lpIMC = (LPINPUTCONTEXT)ImmLockIMC(hIMC))) {
MessageBeep((UINT)-1);
return;
}
// get lpImcP
if(!(lpImcP = (LPPRIVCONTEXT)ImmLockIMCC(lpIMC->hPrivate))) {
MessageBeep((UINT)-1);
return;
}
#if defined(COMBO_IME)
//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);
}
#endif //COMBO_IME
// set font
if (sImeG.fDiffSysCharSet) {
LOGFONT lfFont;
ZeroMemory(&lfFont, sizeof(lfFont));
hOldFont = GetCurrentObject(hDC, OBJ_FONT);
lfFont.lfHeight = -MulDiv(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
hSymbolBmp = (HBITMAP)NULL;
hShapeBmp = (HBITMAP)NULL;
hSKBmp = (HBITMAP)NULL;
if (!lpIMC->fOpen) {
hSymbolBmp = LoadBitmap(hInst, szNone);
hShapeBmp = LoadBitmap(hInst, szNone);
hSKBmp = LoadBitmap(hInst, szNone);
hImeIconBmp = LoadBitmap(hInst, szChinese);
} else if (lpIMC->fdwConversion & IME_CMODE_NATIVE) {
hImeIconBmp = LoadBitmap(hInst, szChinese);
} else {
hImeIconBmp = LoadBitmap(hInst, szEnglish);
}
if (!hShapeBmp) {
if (lpIMC->fdwConversion & IME_CMODE_FULLSHAPE) {
hShapeBmp = LoadBitmap(hInst, szFullShape);
} else {
hShapeBmp = LoadBitmap(hInst, szHalfShape);
}
}
if (!hSymbolBmp) {
if (lpIMC->fdwConversion & IME_CMODE_SYMBOL) {
hSymbolBmp = LoadBitmap(hInst, szSymbol);
} else {
hSymbolBmp = LoadBitmap(hInst, szNoSymbol);
}
}
if (!hSKBmp) {
if (lpIMC->fdwConversion & IME_CMODE_SOFTKBD) {
hSKBmp = LoadBitmap(hInst, szSoftKBD);
} else {
hSKBmp = LoadBitmap(hInst, szNoSoftKBD);
}
}
ImmUnlockIMC(hIMC);
ImmUnlockIMCC(lpIMC->hPrivate);
hMemDC = CreateCompatibleDC(hDC);
hOldBmp = 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, hShapeBmp);
BitBlt(hDC, sImeG.rcShapeText.left, sImeG.rcShapeText.top,
sImeG.rcShapeText.right - sImeG.rcShapeText.left,
STATUS_DIM_Y,
hMemDC, 0, 0, SRCCOPY);
SelectObject(hMemDC, hSymbolBmp);
BitBlt(hDC, sImeG.rcSymbol.left, sImeG.rcSymbol.top,
sImeG.rcSymbol.right - sImeG.rcSymbol.left,
STATUS_DIM_Y,
hMemDC, 0, 0, SRCCOPY);
SelectObject(hMemDC, hSKBmp);
BitBlt(hDC, sImeG.rcSKText.left, sImeG.rcSKText.top,
sImeG.xStatusWi - sImeG.rcSKText.left,
STATUS_DIM_Y,
hMemDC, 0, 0, SRCCOPY);
SelectObject(hMemDC, hOldBmp);
DeleteDC(hMemDC);
DeleteObject(hImeIconBmp);
DeleteObject(hSymbolBmp);
DeleteObject(hShapeBmp);
DeleteObject(hSKBmp);
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:
StatusSetCursor(hStatusWnd, lParam);
break;
case WM_MOUSEMOVE:
if (GetWindowLong(hStatusWnd, UI_MOVE_OFFSET) != WINDOW_NOT_DRAG) {
POINT ptCursor;
DrawDragBorder(hStatusWnd,
GetWindowLong(hStatusWnd, UI_MOVE_XY),
GetWindowLong(hStatusWnd, UI_MOVE_OFFSET));
GetCursorPos(&ptCursor);
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);
}
/**********************************************************************/
/* ImeVerDlgProc() */
/* Return Value: */
/* TRUE - successful, FALSE - failure */
/**********************************************************************/
BOOL FAR PASCAL ImeVerDlgProc( // dialog procedure of configuration
HWND hDlg,
UINT uMessage,
WORD wParam,
LONG lParam)
{
RECT rc;
LONG DlgWidth, DlgHeight;
switch (uMessage) {
case WM_INITDIALOG:
hCrtDlg = hDlg;
// reset position
GetWindowRect(hDlg, &rc);
DlgWidth = rc.right - rc.left;
DlgHeight = rc.bottom - rc.top;
SetWindowPos(hDlg, HWND_TOP,
(int)(sImeG.rcWorkArea.right - DlgWidth)/2,
(int)(sImeG.rcWorkArea.bottom - DlgHeight)/2,
(int)0, (int)0, SWP_NOSIZE);
return (TRUE); // don't want to set focus to special control
case WM_COMMAND:
switch (wParam) {
case IDOK:
EndDialog(hDlg, FALSE);
break;
case IDCANCEL:
EndDialog(hDlg, FALSE);
break;
default:
return (FALSE);
break;
}
return (TRUE);
case WM_CLOSE:
EndDialog(hDlg, FALSE);
return FALSE;
case WM_PAINT:
{
RECT rc;
GetClientRect(hDlg, &rc);
DrawConvexRect(GetDC(hDlg),
rc.left + 10,
rc.top + 10,
rc.right - 10 - 1,
rc.bottom - 43 - 1);
DrawConvexRectP(GetDC(hDlg),
rc.left + 10,
rc.top + 10,
rc.right - 10,
rc.bottom - 43);
}
return (FALSE);
default:
return (FALSE);
}
return (TRUE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -