📄 uisubs.c
字号:
/*++
Copyright (c) 1990-1999 Microsoft Corporation, All Rights Reserved
Module Name:
uisubs.c
++*/
#include <windows.h>
#include <imm.h>
#include <htmlhelp.h>
#include <imedefs.h>
/**********************************************************************/
/* DrawDragBorder() */
/**********************************************************************/
void PASCAL DrawDragBorder(
HWND hWnd, // window of IME is dragged
LONG lCursorPos, // the cursor position
LONG lCursorOffset) // the offset form cursor to window org
{
HDC hDC;
int cxBorder, cyBorder;
int x, y;
RECT rcWnd;
cxBorder = GetSystemMetrics(SM_CXBORDER); // width of border
cyBorder = GetSystemMetrics(SM_CYBORDER); // height of border
// get cursor position
x = (*(LPPOINTS)&lCursorPos).x;
y = (*(LPPOINTS)&lCursorPos).y;
// calculate the org by the offset
x -= (*(LPPOINTS)&lCursorOffset).x;
y -= (*(LPPOINTS)&lCursorOffset).y;
#ifndef MUL_MONITOR
// check for the min boundary of the display
if (x < sImeG.rcWorkArea.left) {
x = sImeG.rcWorkArea.left;
}
if (y < sImeG.rcWorkArea.top) {
y = sImeG.rcWorkArea.top;
}
#endif
// check for the max boundary of the display
GetWindowRect(hWnd, &rcWnd);
#ifndef MUL_MONITOR
if (x + rcWnd.right - rcWnd.left > sImeG.rcWorkArea.right) {
x = sImeG.rcWorkArea.right - (rcWnd.right - rcWnd.left);
}
if (y + rcWnd.bottom - rcWnd.top > sImeG.rcWorkArea.bottom) {
y = sImeG.rcWorkArea.bottom - (rcWnd.bottom - rcWnd.top);
}
#endif
// draw the moving track
hDC = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
SelectObject(hDC, GetStockObject(GRAY_BRUSH));
// ->
PatBlt(hDC, x, y, rcWnd.right - rcWnd.left - cxBorder, cyBorder,
PATINVERT);
// v
PatBlt(hDC, x, y + cyBorder, cxBorder, rcWnd.bottom - rcWnd.top -
cyBorder, PATINVERT);
// _>
PatBlt(hDC, x + cxBorder, y + rcWnd.bottom - rcWnd.top,
rcWnd.right - rcWnd.left - cxBorder, -cyBorder, PATINVERT);
// v
PatBlt(hDC, x + rcWnd.right - rcWnd.left, y,
- cxBorder, rcWnd.bottom - rcWnd.top - cyBorder, PATINVERT);
DeleteDC(hDC);
return;
}
/**********************************************************************/
/* DrawFrameBorder() */
/**********************************************************************/
void PASCAL DrawFrameBorder( // border of IME
HDC hDC,
HWND hWnd) // window of IME
{
RECT rcWnd;
int xWi, yHi;
GetWindowRect(hWnd, &rcWnd);
xWi = rcWnd.right - rcWnd.left;
yHi = rcWnd.bottom - rcWnd.top;
// 1, ->
PatBlt(hDC, 0, 0, xWi, 1, WHITENESS);
// 1, v
PatBlt(hDC, 0, 0, 1, yHi, WHITENESS);
// 1, _>
PatBlt(hDC, 0, yHi, xWi, -1, BLACKNESS);
// 1, v
PatBlt(hDC, xWi, 0, -1, yHi, BLACKNESS);
xWi -= 2;
yHi -= 2;
SelectObject(hDC, GetStockObject(LTGRAY_BRUSH));
// 2, ->
PatBlt(hDC, 1, 1, xWi, 1, PATCOPY);
// 2, v
PatBlt(hDC, 1, 1, 1, yHi, PATCOPY);
// 2, v
PatBlt(hDC, xWi + 1, 1, -1, yHi, PATCOPY);
SelectObject(hDC, GetStockObject(GRAY_BRUSH));
// 2, _>
PatBlt(hDC, 1, yHi + 1, xWi, -1, PATCOPY);
xWi -= 2;
yHi -= 2;
// 3, ->
PatBlt(hDC, 2, 2, xWi, 1, PATCOPY);
// 3, v
PatBlt(hDC, 2, 2, 1, yHi, PATCOPY);
// 3, v
PatBlt(hDC, xWi + 2, 3, -1, yHi - 1, WHITENESS);
SelectObject(hDC, GetStockObject(LTGRAY_BRUSH));
// 3, _>
PatBlt(hDC, 2, yHi + 2, xWi, -1, PATCOPY);
SelectObject(hDC, GetStockObject(GRAY_BRUSH));
xWi -= 2;
yHi -= 2;
// 4, ->
PatBlt(hDC, 3, 3, xWi, 1, PATCOPY);
// 4, v
PatBlt(hDC, 3, 3, 1, yHi, PATCOPY);
SelectObject(hDC, GetStockObject(LTGRAY_BRUSH));
// 4, v
PatBlt(hDC, xWi + 3, 4, -1, yHi - 1, PATCOPY);
// 4, _>
PatBlt(hDC, 3, yHi + 3, xWi, -1, WHITENESS);
return;
}
/**********************************************************************/
/* ContextMenuWndProc() */
/**********************************************************************/
LRESULT CALLBACK ContextMenuWndProc(
HWND hCMenuWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
switch (uMsg) {
case WM_DESTROY:
{
HWND hUIWnd;
hUIWnd = (HWND)GetWindowLongPtr(hCMenuWnd, CMENU_HUIWND);
if (hUIWnd) {
SendMessage(hUIWnd, WM_IME_NOTIFY, IMN_PRIVATE,
IMN_PRIVATE_CMENUDESTROYED);
}
}
break;
case WM_USER_DESTROY:
{
SendMessage(hCMenuWnd, WM_CLOSE, 0, 0);
DestroyWindow(hCMenuWnd);
}
break;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDM_PROP:
{
HIMC hIMC;
LPINPUTCONTEXT lpIMC;
LPPRIVCONTEXT lpImcP;
int UI_MODE;
HWND hUIWnd;
RECT rcWorkArea;
hUIWnd = (HWND)GetWindowLongPtr(hCMenuWnd, CMENU_HUIWND);
if (!hUIWnd) {
return (0L);
}
#ifdef MUL_MONITOR
rcWorkArea = ImeMonitorWorkAreaFromWindow(hCMenuWnd);
#else
rcWorkArea = sImeG.rcWorkArea;
#endif
hIMC = (HIMC)GetWindowLongPtr(hUIWnd, IMMGWLP_IMC);
if (!hIMC) {
return (0L);
}
lpIMC = (LPINPUTCONTEXT)ImmLockIMC(hIMC);
if (!lpIMC) {
return (0L);
}
lpImcP = (LPPRIVCONTEXT)ImmLockIMCC(lpIMC->hPrivate);
if (!lpImcP) {
return (0L);
}
ImeConfigure(GetKeyboardLayout(0), lpIMC->hWnd, IME_CONFIG_GENERAL, NULL);
#ifdef CROSSREF
{
HWND hCompWnd;
hCompWnd = GetCompWnd(hUIWnd);
DestroyWindow(hCompWnd);
}
#endif
lpImcP->iImeState = CST_INIT;
CompCancel(hIMC, lpIMC);
// change compwnd size
// init fields of hIMC
lpIMC->fOpen = TRUE;
if (!(lpIMC->fdwInit & INIT_CONVERSION)) {
lpIMC->fdwConversion = IME_CMODE_NATIVE;
lpIMC->fdwInit |= INIT_CONVERSION;
}
lpImcP->fdwImeMsg = lpImcP->fdwImeMsg | MSG_IMN_DESTROYCAND;
GenerateMessage(hIMC, lpIMC, lpImcP);
// set cand window data
if(sImeG.IC_Trace) {
UI_MODE = BOX_UI;
} else {
POINT ptSTFixPos;
UI_MODE = LIN_UI;
ptSTFixPos.x = 0;
ptSTFixPos.y = rcWorkArea.bottom - sImeG.yStatusHi;
ImmSetStatusWindowPos(hIMC, (LPPOINT)&ptSTFixPos);
}
InitCandUIData(
GetSystemMetrics(SM_CXBORDER),
GetSystemMetrics(SM_CYBORDER), UI_MODE);
ImmUnlockIMCC(lpIMC->hPrivate);
ImmUnlockIMC(hIMC);
break;
}
//case IDM_HLP:
case IDM_OPTGUD:
{
TCHAR szOPTGUDHlpName[MAXSTRLEN];
szOPTGUDHlpName[0] = 0;
GetWindowsDirectory((LPTSTR)szOPTGUDHlpName, MAXSTRLEN);
lstrcat((LPTSTR)szOPTGUDHlpName, TEXT("\\HELP\\WINIME.CHM"));
HtmlHelp(hCMenuWnd,szOPTGUDHlpName,HH_DISPLAY_TOPIC,0L);
}
break;
case IDM_IMEGUD:
{
TCHAR szIMEGUDHlpName[MAXSTRLEN];
szIMEGUDHlpName[0] = TEXT('\0');
GetWindowsDirectory((LPTSTR)szIMEGUDHlpName, MAXSTRLEN);
lstrcat((LPTSTR)szIMEGUDHlpName, TEXT("\\HELP\\") );
#if defined(COMBO_IME)
//COMBO_IME has only one IME help file
lstrcat((LPTSTR)szIMEGUDHlpName, TEXT("WINGB.CHM"));
#else //COMBO_IME
#ifdef GB
lstrcpy((LPTSTR)szIMEGUDHlpName, TEXT("WINGB.CHM"));
#else
lstrcpy((LPTSTR)szIMEGUDHlpName, TEXT("WINNM.HLP"));
#endif
#endif //COMBO_IME
HtmlHelp(hCMenuWnd,szIMEGUDHlpName,HH_DISPLAY_TOPIC,0L);
}
break;
case IDM_VER:
{
HIMC hIMC;
LPINPUTCONTEXT lpIMC;
HWND hUIWnd;
hUIWnd = (HWND)GetWindowLongPtr(hCMenuWnd, CMENU_HUIWND);
if (!hUIWnd) {
return (0L);
}
hIMC = (HIMC)GetWindowLongPtr(hUIWnd, IMMGWLP_IMC);
if (!hIMC) {
return (0L);
}
lpIMC = (LPINPUTCONTEXT)ImmLockIMC(hIMC);
if (!lpIMC) {
return (0L);
}
DialogBox(hInst, TEXT("IMEVER"), (HWND)lpIMC->hWnd, (DLGPROC)ImeVerDlgProc);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -