📄 freepy.c
字号:
/*
* Copyright (C) 1999.4 Li ZhenChun
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License; or
* (at your option) any later version.
*
* This program is distributed in the hope that is will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, M A 02139, USA.
*
* Author: Li ZhenChun email: zhchli@163.net or zhchli@126.com
*
*
*/
#include "stdafx.h"
#include "freepy.h"
#define CS_FREEPY (CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS)
/**********************************************************************/
/* DLLEntry */
/**********************************************************************/
BOOL WINAPI DLLMain(
HANDLE hInstDLL, //HINSTANCE
DWORD dwFunction,
LPVOID lpNot)
{
switch(dwFunction)
{
case DLL_PROCESS_ATTACH:
/* for debug ********************************/
#ifdef _MY_DEBUG
if(nDebugLevel){
if( (DebugLogFile=_tfopen( DEBUGLOGFILE, _T("w")))==NULL)
MessageBox(NULL,_T("can not open Debuglogfile"),_T("debug"),MB_OK);
DebugLog(1,(DebugLogFile,_T("Entry in\r\n")));
}
#endif
RETAILMSG(DEBUGMODE,(TEXT("Entry in\r\n")));
/********************************************/
InitDictionary();
hInst = hInstDLL;
IMERegisterClass( hInst );
break;
case DLL_PROCESS_DETACH:
UnregisterClass(UICLASSNAME,hInst);
UnregisterClass(COMPCLASSNAME,hInst);
UnregisterClass(CANDCLASSNAME,hInst);
UnregisterClass(STATUSCLASSNAME,hInst);
DestroyDictionary();
/* for debug ********************************/
#ifdef _MY_DEBUG
if(nDebugLevel){
DebugLog(1,(DebugLogFile,_T("Entry out\r\n")));
if(DebugLogFile!=NULL)
fclose(DebugLogFile);
}
#endif
/********************************************/
RETAILMSG(DEBUGMODE,(TEXT("Entry out\r\n")));
break;
case DLL_THREAD_ATTACH:
RETAILMSG(DEBUGMODE,(TEXT("IME:Thread attach\r\n")));
break;
case DLL_THREAD_DETACH:
RETAILMSG(DEBUGMODE,(TEXT("IME:Thread detach\r\n")));
break;
}
return TRUE;
}
BOOL IMERegisterClass( HANDLE hInstance )
{
WNDCLASS wc;
//
// register class of UI window.
//
//wc.cbSize = sizeof(WNDCLASS);
wc.style = CS_FREEPY | CS_IME;
wc.lpfnWndProc = UIWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 2 * sizeof(LONG);
wc.hInstance = hInstance;
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
wc.hIcon = NULL;
wc.lpszMenuName = (LPTSTR)NULL;
wc.lpszClassName = UICLASSNAME;
wc.hbrBackground = NULL;
//wc.hIconSm = NULL;
if( !RegisterClass( (LPWNDCLASS)&wc ) )
return FALSE;
//
// register class of composition window.
//
//wc.cbSize = sizeof(WNDCLASS);
wc.style = CS_FREEPY | CS_IME;
wc.lpfnWndProc = CompWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = UICHILDEXTRASIZE;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
wc.hIcon = NULL;
wc.lpszMenuName = (LPTSTR)NULL;
wc.lpszClassName = COMPCLASSNAME;
wc.hbrBackground = NULL;
//wc.hIconSm = NULL;
if( !RegisterClass( (LPWNDCLASS)&wc ) )
return FALSE;
//
// register class of candadate window.
//
//wc.cbSize = sizeof(WNDCLASS);
wc.style = CS_FREEPY | CS_IME;
wc.lpfnWndProc = CandWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = UICHILDEXTRASIZE;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
wc.hIcon = NULL;
wc.lpszMenuName = (LPTSTR)NULL;
wc.lpszClassName = CANDCLASSNAME;
wc.hbrBackground = NULL;
//wc.hIconSm = NULL;
if( !RegisterClass( (LPWNDCLASS)&wc ) )
return FALSE;
//
// register class of status window.
//
//wc.cbSize = sizeof(WNDCLASS);
wc.style = CS_FREEPY | CS_IME;
wc.lpfnWndProc = StatusWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = UICHILDEXTRASIZE;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
wc.hIcon = NULL;
wc.lpszMenuName = (LPTSTR)NULL;
wc.lpszClassName = STATUSCLASSNAME;
wc.hbrBackground = NULL;
//wc.hIconSm = NULL;
if( !RegisterClass( (LPWNDCLASS)&wc ) )
return FALSE;
return TRUE;
}
/**********************************************************************/
/* */
/* UIWndProc() */
/* */
/* IME UI window procedure */
/* */
/**********************************************************************/
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,_T("UIWnd\r\n")));
RETAILMSG(DEBUGMODE,(TEXT("UIWND\r\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,_T("UIWnd:WM_CREATE\r\n")));
RETAILMSG(DEBUGMODE,(TEXT("UIWnd:WM_CREATE\r\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,_T("UIWnd:WM_IME_SETCONTEXT\r\n")));
RETAILMSG(DEBUGMODE,(TEXT("UIWnd:WM_IME_SETCONTEXT\r\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);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -