// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A // PARTICULAR PURPOSE. // // Copyright (c) Microsoft Corporation. All rights reserved #pragma once #include "private.h" #include "define.h" #include "SampleIMEBaseStructure.h" void DllAddRef(); void DllRelease(); namespace Global { //--------------------------------------------------------------------- // inline //--------------------------------------------------------------------- inline void SafeRelease(_In_ IUnknown *punk) { if (punk != nullptr) { punk->Release(); } } inline void QuickVariantInit(_Inout_ VARIANT *pvar) { pvar->vt = VT_EMPTY; } inline void QuickVariantClear(_Inout_ VARIANT *pvar) { switch (pvar->vt) { // some ovbious VTs that don't need to call VariantClear. case VT_EMPTY: case VT_NULL: case VT_I2: case VT_I4: case VT_R4: case VT_R8: case VT_CY: case VT_DATE: case VT_I1: case VT_UI1: case VT_UI2: case VT_UI4: case VT_I8: case VT_UI8: case VT_INT: case VT_UINT: case VT_BOOL: break; // Call release for VT_UNKNOWN. case VT_UNKNOWN: SafeRelease(pvar->punkVal); break; default: // we call OleAut32 for other VTs. VariantClear(pvar); break; } pvar->vt = VT_EMPTY; } //+--------------------------------------------------------------------------- // // IsTooSimilar // // Return TRUE if the colors cr1 and cr2 are so similar that they // are hard to distinguish. Used for deciding to use reverse video // selection instead of system selection colors. // //---------------------------------------------------------------------------- inline BOOL IsTooSimilar(COLORREF cr1, COLORREF cr2) { if ((cr1 | cr2) & 0xFF000000) // One color and/or the other isn't RGB, so algorithm doesn't apply { return FALSE; } LONG DeltaR = abs(GetRValue(cr1) - GetRValue(cr2)); LONG DeltaG = abs(GetGValue(cr1) - GetGValue(cr2)); LONG DeltaB = abs(GetBValue(cr1) - GetBValue(cr2)); return DeltaR + DeltaG + DeltaB < 80; } //--------------------------------------------------------------------- // extern //--------------------------------------------------------------------- extern HINSTANCE dllInstanceHandle; extern ATOM AtomCandidateWindow; extern ATOM AtomShadowWindow; extern ATOM AtomScrollBarWindow; BOOL RegisterWindowClass(); extern LONG dllRefCount; extern CRITICAL_SECTION CS; extern HFONT defaultlFontHandle; // Global font object we use everywhere extern const CLSID SampleIMECLSID; extern const CLSID SampleIMEGuidProfile; extern const CLSID SampleIMEGuidImeModePreserveKey; extern const CLSID SampleIMEGuidDoubleSingleBytePreserveKey; extern const CLSID SampleIMEGuidPunctuationPreserveKey; LRESULT CALLBACK ThreadKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam); BOOL CheckModifiers(UINT uModCurrent, UINT uMod); BOOL UpdateModifiers(WPARAM wParam, LPARAM lParam); extern USHORT ModifiersValue; extern BOOL IsShiftKeyDownOnly; extern BOOL IsControlKeyDownOnly; extern BOOL IsAltKeyDownOnly; extern const GUID SampleIMEGuidCompartmentDoubleSingleByte; extern const GUID SampleIMEGuidCompartmentPunctuation; extern const WCHAR FullWidthCharTable[]; extern const struct _PUNCTUATION PunctuationTable[14]; extern const GUID SampleIMEGuidLangBarIMEMode; extern const GUID SampleIMEGuidLangBarDoubleSingleByte; extern const GUID SampleIMEGuidLangBarPunctuation; extern const GUID SampleIMEGuidDisplayAttributeInput; extern const GUID SampleIMEGuidDisplayAttributeConverted; extern const GUID SampleIMEGuidCandUIElement; extern const WCHAR UnicodeByteOrderMark; extern const WCHAR KeywordDelimiter; extern const WCHAR StringDelimiter; extern const WCHAR ImeModeDescription[]; extern const int ImeModeOnIcoIndex; extern const int ImeModeOffIcoIndex; extern const WCHAR DoubleSingleByteDescription[]; extern const int DoubleSingleByteOnIcoIndex; extern const int DoubleSingleByteOffIcoIndex; extern const WCHAR PunctuationDescription[]; extern const int PunctuationOnIcoIndex; extern const int PunctuationOffIcoIndex; extern const WCHAR LangbarImeModeDescription[]; extern const WCHAR LangbarDoubleSingleByteDescription[]; extern const WCHAR LangbarPunctuationDescription[]; }