Statusui.pas
资源名称:Wingb_Mz.rar [点击查看]
上传用户:wen198501
上传日期:2013-04-01
资源大小:335k
文件大小:20k
源码类别:
输入法编程
开发平台:
Delphi
- {******************************************************}
- { }
- { Copyright (c) 1990-1999 Microsoft Corporation }
- { }
- { Module Name: Statusui.c ->> Statusui.pas }
- { }
- { Translator: Liu_mazi@126.com, 2005-11-16 }
- { }
- {******************************************************}
- unit Statusui;
- {$I Define.Inc}
- interface
- uses Windows;
- function GetStatusWnd(hUIWnd: hWnd): hWnd; // 返回Status窗口句柄
- function StatusWndProc(hStatusWnd: hWnd; uMsg: uInt; wParam: WParam; lParam: LParam): LResult; stdcall; // Status窗口回调
- function ImeVerDlgProc(hDlg: hWnd; uMessage: uInt; wParam: WParam; lParam: LParam): Bool; stdcall; // 版本对话框回调
- procedure OpenStatus(hUIWnd: hWnd); // "打开"Status窗口
- procedure ShowStatus(hUIWnd: hWnd; nShowStatusCmd: Integer); // 显示隐藏Status窗口
- implementation
- uses Messages, ImmDev, ImeDefs, Data, DDIS, Uisubs, Ui, LogText;
- // 返回Status窗口句柄
- function GetStatusWnd(hUIWnd: hWnd): hWnd;
- var
- hUIPrivate: hGlobal;
- lpUIPrivate: PUIPriv;
- begin
- Result := 0;
- hUIPrivate := GetWindowLong(hUIWnd, IMMGWLP_PRIVATE);
- if (hUIPrivate = 0) then Exit; // can not darw status window
- lpUIPrivate := GlobalLock(hUIPrivate);
- if (lpUIPrivate = nil) then Exit; // can not draw status window
- Result := lpUIPrivate.hStatusWnd;
- GlobalUnlock(hUIPrivate);
- end;
- // 调整Status窗口位置
- procedure AdjustStatusBoundary(lppt: PSmallPoint; hUIWnd: hWnd);
- var
- Comp_CandWndLen: Integer;
- begin
- // boundary check ..
- if (lppt.x < sImeG.rcWorkArea.Left) then
- lppt.x := sImeG.rcWorkArea.Left
- else
- if (lppt.x + sImeG.xStatusWi > sImeG.rcWorkArea.Right) then
- lppt.x := sImeG.rcWorkArea.Right - sImeG.xStatusWi;
- if (lppt.y < sImeG.rcWorkArea.Top) then
- lppt.y := sImeG.rcWorkArea.Top
- else
- if (lppt.y + sImeG.yStatusHi > sImeG.rcWorkArea.Bottom) then
- lppt.y := sImeG.rcWorkArea.Bottom - sImeG.yStatusHi;
- // 固定模式
- if (sImeG.IC_Trace = 0) then
- begin
- Comp_CandWndLen := 0;
- if (uStartComp <> 0) then Inc(Comp_CandWndLen, sImeL.xCompWi + UI_MARGIN);
- if (uOpenCand <> 0) then Inc(Comp_CandWndLen, sImeG.xCandWi + UI_MARGIN);
- if (lppt.x + sImeG.xStatusWi + Comp_CandWndLen > sImeG.rcWorkArea.Right) then
- lppt.x := sImeG.rcWorkArea.Right - sImeG.xStatusWi - Comp_CandWndLen;
- end;
- end;
- // 设置Status窗口位置
- function SetStatusWindowPos(hStatusWnd: hWnd): LResult;
- var
- hUIWnd: hWnd;
- _hIMC: hIMC;
- lpIMC: PInputContext;
- ptPos: TSmallPoint;
- begin
- Result := 1;
- hUIWnd := GetWindow(hStatusWnd, GW_OWNER);
- _hIMC := GetWindowLong(hUIWnd, IMMGWLP_IMC);
- if (_hIMC = 0) then Exit;
- lpIMC := ImmLockIMC(_hIMC);
- if (lpIMC = nil) then Exit;
- ptPos.x := lpIMC.ptStatusWndPos.x;
- ptPos.y := lpIMC.ptStatusWndPos.y;
- AdjustStatusBoundary(@ptPos, hUIWnd);
- SetWindowPos(hStatusWnd, 0, ptPos.x, ptPos.y, 0, 0, SWP_NOACTIVATE or SWP_NOCOPYBITS or SWP_NOSIZE or SWP_NOZORDER);
- ImmUnlockIMC(_hIMC);
- Result := 0;
- end;
- // 显示隐藏Status窗口
- procedure ShowStatus(hUIWnd: hWnd; nShowStatusCmd: Integer);
- var
- hUIPrivate: hGlobal;
- lpUIPrivate: PUIPriv;
- begin
- hUIPrivate := GetWindowLong(hUIWnd, IMMGWLP_PRIVATE);
- if (hUIPrivate = 0) then Exit; // can not darw status window
- lpUIPrivate := GlobalLock(hUIPrivate);
- if (lpUIPrivate = nil) then Exit; // can not draw status window
- if IsWindow(lpUIPrivate.hStatusWnd) and (lpUIPrivate.nShowStatusCmd <> nShowStatusCmd) then
- begin
- SystemParametersInfo(SPI_GETWORKAREA, 0, @sImeG.rcWorkArea, 0);
- SetStatusWindowPos(lpUIPrivate.hStatusWnd);
- ShowWindow(lpUIPrivate.hStatusWnd, nShowStatusCmd);
- lpUIPrivate.nShowStatusCmd := nShowStatusCmd;
- end;
- GlobalUnlock(hUIPrivate);
- end;
- // "打开"Status窗口
- procedure OpenStatus(hUIWnd: hWnd);
- var
- hUIPrivate: hGlobal;
- lpUIPrivate: PUIPriv;
- _hIMC: hIMC;
- lpIMC: PInputContext;
- ptPos: TPoint;
- // nShowStatusCmd: Integer;
- begin
- hUIPrivate := GetWindowLong(hUIWnd, IMMGWLP_PRIVATE);
- if (hUIPrivate = 0) then Exit; // can not darw status window
- lpUIPrivate := GlobalLock(hUIPrivate);
- if (lpUIPrivate = nil) then Exit; // can not draw status window
- _hIMC := GetWindowLong(hUIWnd, IMMGWLP_IMC);
- if (_hIMC = 0) then
- begin
- ptPos.x := sImeG.rcWorkArea.Left;
- ptPos.y := sImeG.rcWorkArea.Bottom - sImeG.yStatusHi;
- // nShowStatusCmd := SW_HIDE;
- end else
- begin
- lpIMC := ImmLockIMC(_hIMC);
- if (lpIMC <> nil) then
- begin
- if (lpIMC.ptStatusWndPos.x < sImeG.rcWorkArea.Left) then
- lpIMC.ptStatusWndPos.x := sImeG.rcWorkArea.Left
- else
- if (lpIMC.ptStatusWndPos.x + sImeG.xStatusWi > sImeG.rcWorkArea.Right) then
- lpIMC.ptStatusWndPos.x := sImeG.rcWorkArea.Right - sImeG.xStatusWi;
- if (lpIMC.ptStatusWndPos.y < sImeG.rcWorkArea.Top) then
- lpIMC.ptStatusWndPos.y := sImeG.rcWorkArea.Top
- else
- if (lpIMC.ptStatusWndPos.y + sImeG.yStatusHi > sImeG.rcWorkArea.Right) then
- lpIMC.ptStatusWndPos.y := sImeG.rcWorkArea.Bottom - sImeG.yStatusHi;
- if (sImeG.IC_Trace <> 0) then
- begin
- ptPos.x := lpIMC.ptStatusWndPos.x;
- ptPos.y := lpIMC.ptStatusWndPos.y;
- end else
- begin
- ptPos.x := sImeG.rcWorkArea.Left;
- ptPos.y := sImeG.rcWorkArea.Bottom - sImeG.yStatusHi;
- end;
- ImmUnlockIMC(_hIMC);
- // nShowStatusCmd := SW_SHOWNOACTIVATE;
- end else
- begin
- ptPos.x := sImeG.rcWorkArea.Left;
- ptPos.y := sImeG.rcWorkArea.Bottom - sImeG.yStatusHi;
- // nShowStatusCmd := SW_HIDE;
- end;
- end;
- if IsWindow(lpUIPrivate.hStatusWnd) then
- begin
- SetWindowPos(lpUIPrivate.hStatusWnd, 0, ptPos.x, ptPos.y, 0, 0, SWP_NOACTIVATE or SWP_NOSIZE or SWP_NOZORDER);
- end else
- begin
- lpUIPrivate.hStatusWnd := CreateWindowEx(WS_EX_WINDOWEDGE or WS_EX_DLGMODALFRAME, szStatusClassName, nil,
- WS_POPUP or WS_DISABLED, ptPos.x, ptPos.y, sImeG.xStatusWi, sImeG.yStatusHi, hUIWnd, 0, HInstance, nil);
- SetWindowLong(lpUIPrivate.hStatusWnd, UI_MOVE_OFFSET, WINDOW_NOT_DRAG);
- SetWindowLong(lpUIPrivate.hStatusWnd, UI_MOVE_XY, 0);
- end;
- lpUIPrivate.fdwSetContext := lpUIPrivate.fdwSetContext or ISC_OPEN_STATUS_WINDOW;
- if (_hIMC <> 0) then ShowStatus(hUIWnd, SW_SHOWNOACTIVATE);
- GlobalUnlock(hUIPrivate);
- end;
- // WM_DESTROY消息处理
- procedure DestroyStatusWindow(hStatusWnd: hWnd);
- var
- hUIWnd: hWnd;
- hUIPrivate: hGlobal;
- lpUIPrivate: PUIPriv;
- begin
- if (GetWindowLong(hStatusWnd, UI_MOVE_OFFSET) <> WINDOW_NOT_DRAG) then // undo the drag border
- begin
- DrawDragBorder(hStatusWnd, GetWindowLong(hStatusWnd, UI_MOVE_XY), GetWindowLong(hStatusWnd, UI_MOVE_OFFSET));
- end;
- hUIWnd := GetWindow(hStatusWnd, GW_OWNER);
- if (IsWindow(hUIWnd) = False) then Exit;
- hUIPrivate := GetWindowLong(hUIWnd, IMMGWLP_PRIVATE);
- if (hUIPrivate = 0) then Exit; // can not darw status window
- lpUIPrivate := GlobalLock(hUIPrivate);
- if (lpUIPrivate = nil) then Exit; // can not draw status window
- lpUIPrivate.nShowStatusCmd := SW_HIDE;
- lpUIPrivate.hStatusWnd := 0;
- GlobalUnlock(hUIPrivate);
- end;
- // WM_LBUTTONDOWN处理
- procedure SetStatus(hStatusWnd: hWnd; lpptCursor: PPoint);
- var
- hUIWnd: hWnd;
- _hIMC: hIMC;
- lpIMC: PInputContext;
- lpbKeyState: TKeyboardState;
- dwConvMode, fdwConversion: DWord;
- lpImcP: PPrivContext;
- begin
- hUIWnd := GetWindow(hStatusWnd, GW_OWNER);
- if (IsWindow(hUIWnd) = False) then Exit;
- _hIMC := GetWindowLong(hUIWnd, IMMGWLP_IMC);
- if (_hIMC = 0) then Exit;
- lpIMC := ImmLockIMC(_hIMC);
- if (lpIMC = nil) then Exit;
- if (lpIMC.fOpen = False) then
- begin
- ImmSetOpenStatus(_hIMC, True);
- end else
- if PtInRect(sImeG.rcImeIcon, lpptCursor^) then // Ime图标..
- begin
- if (lpIMC.fdwConversion and (IME_CMODE_CHARCODE or IME_CMODE_EUDC) <> 0) then
- begin // change to native mode
- fdwConversion := (lpIMC.fdwConversion or IME_CMODE_NATIVE) and not(IME_CMODE_CHARCODE or IME_CMODE_EUDC);
- end else
- if ((lpIMC.fdwConversion and IME_CMODE_NATIVE) <> 0) then
- begin // change to alphanumeric mode
- fdwConversion := lpIMC.fdwConversion and not(IME_CMODE_CHARCODE or IME_CMODE_NATIVE or IME_CMODE_EUDC);
- end else
- begin
- GetKeyboardState(lpbKeyState);
- if ((lpbKeyState[VK_CAPITAL] and 1) <> 0) then
- begin
- keybd_event(VK_CAPITAL, $3A, KEYEVENTF_EXTENDEDKEY or 0, 0); // Simulate a key press
- keybd_event(VK_CAPITAL, $3A, KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP, 0); // Simulate a key release
- end;
- fdwConversion := (lpIMC.fdwConversion or IME_CMODE_NATIVE) and not(IME_CMODE_CHARCODE or IME_CMODE_EUDC);
- uCaps := 0;
- end;
- ImmSetConversionStatus(_hIMC, fdwConversion, lpIMC.fdwSentence);
- end else
- if PtInRect(sImeG.rcImeName, lpptCursor^) then // 切换方式..
- begin
- end else
- if PtInRect(sImeG.rcShapeText, lpptCursor^) then // 全角半角..
- begin
- if ((lpIMC.fdwConversion and IME_CMODE_CHARCODE) <> 0) or
- ((lpIMC.fdwConversion and IME_CMODE_EUDC) <> 0) then
- begin
- MessageBeep($FFFFFFFF);
- end else
- begin
- dwConvMode := lpIMC.fdwConversion xor IME_CMODE_FULLSHAPE;
- ImmSetConversionStatus(_hIMC, dwConvMode, lpIMC.fdwSentence);
- end;
- end else
- if PtInRect(sImeG.rcSymbol, lpptCursor^) then // 标点符号..
- begin
- if (lpIMC.fdwConversion and IME_CMODE_CHARCODE) <> 0 then MessageBeep($FFFFFFFF)
- else begin
- fdwConversion := lpIMC.fdwConversion xor IME_CMODE_SYMBOL;
- ImmSetConversionStatus(_hIMC, fdwConversion, lpIMC.fdwSentence);
- end;
- end else
- if PtInRect(sImeG.rcSKText, lpptCursor^) then // 软键盘..
- begin
- lpImcP := ImmLockIMCC(lpIMC.hPrivate);
- if (lpImcP <> nil) then
- begin
- if (sImeL.hSKMenu = 0) then sImeL.hSKMenu := LoadMenu(HInstance, 'SKMENU');
- sImeL.dwSKState[sImeL.dwSKWant] := sImeL.dwSKState[sImeL.dwSKWant] xor 1;
- fdwConversion := lpIMC.fdwConversion xor IME_CMODE_SOFTKBD;
- ImmSetConversionStatus(_hIMC, fdwConversion, lpIMC.fdwSentence);
- ImmUnlockIMCC(lpIMC.hPrivate);
- end else
- MessageBeep($FFFFFFFF);
- end else
- MessageBeep($FFFFFFFF);
- ImmUnlockIMC(_hIMC);
- end;
- // WM_SETCURSOR处理
- procedure StatusSetCursor(hStatusWnd: hWnd; lParam: LParam);
- const {$J+}
- fSoftkey: Bool = False;
- fCmenu: Bool = False; {$J-}
- var
- ptCursor, ptSavCursor: TPoint;
- rcWnd: TRect;
- begin
- if (GetWindowLong(hStatusWnd, UI_MOVE_OFFSET) <> WINDOW_NOT_DRAG) then // 拖拽中..
- begin
- SetCursor(LoadCursor(0, IDC_SIZEALL));
- Exit;
- end;
- GetCursorPos(ptCursor);
- ptSavCursor := ptCursor;
- ScreenToClient(hStatusWnd, ptCursor);
- if PtInRect(sImeG.rcStatusText, ptCursor) then
- begin
- SetCursor(LoadCursor(HInstance, szHandCursor));
- if (HiWord(lParam) = WM_LBUTTONDOWN) then // 左键按下
- begin
- SetStatus(hStatusWnd, @ptCursor);
- end else
- if (HiWord(lParam) = WM_RBUTTONUP) then // 右键按下
- begin
- if PtInRect(sImeG.rcSKText, ptCursor) then // 软键盘
- begin
- // configuration already bring up
- if (fSoftkey) then Exit;
- fSoftkey := True;
- SoftkeyMenu(hStatusWnd, ptSavCursor.x, ptSavCursor.y);
- fSoftkey := False;
- end else
- begin
- // configuration already bring up
- if (fCmenu) then Exit;
- fCmenu := True;
- ContextMenu(hStatusWnd, ptSavCursor.x, ptSavCursor.y);
- fCmenu := False;
- end;
- end;
- end else
- begin
- SetCursor(LoadCursor(0, IDC_SIZEALL));
- if (HiWord(lParam) = WM_LBUTTONDOWN) then // start drag
- begin
- 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));
- end;
- end;
- end;
- // 绘制Status窗口
- procedure PaintStatusWindow(_hDC: hDC; hStatusWnd: hWnd);
- var
- hUIWnd: hWnd;
- _hIMC: hIMC;
- lpIMC: PInputContext;
- lpImcP: PPrivContext;
- hOldFont: hGdiObj;
- hImeIconBmp, hShapeBmp, hSymbolBmp, hSKBmp, hOldBmp: hBitMap;
- hMemDC: hDC;
- lfFont: TLogFont;
- begin
- hUIWnd := GetWindow(hStatusWnd, GW_OWNER);
- if (IsWindow(hUIWnd) = False) then Exit;
- _hIMC := GetWindowLong(hUIWnd, IMMGWLP_IMC);
- if (_hIMC = 0) then
- begin
- MessageBeep($FFFFFFFF);
- Exit;
- end;
- lpIMC := ImmLockIMC(_hIMC);
- if (lpIMC = nil) then
- begin
- MessageBeep($FFFFFFFF);
- Exit;
- end;
- // get lpImcP
- lpImcP := ImmLockIMCC(lpIMC.hPrivate);
- if (lpImcP = nil) then
- begin
- MessageBeep($FFFFFFFF);
- Exit;
- end;
- // set font
- if (sImeG.fDiffSysCharSet) then
- begin
- hOldFont := GetCurrentObject(_hDC, OBJ_FONT);
- ZeroMemory(@lfFont, SizeOf(lfFont));
- lfFont.lfHeight := - MulDiv(12, GetDeviceCaps(_hDC, LOGPIXELSY), 72);
- lfFont.lfCharSet := NATIVE_CHARSET;
- lStrCpy(lfFont.lfFaceName, '宋体');
- SelectObject(_hDC, CreateFontIndirect(lfFont));
- end else
- hOldFont := 0;
- // draw Ime Name ..
- if (lpIMC.fOpen) then SetTextColor(_hDC, RGB($00, $00, $00)) else SetTextColor(_hDC, RGB($80, $80, $80));
- SetBkColor(_hDC, RGB($C0, $C0, $C0));
- DrawText(_hDC, szImeName, lStrLen(szImeName), sImeG.rcImeName, DT_CENTER or DT_VCENTER or 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 & draw ..
- hSymbolBmp := 0;
- hShapeBmp := 0;
- hSKBmp := 0;
- if (lpIMC.fOpen = False) then
- begin
- hSymbolBmp := LoadBitmap(HInstance, szNone);
- hShapeBmp := LoadBitmap(HInstance, szNone);
- hSKBmp := LoadBitmap(HInstance, szNone);
- hImeIconBmp := LoadBitmap(HInstance, szChinese);
- end else
- if (lpIMC.fdwConversion and IME_CMODE_NATIVE) <> 0 then
- hImeIconBmp := LoadBitmap(HInstance, szChinese)
- else
- hImeIconBmp := LoadBitmap(HInstance, szEnglish);
- if (hShapeBmp = 0) then
- begin
- if (lpIMC.fdwConversion and IME_CMODE_FULLSHAPE) <> 0 then
- hShapeBmp := LoadBitmap(HInstance, szFullShape)
- else
- hShapeBmp := LoadBitmap(HInstance, szHalfShape);
- end;
- if (hSymbolBmp = 0) then
- begin
- if (lpIMC.fdwConversion and IME_CMODE_SYMBOL) <> 0 then
- hSymbolBmp := LoadBitmap(HInstance, szSymbol)
- else
- hSymbolBmp := LoadBitmap(HInstance, szNoSymbol);
- end;
- if (hSKBmp = 0) then
- begin
- if (lpIMC.fdwConversion and IME_CMODE_SOFTKBD) <> 0 then
- hSKBmp := LoadBitmap(HInstance, szSoftKBD)
- else
- hSKBmp := LoadBitmap(HInstance, szNoSoftKBD);
- end;
- 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) then DeleteObject(SelectObject(_hDC, hOldFont));
- end;
- // Status窗口回调
- function StatusWndProc(hStatusWnd: hWnd; uMsg: uInt; wParam: WParam; lParam: LParam): LResult; stdcall;
- var
- ptCursor: TPoint;
- lTmpCursor, lTmpOffset: DWord;
- _hDC: hDC;
- ps: TPaintStruct;
- begin
- Result := 0;
- case (uMsg) of
- WM_DESTROY:
- DestroyStatusWindow(hStatusWnd);
- WM_SETCURSOR:
- StatusSetCursor(hStatusWnd, lParam);
- WM_MOUSEMOVE:
- if (GetWindowLong(hStatusWnd, UI_MOVE_OFFSET) <> WINDOW_NOT_DRAG) then // 拖拽中..
- begin
- 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));
- end else
- Result := DefWindowProc(hStatusWnd, uMsg, wParam, lParam);
- WM_LBUTTONUP:
- if (GetWindowLong(hStatusWnd, UI_MOVE_OFFSET) <> WINDOW_NOT_DRAG) then // 拖拽中..
- begin
- lTmpCursor := GetWindowLong(hStatusWnd, UI_MOVE_XY);
- lTmpOffset := GetWindowLong(hStatusWnd, UI_MOVE_OFFSET);
- DrawDragBorder(hStatusWnd, lTmpCursor, lTmpOffset);
- // calculate the org by the offset
- Dec(PSmallPoint(@lTmpCursor).x, PSmallPoint(@lTmpOffset).x);
- Dec(PSmallPoint(@lTmpCursor).y, PSmallPoint(@lTmpOffset).y);
- SetWindowLong(hStatusWnd, UI_MOVE_OFFSET, WINDOW_NOT_DRAG);
- ReleaseCapture();
- AdjustStatusBoundary(PSmallPoint(@lTmpCursor), GetWindow(hStatusWnd, GW_OWNER));
- SendMessage(GetWindow(hStatusWnd, GW_OWNER), WM_IME_CONTROL, IMC_SETSTATUSWINDOWPOS, lTmpCursor);
- end else
- Result := DefWindowProc(hStatusWnd, uMsg, wParam, lParam);
- WM_IME_NOTIFY:
- begin
- SystemParametersInfo(SPI_GETWORKAREA, 0, @sImeG.rcWorkArea, 0); // get work area for changing
- if (wParam = IMN_SETSTATUSWINDOWPOS) then SetStatusWindowPos(hStatusWnd);
- end;
- WM_PAINT:
- begin
- _hDC := BeginPaint(hStatusWnd, ps);
- PaintStatusWindow(_hDC, hStatusWnd);
- EndPaint(hStatusWnd, ps);
- end;
- WM_MOUSEACTIVATE:
- Result := MA_NOACTIVATE;
- else
- Result := DefWindowProc(hStatusWnd, uMsg, wParam, lParam);
- end;
- end;
- // 版本对话框回调
- function ImeVerDlgProc(hDlg: hWnd; uMessage: uInt; wParam: WParam; lParam: LParam): Bool; stdcall;
- var
- Rc: TRect;
- DlgWidth, DlgHeight: Integer;
- begin
- case (uMessage) of
- WM_INITDIALOG:
- begin
- hCrtDlg := hDlg;
- GetWindowRect(hDlg, Rc);
- DlgWidth := Rc.Right - Rc.Left;
- DlgHeight := Rc.Bottom - Rc.Top;
- // reset position ..
- SetWindowPos(hDlg, HWND_TOP, (sImeG.rcWorkArea.Right - DlgWidth) div 2,
- (sImeG.rcWorkArea.Bottom - DlgHeight) div 2, 0, 0, SWP_NOSIZE);
- Result := True;
- end;
- WM_COMMAND:
- begin
- case (wParam) of
- IDOK, IDCANCEL: EndDialog(hDlg, 0);
- end;
- Result := True;
- end;
- WM_CLOSE:
- begin
- EndDialog(hDlg, 0); // 没必要吧, ??
- Result := False;
- end;
- WM_PAINT: // 画了有用吗, ??
- begin
- 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);
- Result := False;
- end;
- else Result := False;
- end;
- end;
- end.