├── BasicTextService.zip ├── BasicTextService ├── DllMain.cpp ├── Globals.cpp ├── PreComp.cpp ├── Readme.txt ├── Register.cpp ├── Resource.h ├── Server.cpp ├── TextService.cpp ├── TextService.def ├── TextService.h ├── TextService.ico ├── TextService.rc ├── TextServiceCP.JPG ├── default.asp ├── globals.h ├── makefile └── sample.asp ├── CandidateList.zip ├── CandidateList ├── CandidateList.cpp ├── CandidateList.h ├── CandidateListUI.JPG ├── CandidateWindow.cpp ├── CandidateWindow.h ├── Compartment.cpp ├── Composition.cpp ├── DisplayAttribute.cpp ├── DisplayAttributeInfo.cpp ├── DisplayAttributeInfo.h ├── DisplayAttributeProvider.cpp ├── DllMain.cpp ├── EditSession.h ├── EndComposition.cpp ├── EnumDisplayAttributeInfo.cpp ├── EnumDisplayAttributeInfo.h ├── Globals.cpp ├── Globals.h ├── KeyEventSink.cpp ├── KeyHandler.cpp ├── LanguageBar.cpp ├── PreComp.cpp ├── Readme.txt ├── Register.cpp ├── Resource.h ├── Server.cpp ├── StartComposition.cpp ├── TextEditSink.cpp ├── TextService.cpp ├── TextService.def ├── TextService.h ├── TextService.ico ├── TextService.rc ├── ThreadMgrEventSink.cpp ├── default.asp ├── makefile └── sample.asp ├── Composition.zip ├── Composition ├── Compartment.cpp ├── Composition.cpp ├── DllMain.cpp ├── EditSession.h ├── EndComposition.cpp ├── Globals.cpp ├── Globals.h ├── KeyEventSink.cpp ├── KeyHandler.cpp ├── LanguageBar.cpp ├── PreComp.cpp ├── Readme.txt ├── Register.cpp ├── Resource.h ├── Server.cpp ├── StartComposition.cpp ├── TextEditSink.cpp ├── TextService.cpp ├── TextService.def ├── TextService.h ├── TextService.ico ├── TextService.rc ├── ThreadMgrEventSink.cpp ├── default.asp ├── handlekeyflowchart.JPG ├── makefile └── sample.asp ├── CompositionStringUnderline.zip ├── CompositionStringUnderline ├── Compartment.cpp ├── Composition.cpp ├── DisplayAttribute.cpp ├── DisplayAttributeInfo.cpp ├── DisplayAttributeInfo.h ├── DisplayAttributeProvider.cpp ├── DllMain.cpp ├── EditSession.h ├── EndComposition.cpp ├── EnumDisplayAttributeInfo.cpp ├── EnumDisplayAttributeInfo.h ├── Globals.cpp ├── Globals.h ├── KeyEventSink.cpp ├── KeyHandler.cpp ├── LanguageBar.cpp ├── PreComp.cpp ├── Readme.txt ├── Register.cpp ├── Resource.h ├── Server.cpp ├── StartComposition.cpp ├── TextEditSink.cpp ├── TextService.cpp ├── TextService.def ├── TextService.h ├── TextService.ico ├── TextService.rc ├── ThreadMgrEventSink.cpp ├── compositionstring.JPG ├── compositionstring2.jpg ├── compositionstring3.jpg ├── default.asp ├── makefile └── sample.asp ├── IconInLanguageBar.zip ├── IconInLanguageBar ├── DllMain.cpp ├── EULA_TSF.rtf ├── Globals.cpp ├── Globals.h ├── LanguageBar.cpp ├── PreComp.cpp ├── Readme.txt ├── Register.cpp ├── Resource.h ├── Server.cpp ├── TextEditSink.cpp ├── TextService.cpp ├── TextService.def ├── TextService.h ├── TextService.ico ├── TextService.rc ├── TextServiceCP2.JPG ├── TextServiceLangBar.JPG ├── ThreadMgrEventSink.cpp ├── default.asp ├── makefile └── sample.asp ├── Keyboard.zip ├── Keyboard ├── Compartment.cpp ├── DllMain.cpp ├── Globals.cpp ├── Globals.h ├── JapaneseTextServiceCP.JPG ├── KeyEventSink.cpp ├── LangBarOpenCloseDisable.JPG ├── LanguageBar.cpp ├── PreComp.cpp ├── Readme.txt ├── Register.cpp ├── Resource.h ├── Server.cpp ├── TextEditSink.cpp ├── TextService.cpp ├── TextService.def ├── TextService.h ├── TextService.ico ├── TextService.rc ├── ThreadMgrEventSink.cpp ├── default.asp ├── makefile └── sample.asp ├── LICENSE ├── PropertyMonitor.zip ├── PropertyMonitor ├── DllMain.cpp ├── DumpProperties.cpp ├── EditSession.h ├── Globals.cpp ├── Globals.h ├── LanguageBar.cpp ├── MemoryStream.cpp ├── MemoryStream.h ├── PopupWindow.cpp ├── PopupWindow.h ├── PreComp.cpp ├── PropertyMonitor.JPG ├── PropertyTextService.JPG ├── Readme.txt ├── Register.cpp ├── Resource.h ├── Server.cpp ├── TextEditSink.cpp ├── TextService.cpp ├── TextService.h ├── ThreadFocusSink.cpp ├── ThreadMgrEventSink.cpp ├── TsfPropertyMonitor.def ├── TsfPropertyMonitor.ico ├── TsfPropertyMonitor.rc ├── default.asp ├── makefile └── sample.asp ├── PropertyTextService.zip ├── PropertyTextService ├── CustomProperty.cpp ├── CustomPropertyStore.cpp ├── CustomPropertyStore.h ├── DllMain.cpp ├── EditSession.h ├── Globals.cpp ├── Globals.h ├── LanguageBar.cpp ├── PreComp.cpp ├── PropertyMonitor.JPG ├── PropertyTextService.JPG ├── PropertyTextService.aps ├── PropertyTextService.def ├── PropertyTextService.ico ├── PropertyTextService.rc ├── Readme.txt ├── Register.cpp ├── Resource.h ├── Server.cpp ├── StaticCompactProperty.cpp ├── StaticProperty.cpp ├── TextEditSink.cpp ├── TextService.cpp ├── TextService.h ├── ThreadMgrEventSink.cpp ├── default.asp ├── dl │ └── PropertyTextService.msi ├── makefile └── sample.asp ├── TextInsertion.zip ├── TextInsertion ├── DllMain.cpp ├── EditSession.h ├── Globals.cpp ├── Globals.h ├── HelloWorld.JPG ├── InsertHello.cpp ├── LanguageBar.cpp ├── PreComp.cpp ├── Readme.txt ├── Register.cpp ├── Resource.h ├── Server.cpp ├── TextEditSink.cpp ├── TextService.cpp ├── TextService.def ├── TextService.h ├── TextService.ico ├── TextService.rc ├── ThreadMgrEventSink.cpp ├── default.asp ├── makefile └── sample.asp ├── TrackFocus.zip ├── TrackFocus ├── DllMain.cpp ├── Globals.cpp ├── PreComp.cpp ├── Readme.txt ├── Register.cpp ├── Resource.h ├── Server.cpp ├── TextService.aps ├── TextService.cpp ├── TextService.def ├── TextService.h ├── TextService.ico ├── TextService.rc ├── ThreadMgrEventSink.cpp ├── default.asp ├── globals.h ├── makefile └── sample.asp ├── TrackTextChange.zip └── TrackTextChange ├── DllMain.cpp ├── EULA_TSF.rtf ├── Globals.cpp ├── PreComp.cpp ├── Readme.txt ├── Register.cpp ├── Resource.h ├── Server.cpp ├── TextEditSink.cpp ├── TextService.cpp ├── TextService.def ├── TextService.h ├── TextService.ico ├── TextService.rc ├── ThreadMgrEventSink.cpp ├── default.asp ├── globals.h ├── makefile └── sample.asp /BasicTextService.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/BasicTextService.zip -------------------------------------------------------------------------------- /BasicTextService/DllMain.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) Microsoft Corporation. All rights reserved. 9 | // 10 | // DllMain.cpp 11 | // 12 | // DllMain module entry point. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "Globals.h" 17 | 18 | //+--------------------------------------------------------------------------- 19 | // 20 | // DllMain 21 | // 22 | //---------------------------------------------------------------------------- 23 | 24 | BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID pvReserved) 25 | { 26 | switch (dwReason) 27 | { 28 | case DLL_PROCESS_ATTACH: 29 | 30 | g_hInst = hInstance; 31 | 32 | if (!InitializeCriticalSectionAndSpinCount(&g_cs, 0)) 33 | return FALSE; 34 | 35 | break; 36 | 37 | case DLL_PROCESS_DETACH: 38 | 39 | DeleteCriticalSection(&g_cs); 40 | 41 | break; 42 | } 43 | 44 | return TRUE; 45 | } 46 | -------------------------------------------------------------------------------- /BasicTextService/Globals.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) Microsoft Corporation. All rights reserved. 9 | // 10 | // Globals.cpp 11 | // 12 | // Global variables 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | 18 | HINSTANCE g_hInst; 19 | 20 | LONG g_cRefDll = -1; // -1 /w no refs, for win95 InterlockedIncrement/Decrement compat 21 | 22 | CRITICAL_SECTION g_cs; 23 | 24 | /* e7ea138e-69f8-11d7-a6ea-00065b84435c */ 25 | const CLSID c_clsidTextService = { 26 | 0xe7ea138e, 27 | 0x69f8, 28 | 0x11d7, 29 | {0xa6, 0xea, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 30 | }; 31 | /* e7ea138f-69f8-11d7-a6ea-00065b84435c */ 32 | const GUID c_guidProfile = { 33 | 0xe7ea138f, 34 | 0x69f8, 35 | 0x11d7, 36 | {0xa6, 0xea, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 37 | }; 38 | 39 | -------------------------------------------------------------------------------- /BasicTextService/PreComp.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) Microsoft Corporation. All rights reserved. 9 | // 10 | // PreComp.cpp 11 | // 12 | // Stub for vc precompiled header. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | -------------------------------------------------------------------------------- /BasicTextService/Resource.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) Microsoft Corporation. All rights reserved. 9 | // 10 | // Resource.h 11 | // 12 | // Resource declarations. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef RESOURCE_H 17 | #define RESOURCE_H 18 | 19 | // #define IDI_TEXTSERVICE 0 20 | 21 | #endif // RESOURCE_H 22 | -------------------------------------------------------------------------------- /BasicTextService/TextService.def: -------------------------------------------------------------------------------- 1 | LIBRARY TextService.dll 2 | 3 | EXPORTS 4 | DllGetClassObject PRIVATE 5 | DllCanUnloadNow PRIVATE 6 | DllRegisterServer PRIVATE 7 | DllUnregisterServer PRIVATE 8 | -------------------------------------------------------------------------------- /BasicTextService/TextService.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) Microsoft Corporation. All rights reserved. 9 | // 10 | // TextService.h 11 | // 12 | // CTextService declaration. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef TEXTSERVICE_H 17 | #define TEXTSERVICE_H 18 | 19 | class CTextService : public ITfTextInputProcessor 20 | { 21 | public: 22 | CTextService(); 23 | ~CTextService(); 24 | 25 | // IUnknown 26 | STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj); 27 | STDMETHODIMP_(ULONG) AddRef(void); 28 | STDMETHODIMP_(ULONG) Release(void); 29 | 30 | // ITfTextInputProcessor 31 | STDMETHODIMP Activate(ITfThreadMgr *pThreadMgr, TfClientId tfClientId); 32 | STDMETHODIMP Deactivate(); 33 | 34 | // CClassFactory factory callback 35 | static HRESULT CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObj); 36 | 37 | private: 38 | LONG _cRef; // COM ref count 39 | }; 40 | 41 | 42 | #endif // TEXTSERVICE_H 43 | -------------------------------------------------------------------------------- /BasicTextService/TextService.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/BasicTextService/TextService.ico -------------------------------------------------------------------------------- /BasicTextService/TextService.rc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) Microsoft Corporation. All rights reserved. 9 | // 10 | // TextService.rc 11 | // 12 | // Resources. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | 17 | IDI_TEXTSERVICE ICON TextService.ico 18 | 19 | -------------------------------------------------------------------------------- /BasicTextService/TextServiceCP.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/BasicTextService/TextServiceCP.JPG -------------------------------------------------------------------------------- /BasicTextService/default.asp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/BasicTextService/default.asp -------------------------------------------------------------------------------- /BasicTextService/globals.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) Microsoft Corporation. All rights reserved. 9 | // 10 | // Globals.h 11 | // 12 | // Global variable declarations. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef GLOBALS_H 17 | #define GLOBALS_H 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include "msctf.h" 24 | 25 | void DllAddRef(); 26 | void DllRelease(); 27 | 28 | #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0])) 29 | 30 | #define TEXTSERVICE_LANGID MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US) 31 | 32 | #define TEXTSERVICE_DESC L"Sample Text Service" 33 | #define TEXTSERVICE_DESC_A "Sample Text Service" 34 | #define TEXTSERVICE_MODEL TEXT("Apartment") 35 | 36 | #define TEXTSERVICE_ICON_INDEX 0 37 | 38 | extern HINSTANCE g_hInst; 39 | 40 | extern LONG g_cRefDll; 41 | 42 | extern CRITICAL_SECTION g_cs; 43 | 44 | extern const CLSID c_clsidTextService; 45 | 46 | extern const GUID c_guidProfile; 47 | 48 | 49 | #endif // GLOBALS_H 50 | -------------------------------------------------------------------------------- /BasicTextService/makefile: -------------------------------------------------------------------------------- 1 | #----- set the project name -------------------------------------------------------------- 2 | Proj = TextService 3 | 4 | #----- Include the PSDK's WIN32.MAK to pick up defines ----------------------------------- 5 | !include 6 | 7 | #----- OUTDIR is defined in WIN32.MAK This is the name of the destination directory ------ 8 | all: $(OUTDIR)\$(Proj).dll 9 | 10 | LINK32_OBJS= \ 11 | $(OUTDIR)\TextService.obj \ 12 | $(OUTDIR)\Dllmain.obj \ 13 | $(OUTDIR)\Globals.obj \ 14 | $(OUTDIR)\PreComp.obj \ 15 | $(OUTDIR)\Register.obj \ 16 | $(OUTDIR)\Server.obj 17 | 18 | #----- If OUTDIR does not exist, then create directory 19 | $(OUTDIR) : 20 | if not exist "$(OUTDIR)/$(NULL)" mkdir $(OUTDIR) 21 | 22 | #----- add the preprocessor definitions needed by this project --------------------------- 23 | 24 | #----- set the libraries needed by this project ------------------------------------------ 25 | LINK_LIBS = $(dlllibs) $(guilibs) $(olelibs) 26 | 27 | #--------------------- DLL --------------------------------------------------------------- 28 | #PLEASE REFER TO WIN32.MAK for the different Linker options WIN32.MAK provides 29 | 30 | # Build rule for DLL 31 | $(OUTDIR)\$(Proj).dll: $(OUTDIR) $(LINK32_OBJS) $(OUTDIR)\$(Proj).res 32 | $(link) $(ldebug) $(dllllflags) \ 33 | $(LINK32_OBJS) $(OUTDIR)\$(Proj).res $(LINK_LIBS) \ 34 | -base:0x20000000 \ 35 | -out:$(OUTDIR)\$(Proj).dll \ 36 | -def:$(Proj).def 37 | 38 | #--------------------- Compiling C/CPP Files --------------------------------------------- 39 | #PLEASE REFER TO WIN32.MAK for the different Compiler options WIN32.MAK provides 40 | 41 | FILE=TextService 42 | 43 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 44 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 45 | 46 | FILE=Dllmain 47 | 48 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 49 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 50 | 51 | FILE=Globals 52 | 53 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 54 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 55 | 56 | FILE=Precomp 57 | 58 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 59 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 60 | 61 | FILE=Register 62 | 63 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 64 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 65 | 66 | FILE=Server 67 | 68 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 69 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 70 | 71 | 72 | #--------------------- Compiling Resource Files ------------------------------------------ 73 | #PLEASE REFER TO WIN32.MAK for the different Resource Compiler options WIN32.MAK provides 74 | 75 | # Build rule for resource file 76 | FILE=TextService 77 | 78 | $(OUTDIR)\$(FILE).res: .\$(FILE).rc $(OUTDIR) 79 | $(rc) $(rcflags) $(rcvars) /fo $(OUTDIR)\$(FILE).res .\$(FILE).rc 80 | 81 | #--------------------- Clean Rule -------------------------------------------------------- 82 | # Rules for cleaning out those old files 83 | clean: 84 | $(CLEANUP) 85 | -------------------------------------------------------------------------------- /BasicTextService/sample.asp: -------------------------------------------------------------------------------- 1 | <% response.redirect "default.asp" %> 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /CandidateList.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/CandidateList.zip -------------------------------------------------------------------------------- /CandidateList/CandidateList.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // CandidateList.h 11 | // 12 | // CCandidateList declaration. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef CANDIDATELIST_H 17 | #define CANDIDATELIST_H 18 | 19 | class CCandidateWindow; 20 | 21 | class CCandidateList : public ITfContextKeyEventSink, 22 | public ITfTextLayoutSink 23 | { 24 | public: 25 | CCandidateList(CTextService *pTextService); 26 | ~CCandidateList(); 27 | 28 | // 29 | // IUnknown methods 30 | // 31 | STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj); 32 | STDMETHODIMP_(ULONG) AddRef(void); 33 | STDMETHODIMP_(ULONG) Release(void); 34 | 35 | // 36 | // ITfContextKeyEventSink 37 | // 38 | STDMETHODIMP OnKeyDown(WPARAM wParam, LPARAM lParam, BOOL *pfEaten); 39 | STDMETHODIMP OnKeyUp(WPARAM wParam, LPARAM lParam, BOOL *pfEaten); 40 | STDMETHODIMP OnTestKeyDown(WPARAM wParam, LPARAM lParam, BOOL *pfEaten); 41 | STDMETHODIMP OnTestKeyUp(WPARAM wParam, LPARAM lParam, BOOL *pfEaten); 42 | 43 | // 44 | // ITfTextLayoutSink 45 | // 46 | STDMETHODIMP OnLayoutChange(ITfContext *pContext, TfLayoutCode lcode, ITfContextView *pContextView); 47 | 48 | HRESULT _StartCandidateList(TfClientId tid, ITfDocumentMgr *pDocumentMgr, ITfContext *pContextDocument, TfEditCookie ec, ITfRange *pRangeComposition); 49 | void _EndCandidateList(); 50 | 51 | BOOL _IsContextCandidateWindow(ITfContext *pContext); 52 | 53 | private: 54 | HRESULT _AdviseContextKeyEventSink(); 55 | HRESULT _UnadviseContextKeyEventSink(); 56 | HRESULT _AdviseTextLayoutSink(); 57 | HRESULT _UnadviseTextLayoutSink(); 58 | 59 | CTextService *_pTextService; 60 | ITfRange *_pRangeComposition; 61 | ITfContext *_pContextCandidateWindow; 62 | ITfContext *_pContextDocument; 63 | ITfDocumentMgr *_pDocumentMgr; 64 | 65 | DWORD _dwCookieContextKeyEventSink; // Cookie for ITfContextKeyEventSink 66 | DWORD _dwCookieTextLayoutSink; // Cookie for ITfContextKeyEventSink 67 | 68 | HWND _hwndParent; 69 | CCandidateWindow *_pCandidateWindow; 70 | 71 | LONG _cRef; // COM ref count 72 | }; 73 | 74 | #endif // CANDIDATELIST_H 75 | -------------------------------------------------------------------------------- /CandidateList/CandidateListUI.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/CandidateList/CandidateListUI.JPG -------------------------------------------------------------------------------- /CandidateList/CandidateWindow.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // CandidateWindow.h 11 | // 12 | // CCandidateWindow declaration. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef CANDIDATEWINDOW_H 17 | #define CANDIDATEWINDOW_H 18 | 19 | //+--------------------------------------------------------------------------- 20 | // 21 | // CCandidateWindow 22 | // 23 | //---------------------------------------------------------------------------- 24 | 25 | class CCandidateWindow 26 | { 27 | public: 28 | CCandidateWindow(); 29 | 30 | static BOOL _InitWindowClass(); 31 | static void _UninitWindowClass(); 32 | 33 | BOOL _Create(); 34 | void _Destroy(); 35 | 36 | void _Move(int x, int y); 37 | void _Show(); 38 | void _Hide(); 39 | 40 | HRESULT _OnKeyDown(UINT uVKey); 41 | HRESULT _OnKeyUp(UINT uVKey); 42 | 43 | private: 44 | static LRESULT CALLBACK _WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 45 | 46 | static void _SetThis(HWND hwnd, LPARAM lParam) 47 | { 48 | SetWindowLongPtr(hwnd, GWLP_USERDATA, 49 | (LONG_PTR)((CREATESTRUCT *)lParam)->lpCreateParams); 50 | } 51 | 52 | static CCandidateWindow *_GetThis(HWND hwnd) 53 | { 54 | return (CCandidateWindow *)GetWindowLongPtr(hwnd, GWLP_USERDATA); 55 | } 56 | 57 | static ATOM _atomWndClass; 58 | 59 | HWND _hwnd; 60 | }; 61 | 62 | #endif // CANDIDATEWINDOW_H 63 | -------------------------------------------------------------------------------- /CandidateList/Composition.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Composition.cpp 11 | // 12 | // ITfCompositionSink interface and compositon utilities 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "Globals.h" 17 | #include "TextService.h" 18 | 19 | //+--------------------------------------------------------------------------- 20 | // 21 | // OnCompositionTerminated 22 | // 23 | // Callback for ITfCompositionSink. The system calls this method whenever 24 | // someone other than this service ends a composition. 25 | //---------------------------------------------------------------------------- 26 | 27 | STDAPI CTextService::OnCompositionTerminated(TfEditCookie ecWrite, ITfComposition *pComposition) 28 | { 29 | 30 | // releae our cached composition 31 | if (_pComposition != NULL) 32 | { 33 | _pComposition->Release(); 34 | _pComposition = NULL; 35 | } 36 | 37 | return S_OK; 38 | } 39 | 40 | //+--------------------------------------------------------------------------- 41 | // 42 | // _IsComposing 43 | // 44 | //---------------------------------------------------------------------------- 45 | 46 | BOOL CTextService::_IsComposing() 47 | { 48 | return _pComposition != NULL; 49 | } 50 | 51 | //+--------------------------------------------------------------------------- 52 | // 53 | // _SetComposition 54 | // 55 | //---------------------------------------------------------------------------- 56 | 57 | void CTextService::_SetComposition(ITfComposition *pComposition) 58 | { 59 | _pComposition = pComposition; 60 | } 61 | 62 | -------------------------------------------------------------------------------- /CandidateList/DisplayAttributeInfo.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // DisplayAttribureInfo.h 11 | // 12 | // CDisplayAttributeInfo class 13 | // CDisplayAttributeInfoInput class 14 | // CDisplayAttributeInfoConverted class 15 | // 16 | ////////////////////////////////////////////////////////////////////// 17 | 18 | #ifndef DISPLAYATTRIBUTEINFO_H 19 | #define DISPLAYATTRIBUTEINFO_H 20 | 21 | //+--------------------------------------------------------------------------- 22 | // 23 | // CDisplayAttributeInfo class 24 | // 25 | //---------------------------------------------------------------------------- 26 | 27 | class CDisplayAttributeInfo : public ITfDisplayAttributeInfo 28 | { 29 | public: 30 | CDisplayAttributeInfo(); 31 | ~CDisplayAttributeInfo(); 32 | 33 | // IUnknown 34 | STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj); 35 | STDMETHODIMP_(ULONG) AddRef(void); 36 | STDMETHODIMP_(ULONG) Release(void); 37 | 38 | // ITfDisplayAttributeInfo 39 | STDMETHODIMP GetGUID(GUID *pguid); 40 | STDMETHODIMP GetDescription(BSTR *pbstrDesc); 41 | STDMETHODIMP GetAttributeInfo(TF_DISPLAYATTRIBUTE *ptfDisplayAttr); 42 | STDMETHODIMP SetAttributeInfo(const TF_DISPLAYATTRIBUTE *ptfDisplayAttr); 43 | STDMETHODIMP Reset(); 44 | 45 | protected: 46 | const GUID *_pguid; 47 | const TF_DISPLAYATTRIBUTE *_pDisplayAttribute; 48 | const WCHAR *_pszDescription; 49 | const TCHAR *_pszValueName; 50 | 51 | private: 52 | LONG _cRef; // COM ref count 53 | }; 54 | 55 | //+--------------------------------------------------------------------------- 56 | // 57 | // CDisplayAttributeInfoInput class 58 | // 59 | //---------------------------------------------------------------------------- 60 | 61 | class CDisplayAttributeInfoInput : public CDisplayAttributeInfo 62 | { 63 | public: 64 | CDisplayAttributeInfoInput() 65 | { 66 | _pguid = &c_guidDisplayAttributeInput; 67 | _pDisplayAttribute = &_s_DisplayAttribute; 68 | _pszDescription = _s_szDescription; 69 | _pszValueName = _s_szValueName; 70 | } 71 | 72 | static const TF_DISPLAYATTRIBUTE _s_DisplayAttribute; 73 | static const WCHAR _s_szDescription[]; 74 | static const TCHAR _s_szValueName[]; 75 | }; 76 | 77 | //+--------------------------------------------------------------------------- 78 | // 79 | // CDisplayAttributeInfoConverted class 80 | // 81 | //---------------------------------------------------------------------------- 82 | 83 | class CDisplayAttributeInfoConverted : public CDisplayAttributeInfo 84 | { 85 | public: 86 | CDisplayAttributeInfoConverted() 87 | { 88 | _pguid = &c_guidDisplayAttributeConverted; 89 | _pDisplayAttribute = &_s_DisplayAttribute; 90 | _pszDescription = _s_szDescription; 91 | _pszValueName = _s_szValueName; 92 | } 93 | 94 | static const TF_DISPLAYATTRIBUTE _s_DisplayAttribute; 95 | static const WCHAR _s_szDescription[]; 96 | static const TCHAR _s_szValueName[]; 97 | }; 98 | 99 | #endif DISPLAYATTRIBUTEINFO_H 100 | -------------------------------------------------------------------------------- /CandidateList/DisplayAttributeProvider.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // DisplayAttribureProvider.cpp 11 | // 12 | // ITfDisplayAttributeProvider implementation. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | #include "TextService.h" 18 | #include "DisplayAttributeInfo.h" 19 | #include "EnumDisplayAttributeInfo.h" 20 | 21 | //+--------------------------------------------------------------------------- 22 | // 23 | // EnumDisplayAttributeInfo 24 | // 25 | //---------------------------------------------------------------------------- 26 | 27 | STDAPI CTextService::EnumDisplayAttributeInfo(IEnumTfDisplayAttributeInfo **ppEnum) 28 | { 29 | CEnumDisplayAttributeInfo *pAttributeEnum; 30 | 31 | if (ppEnum == NULL) 32 | return E_INVALIDARG; 33 | 34 | *ppEnum = NULL; 35 | 36 | if ((pAttributeEnum = new CEnumDisplayAttributeInfo) == NULL) 37 | return E_OUTOFMEMORY; 38 | 39 | *ppEnum = pAttributeEnum; 40 | 41 | return S_OK; 42 | } 43 | 44 | //+--------------------------------------------------------------------------- 45 | // 46 | // GetDisplayAttributeInfo 47 | // 48 | //---------------------------------------------------------------------------- 49 | 50 | STDAPI CTextService::GetDisplayAttributeInfo(REFGUID guidInfo, ITfDisplayAttributeInfo **ppInfo) 51 | { 52 | if (ppInfo == NULL) 53 | return E_INVALIDARG; 54 | 55 | *ppInfo = NULL; 56 | 57 | // Which display attribute GUID? 58 | if (IsEqualGUID(guidInfo, c_guidDisplayAttributeInput)) 59 | { 60 | if ((*ppInfo = new CDisplayAttributeInfoInput()) == NULL) 61 | return E_OUTOFMEMORY; 62 | } 63 | else if (IsEqualGUID(guidInfo, c_guidDisplayAttributeConverted)) 64 | { 65 | if ((*ppInfo = new CDisplayAttributeInfoConverted()) == NULL) 66 | return E_OUTOFMEMORY; 67 | } 68 | else 69 | { 70 | return E_INVALIDARG; 71 | } 72 | 73 | 74 | return S_OK; 75 | } 76 | -------------------------------------------------------------------------------- /CandidateList/DllMain.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // DllMain.cpp 11 | // 12 | // DllMain module entry point. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "Globals.h" 17 | #include "CandidateWindow.h" 18 | 19 | //+--------------------------------------------------------------------------- 20 | // 21 | // DllMain 22 | // 23 | //---------------------------------------------------------------------------- 24 | 25 | BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID pvReserved) 26 | { 27 | switch (dwReason) 28 | { 29 | case DLL_PROCESS_ATTACH: 30 | 31 | g_hInst = hInstance; 32 | 33 | if (!InitializeCriticalSectionAndSpinCount(&g_cs, 0)) 34 | return FALSE; 35 | 36 | // register candidate window class. 37 | CCandidateWindow::_InitWindowClass(); 38 | 39 | break; 40 | 41 | case DLL_PROCESS_DETACH: 42 | 43 | // unregister candidate window class. 44 | CCandidateWindow::_UninitWindowClass(); 45 | 46 | DeleteCriticalSection(&g_cs); 47 | 48 | break; 49 | } 50 | 51 | return TRUE; 52 | } 53 | -------------------------------------------------------------------------------- /CandidateList/EditSession.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // EditSession.h 11 | // 12 | // CEditSessionBase declaration. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef EDITSESSION_H 17 | #define EDITSESSION_H 18 | 19 | #include "TextService.h" 20 | 21 | class CEditSessionBase : public ITfEditSession 22 | { 23 | public: 24 | CEditSessionBase(CTextService *pTextService, ITfContext *pContext) 25 | { 26 | _cRef = 1; 27 | _pContext = pContext; 28 | _pContext->AddRef(); 29 | 30 | _pTextService = pTextService; 31 | _pTextService->AddRef(); 32 | } 33 | virtual ~CEditSessionBase() 34 | { 35 | _pContext->Release(); 36 | _pTextService->Release(); 37 | } 38 | 39 | // IUnknown 40 | STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj) 41 | { 42 | if (ppvObj == NULL) 43 | return E_INVALIDARG; 44 | 45 | *ppvObj = NULL; 46 | 47 | if (IsEqualIID(riid, IID_IUnknown) || 48 | IsEqualIID(riid, IID_ITfEditSession)) 49 | { 50 | *ppvObj = (ITfLangBarItemButton *)this; 51 | } 52 | 53 | if (*ppvObj) 54 | { 55 | AddRef(); 56 | return S_OK; 57 | } 58 | 59 | return E_NOINTERFACE; 60 | } 61 | STDMETHODIMP_(ULONG) AddRef(void) 62 | { 63 | return ++_cRef; 64 | } 65 | STDMETHODIMP_(ULONG) Release(void) 66 | { 67 | LONG cr = --_cRef; 68 | 69 | assert(_cRef >= 0); 70 | 71 | if (_cRef == 0) 72 | { 73 | delete this; 74 | } 75 | 76 | return cr; 77 | } 78 | 79 | // ITfEditSession 80 | virtual STDMETHODIMP DoEditSession(TfEditCookie ec) = 0; 81 | 82 | protected: 83 | ITfContext *_pContext; 84 | CTextService *_pTextService; 85 | 86 | private: 87 | LONG _cRef; // COM ref count 88 | }; 89 | 90 | #endif // EDITSESSION_H 91 | -------------------------------------------------------------------------------- /CandidateList/EndComposition.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // EndComposition.cpp 11 | // 12 | // terminate the compositon object 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "Globals.h" 17 | #include "EditSession.h" 18 | #include "TextService.h" 19 | 20 | //+--------------------------------------------------------------------------- 21 | // 22 | // CEndCompositionEditSession 23 | // 24 | //---------------------------------------------------------------------------- 25 | 26 | class CEndCompositionEditSession : public CEditSessionBase 27 | { 28 | public: 29 | CEndCompositionEditSession(CTextService *pTextService, ITfContext *pContext) : CEditSessionBase(pTextService, pContext) 30 | { 31 | } 32 | 33 | // ITfEditSession 34 | STDMETHODIMP DoEditSession(TfEditCookie ec) 35 | { 36 | _pTextService->_TerminateComposition(ec, _pContext); 37 | return S_OK; 38 | } 39 | 40 | }; 41 | 42 | //+--------------------------------------------------------------------------- 43 | // 44 | // _TerminateComposition 45 | // 46 | //---------------------------------------------------------------------------- 47 | 48 | void CTextService::_TerminateComposition(TfEditCookie ec, ITfContext *pContext) 49 | { 50 | if (_pComposition != NULL) 51 | { 52 | // 53 | // remove the display attribute from the composition range. 54 | // 55 | _ClearCompositionDisplayAttributes(ec, pContext); 56 | 57 | _pComposition->EndComposition(ec); 58 | _pComposition->Release(); 59 | _pComposition = NULL; 60 | } 61 | } 62 | 63 | //+--------------------------------------------------------------------------- 64 | // 65 | // _EndComposition 66 | // 67 | //---------------------------------------------------------------------------- 68 | 69 | void CTextService::_EndComposition(ITfContext *pContext) 70 | { 71 | CEndCompositionEditSession *pEditSession; 72 | HRESULT hr; 73 | 74 | if (pEditSession = new CEndCompositionEditSession(this, pContext)) 75 | { 76 | pContext->RequestEditSession(_tfClientId, pEditSession, TF_ES_ASYNCDONTCARE | TF_ES_READWRITE, &hr); 77 | pEditSession->Release(); 78 | } 79 | } 80 | 81 | -------------------------------------------------------------------------------- /CandidateList/EnumDisplayAttributeInfo.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // EnumDisplayAttribureInfo.h 11 | // 12 | // ITfEnumDisplayAttributeInfo implementation. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef ENUMDISPLAYATTRIBUTEINFO_H 17 | #define ENUMDISPLAYATTRIBUTEINFO_H 18 | 19 | //+--------------------------------------------------------------------------- 20 | // 21 | // CEnumDisplayAttributeInfo 22 | // 23 | //---------------------------------------------------------------------------- 24 | 25 | class CEnumDisplayAttributeInfo : public IEnumTfDisplayAttributeInfo 26 | { 27 | public: 28 | CEnumDisplayAttributeInfo(); 29 | ~CEnumDisplayAttributeInfo(); 30 | 31 | // IUnknown 32 | STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj); 33 | STDMETHODIMP_(ULONG) AddRef(void); 34 | STDMETHODIMP_(ULONG) Release(void); 35 | 36 | // IEnumTfDisplayAttributeInfo 37 | STDMETHODIMP Clone(IEnumTfDisplayAttributeInfo **ppEnum); 38 | STDMETHODIMP Next(ULONG ulCount, ITfDisplayAttributeInfo **rgInfo, ULONG *pcFetched); 39 | STDMETHODIMP Reset(); 40 | STDMETHODIMP Skip(ULONG ulCount); 41 | 42 | private: 43 | LONG _iIndex; // next display attribute to enum 44 | LONG _cRef; // COM ref count 45 | }; 46 | 47 | #endif ENUMDISPLAYATTRIBUTEINFO_H 48 | -------------------------------------------------------------------------------- /CandidateList/Globals.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Globals.cpp 11 | // 12 | // Global variables 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | 18 | HINSTANCE g_hInst; 19 | 20 | LONG g_cRefDll = -1; // -1 /w no refs, for win95 InterlockedIncrement/Decrement compat 21 | 22 | CRITICAL_SECTION g_cs; 23 | 24 | /* e7ea138e-69f8-11d7-a6ea-00065b84435c */ 25 | const CLSID c_clsidTextService = { 26 | 0xe7ea138e, 27 | 0x69f8, 28 | 0x11d7, 29 | {0xa6, 0xea, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 30 | }; 31 | /* e7ea138f-69f8-11d7-a6ea-00065b84435c */ 32 | const GUID c_guidProfile = { 33 | 0xe7ea138f, 34 | 0x69f8, 35 | 0x11d7, 36 | {0xa6, 0xea, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 37 | }; 38 | /* 41f46e67-86d5-49fb-a1d9-3dc0941a66a3 */ 39 | const GUID c_guidLangBarItemButton = { 40 | 0x41f46e67, 41 | 0x86d5, 42 | 0x49fb, 43 | {0xa1, 0xd9, 0x3d, 0xc0, 0x94, 0x1a, 0x66, 0xa3} 44 | }; 45 | 46 | 47 | // 48 | // define two guids for display attribute info. This textservice has 49 | // two display attribute. One is for input text and the other is for the 50 | // converted text. 51 | // 52 | // c_guidDisplayAttributeInput 53 | // c_guidDisplayAttributeConverted 54 | // 55 | /* 4e1aa3fe-6c7f-11d7-a6ec-00065b84435c */ 56 | const GUID c_guidDisplayAttributeInput = { 57 | 0x4e1aa3fe, 58 | 0x6c7f, 59 | 0x11d7, 60 | {0xa6, 0xec, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 61 | }; 62 | /* 4e1aa3ff-6c7f-11d7-a6ec-00065b84435c */ 63 | const GUID c_guidDisplayAttributeConverted = { 64 | 0x4e1aa3ff, 65 | 0x6c7f, 66 | 0x11d7, 67 | {0xa6, 0xec, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 68 | }; 69 | 70 | -------------------------------------------------------------------------------- /CandidateList/Globals.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Globals.h 11 | // 12 | // Global variable declarations. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef GLOBALS_H 17 | #define GLOBALS_H 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include "msctf.h" 24 | 25 | void DllAddRef(); 26 | void DllRelease(); 27 | 28 | #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0])) 29 | 30 | #define TEXTSERVICE_LANGID MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT) 31 | 32 | #define TEXTSERVICE_DESC L"Sample Text Service" 33 | #define TEXTSERVICE_DESC_A "Sample Text Service" 34 | #define TEXTSERVICE_MODEL TEXT("Apartment") 35 | 36 | #define TEXTSERVICE_ICON_INDEX 0 37 | #define LANGBAR_ITEM_DESC L"Sample Text Service Button" 38 | 39 | //+--------------------------------------------------------------------------- 40 | // 41 | // SafeStringCopy 42 | // 43 | // Copies a string from one buffer to another. wcsncpy does not always 44 | // null-terminate the destination buffer; this function does. 45 | //---------------------------------------------------------------------------- 46 | 47 | inline void SafeStringCopy(WCHAR *pchDst, ULONG cchMax, const WCHAR *pchSrc) 48 | { 49 | if (cchMax > 0) 50 | { 51 | wcsncpy(pchDst, pchSrc, cchMax); 52 | pchDst[cchMax-1] = '\0'; 53 | } 54 | } 55 | 56 | extern HINSTANCE g_hInst; 57 | 58 | extern LONG g_cRefDll; 59 | 60 | extern CRITICAL_SECTION g_cs; 61 | 62 | extern const CLSID c_clsidTextService; 63 | 64 | extern const GUID c_guidProfile; 65 | 66 | extern const GUID c_guidLangBarItemButton; 67 | 68 | extern const GUID c_guidDisplayAttributeInput; 69 | extern const GUID c_guidDisplayAttributeConverted; 70 | 71 | #endif // GLOBALS_H 72 | -------------------------------------------------------------------------------- /CandidateList/PreComp.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // PreComp.cpp 11 | // 12 | // Stub for vc precompiled header. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | -------------------------------------------------------------------------------- /CandidateList/Resource.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Resource.h 11 | // 12 | // Resource declarations. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef RESOURCE_H 17 | #define RESOURCE_H 18 | 19 | // #define IDI_TEXTSERVICE 0 20 | 21 | #endif // RESOURCE_H 22 | -------------------------------------------------------------------------------- /CandidateList/TextService.def: -------------------------------------------------------------------------------- 1 | LIBRARY TextService.dll 2 | 3 | EXPORTS 4 | DllGetClassObject PRIVATE 5 | DllCanUnloadNow PRIVATE 6 | DllRegisterServer PRIVATE 7 | DllUnregisterServer PRIVATE 8 | -------------------------------------------------------------------------------- /CandidateList/TextService.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/CandidateList/TextService.ico -------------------------------------------------------------------------------- /CandidateList/TextService.rc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // TextService.rc 11 | // 12 | // Resources. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | 17 | IDI_TEXTSERVICE ICON TextService.ico 18 | 19 | -------------------------------------------------------------------------------- /CandidateList/default.asp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/CandidateList/default.asp -------------------------------------------------------------------------------- /CandidateList/sample.asp: -------------------------------------------------------------------------------- 1 | <% response.redirect "default.asp" %> 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Composition.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/Composition.zip -------------------------------------------------------------------------------- /Composition/Composition.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Composition.cpp 11 | // 12 | // ITfCompositionSink interface and compositon utilities 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "Globals.h" 17 | #include "TextService.h" 18 | 19 | //+--------------------------------------------------------------------------- 20 | // 21 | // OnCompositionTerminated 22 | // 23 | // Callback for ITfCompositionSink. The system calls this method whenever 24 | // someone other than this service ends a composition. 25 | //---------------------------------------------------------------------------- 26 | 27 | STDAPI CTextService::OnCompositionTerminated(TfEditCookie ecWrite, ITfComposition *pComposition) 28 | { 29 | 30 | // releae our cached composition 31 | if (_pComposition != NULL) 32 | { 33 | _pComposition->Release(); 34 | _pComposition = NULL; 35 | } 36 | 37 | return S_OK; 38 | } 39 | 40 | //+--------------------------------------------------------------------------- 41 | // 42 | // _IsComposing 43 | // 44 | //---------------------------------------------------------------------------- 45 | 46 | BOOL CTextService::_IsComposing() 47 | { 48 | return _pComposition != NULL; 49 | } 50 | 51 | //+--------------------------------------------------------------------------- 52 | // 53 | // _SetComposition 54 | // 55 | //---------------------------------------------------------------------------- 56 | 57 | void CTextService::_SetComposition(ITfComposition *pComposition) 58 | { 59 | _pComposition = pComposition; 60 | } 61 | 62 | -------------------------------------------------------------------------------- /Composition/DllMain.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // DllMain.cpp 11 | // 12 | // DllMain module entry point. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "Globals.h" 17 | 18 | //+--------------------------------------------------------------------------- 19 | // 20 | // DllMain 21 | // 22 | //---------------------------------------------------------------------------- 23 | 24 | BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID pvReserved) 25 | { 26 | switch (dwReason) 27 | { 28 | case DLL_PROCESS_ATTACH: 29 | 30 | g_hInst = hInstance; 31 | 32 | if (!InitializeCriticalSectionAndSpinCount(&g_cs, 0)) 33 | return FALSE; 34 | 35 | break; 36 | 37 | case DLL_PROCESS_DETACH: 38 | 39 | DeleteCriticalSection(&g_cs); 40 | 41 | break; 42 | } 43 | 44 | return TRUE; 45 | } 46 | -------------------------------------------------------------------------------- /Composition/EditSession.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // EditSession.h 11 | // 12 | // CEditSessionBase declaration. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef EDITSESSION_H 17 | #define EDITSESSION_H 18 | 19 | #include "TextService.h" 20 | 21 | class CEditSessionBase : public ITfEditSession 22 | { 23 | public: 24 | CEditSessionBase(CTextService *pTextService, ITfContext *pContext) 25 | { 26 | _cRef = 1; 27 | _pContext = pContext; 28 | _pContext->AddRef(); 29 | 30 | _pTextService = pTextService; 31 | _pTextService->AddRef(); 32 | } 33 | virtual ~CEditSessionBase() 34 | { 35 | _pContext->Release(); 36 | _pTextService->Release(); 37 | } 38 | 39 | // IUnknown 40 | STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj) 41 | { 42 | if (ppvObj == NULL) 43 | return E_INVALIDARG; 44 | 45 | *ppvObj = NULL; 46 | 47 | if (IsEqualIID(riid, IID_IUnknown) || 48 | IsEqualIID(riid, IID_ITfEditSession)) 49 | { 50 | *ppvObj = (ITfLangBarItemButton *)this; 51 | } 52 | 53 | if (*ppvObj) 54 | { 55 | AddRef(); 56 | return S_OK; 57 | } 58 | 59 | return E_NOINTERFACE; 60 | } 61 | STDMETHODIMP_(ULONG) AddRef(void) 62 | { 63 | return ++_cRef; 64 | } 65 | STDMETHODIMP_(ULONG) Release(void) 66 | { 67 | LONG cr = --_cRef; 68 | 69 | assert(_cRef >= 0); 70 | 71 | if (_cRef == 0) 72 | { 73 | delete this; 74 | } 75 | 76 | return cr; 77 | } 78 | 79 | // ITfEditSession 80 | virtual STDMETHODIMP DoEditSession(TfEditCookie ec) = 0; 81 | 82 | protected: 83 | ITfContext *_pContext; 84 | CTextService *_pTextService; 85 | 86 | private: 87 | LONG _cRef; // COM ref count 88 | }; 89 | 90 | #endif // EDITSESSION_H 91 | -------------------------------------------------------------------------------- /Composition/EndComposition.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // EndComposition.cpp 11 | // 12 | // terminate the compositon object 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "Globals.h" 17 | #include "EditSession.h" 18 | #include "TextService.h" 19 | 20 | //+--------------------------------------------------------------------------- 21 | // 22 | // CEndCompositionEditSession 23 | // 24 | //---------------------------------------------------------------------------- 25 | 26 | class CEndCompositionEditSession : public CEditSessionBase 27 | { 28 | public: 29 | CEndCompositionEditSession(CTextService *pTextService, ITfContext *pContext) : CEditSessionBase(pTextService, pContext) 30 | { 31 | } 32 | 33 | // ITfEditSession 34 | STDMETHODIMP DoEditSession(TfEditCookie ec) 35 | { 36 | _pTextService->_TerminateComposition(ec); 37 | return S_OK; 38 | } 39 | 40 | }; 41 | 42 | //+--------------------------------------------------------------------------- 43 | // 44 | // _TerminateComposition 45 | // 46 | //---------------------------------------------------------------------------- 47 | 48 | void CTextService::_TerminateComposition(TfEditCookie ec) 49 | { 50 | if (_pComposition != NULL) 51 | { 52 | _pComposition->EndComposition(ec); 53 | _pComposition->Release(); 54 | _pComposition = NULL; 55 | } 56 | } 57 | 58 | //+--------------------------------------------------------------------------- 59 | // 60 | // _EndComposition 61 | // 62 | //---------------------------------------------------------------------------- 63 | 64 | void CTextService::_EndComposition(ITfContext *pContext) 65 | { 66 | CEndCompositionEditSession *pEditSession; 67 | HRESULT hr; 68 | 69 | if (pEditSession = new CEndCompositionEditSession(this, pContext)) 70 | { 71 | pContext->RequestEditSession(_tfClientId, pEditSession, TF_ES_ASYNCDONTCARE | TF_ES_READWRITE, &hr); 72 | pEditSession->Release(); 73 | } 74 | } 75 | 76 | -------------------------------------------------------------------------------- /Composition/Globals.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Globals.cpp 11 | // 12 | // Global variables 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | 18 | HINSTANCE g_hInst; 19 | 20 | LONG g_cRefDll = -1; // -1 /w no refs, for win95 InterlockedIncrement/Decrement compat 21 | 22 | CRITICAL_SECTION g_cs; 23 | 24 | /* e7ea138e-69f8-11d7-a6ea-00065b84435c */ 25 | const CLSID c_clsidTextService = { 26 | 0xe7ea138e, 27 | 0x69f8, 28 | 0x11d7, 29 | {0xa6, 0xea, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 30 | }; 31 | /* e7ea138f-69f8-11d7-a6ea-00065b84435c */ 32 | const GUID c_guidProfile = { 33 | 0xe7ea138f, 34 | 0x69f8, 35 | 0x11d7, 36 | {0xa6, 0xea, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 37 | }; 38 | /* 41f46e67-86d5-49fb-a1d9-3dc0941a66a3 */ 39 | const GUID c_guidLangBarItemButton = { 40 | 0x41f46e67, 41 | 0x86d5, 42 | 0x49fb, 43 | {0xa1, 0xd9, 0x3d, 0xc0, 0x94, 0x1a, 0x66, 0xa3} 44 | }; 45 | 46 | -------------------------------------------------------------------------------- /Composition/Globals.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Globals.h 11 | // 12 | // Global variable declarations. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef GLOBALS_H 17 | #define GLOBALS_H 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include "msctf.h" 24 | 25 | void DllAddRef(); 26 | void DllRelease(); 27 | 28 | #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0])) 29 | 30 | #define TEXTSERVICE_LANGID MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT) 31 | 32 | #define TEXTSERVICE_DESC L"Sample Text Service" 33 | #define TEXTSERVICE_DESC_A "Sample Text Service" 34 | #define TEXTSERVICE_MODEL TEXT("Apartment") 35 | 36 | #define TEXTSERVICE_ICON_INDEX 0 37 | #define LANGBAR_ITEM_DESC L"Sample Text Service Button" 38 | 39 | //+--------------------------------------------------------------------------- 40 | // 41 | // SafeStringCopy 42 | // 43 | // Copies a string from one buffer to another. wcsncpy does not always 44 | // null-terminate the destination buffer; this function does. 45 | //---------------------------------------------------------------------------- 46 | 47 | inline void SafeStringCopy(WCHAR *pchDst, ULONG cchMax, const WCHAR *pchSrc) 48 | { 49 | if (cchMax > 0) 50 | { 51 | wcsncpy(pchDst, pchSrc, cchMax); 52 | pchDst[cchMax-1] = '\0'; 53 | } 54 | } 55 | 56 | extern HINSTANCE g_hInst; 57 | 58 | extern LONG g_cRefDll; 59 | 60 | extern CRITICAL_SECTION g_cs; 61 | 62 | extern const CLSID c_clsidTextService; 63 | 64 | extern const GUID c_guidProfile; 65 | 66 | extern const GUID c_guidLangBarItemButton; 67 | 68 | 69 | #endif // GLOBALS_H 70 | -------------------------------------------------------------------------------- /Composition/PreComp.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // PreComp.cpp 11 | // 12 | // Stub for vc precompiled header. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | -------------------------------------------------------------------------------- /Composition/Resource.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Resource.h 11 | // 12 | // Resource declarations. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef RESOURCE_H 17 | #define RESOURCE_H 18 | 19 | // #define IDI_TEXTSERVICE 0 20 | 21 | #endif // RESOURCE_H 22 | -------------------------------------------------------------------------------- /Composition/TextService.def: -------------------------------------------------------------------------------- 1 | LIBRARY TextService.dll 2 | 3 | EXPORTS 4 | DllGetClassObject PRIVATE 5 | DllCanUnloadNow PRIVATE 6 | DllRegisterServer PRIVATE 7 | DllUnregisterServer PRIVATE 8 | -------------------------------------------------------------------------------- /Composition/TextService.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/Composition/TextService.ico -------------------------------------------------------------------------------- /Composition/TextService.rc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // TextService.rc 11 | // 12 | // Resources. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | 17 | IDI_TEXTSERVICE ICON TextService.ico 18 | 19 | -------------------------------------------------------------------------------- /Composition/default.asp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/Composition/default.asp -------------------------------------------------------------------------------- /Composition/handlekeyflowchart.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/Composition/handlekeyflowchart.JPG -------------------------------------------------------------------------------- /Composition/sample.asp: -------------------------------------------------------------------------------- 1 | <% response.redirect "default.asp" %> 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /CompositionStringUnderline.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/CompositionStringUnderline.zip -------------------------------------------------------------------------------- /CompositionStringUnderline/Composition.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Composition.cpp 11 | // 12 | // ITfCompositionSink interface and compositon utilities 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "Globals.h" 17 | #include "TextService.h" 18 | 19 | //+--------------------------------------------------------------------------- 20 | // 21 | // OnCompositionTerminated 22 | // 23 | // Callback for ITfCompositionSink. The system calls this method whenever 24 | // someone other than this service ends a composition. 25 | //---------------------------------------------------------------------------- 26 | 27 | STDAPI CTextService::OnCompositionTerminated(TfEditCookie ecWrite, ITfComposition *pComposition) 28 | { 29 | 30 | // releae our cached composition 31 | if (_pComposition != NULL) 32 | { 33 | _pComposition->Release(); 34 | _pComposition = NULL; 35 | } 36 | 37 | return S_OK; 38 | } 39 | 40 | //+--------------------------------------------------------------------------- 41 | // 42 | // _IsComposing 43 | // 44 | //---------------------------------------------------------------------------- 45 | 46 | BOOL CTextService::_IsComposing() 47 | { 48 | return _pComposition != NULL; 49 | } 50 | 51 | //+--------------------------------------------------------------------------- 52 | // 53 | // _SetComposition 54 | // 55 | //---------------------------------------------------------------------------- 56 | 57 | void CTextService::_SetComposition(ITfComposition *pComposition) 58 | { 59 | _pComposition = pComposition; 60 | } 61 | 62 | -------------------------------------------------------------------------------- /CompositionStringUnderline/DisplayAttributeInfo.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // DisplayAttribureInfo.h 11 | // 12 | // CDisplayAttributeInfo class 13 | // CDisplayAttributeInfoInput class 14 | // CDisplayAttributeInfoConverted class 15 | // 16 | ////////////////////////////////////////////////////////////////////// 17 | 18 | #ifndef DISPLAYATTRIBUTEINFO_H 19 | #define DISPLAYATTRIBUTEINFO_H 20 | 21 | //+--------------------------------------------------------------------------- 22 | // 23 | // CDisplayAttributeInfo class 24 | // 25 | //---------------------------------------------------------------------------- 26 | 27 | class CDisplayAttributeInfo : public ITfDisplayAttributeInfo 28 | { 29 | public: 30 | CDisplayAttributeInfo(); 31 | ~CDisplayAttributeInfo(); 32 | 33 | // IUnknown 34 | STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj); 35 | STDMETHODIMP_(ULONG) AddRef(void); 36 | STDMETHODIMP_(ULONG) Release(void); 37 | 38 | // ITfDisplayAttributeInfo 39 | STDMETHODIMP GetGUID(GUID *pguid); 40 | STDMETHODIMP GetDescription(BSTR *pbstrDesc); 41 | STDMETHODIMP GetAttributeInfo(TF_DISPLAYATTRIBUTE *ptfDisplayAttr); 42 | STDMETHODIMP SetAttributeInfo(const TF_DISPLAYATTRIBUTE *ptfDisplayAttr); 43 | STDMETHODIMP Reset(); 44 | 45 | protected: 46 | const GUID *_pguid; 47 | const TF_DISPLAYATTRIBUTE *_pDisplayAttribute; 48 | const WCHAR *_pszDescription; 49 | const TCHAR *_pszValueName; 50 | 51 | private: 52 | LONG _cRef; // COM ref count 53 | }; 54 | 55 | //+--------------------------------------------------------------------------- 56 | // 57 | // CDisplayAttributeInfoInput class 58 | // 59 | //---------------------------------------------------------------------------- 60 | 61 | class CDisplayAttributeInfoInput : public CDisplayAttributeInfo 62 | { 63 | public: 64 | CDisplayAttributeInfoInput() 65 | { 66 | _pguid = &c_guidDisplayAttributeInput; 67 | _pDisplayAttribute = &_s_DisplayAttribute; 68 | _pszDescription = _s_szDescription; 69 | _pszValueName = _s_szValueName; 70 | } 71 | 72 | static const TF_DISPLAYATTRIBUTE _s_DisplayAttribute; 73 | static const WCHAR _s_szDescription[]; 74 | static const TCHAR _s_szValueName[]; 75 | }; 76 | 77 | //+--------------------------------------------------------------------------- 78 | // 79 | // CDisplayAttributeInfoConverted class 80 | // 81 | //---------------------------------------------------------------------------- 82 | 83 | class CDisplayAttributeInfoConverted : public CDisplayAttributeInfo 84 | { 85 | public: 86 | CDisplayAttributeInfoConverted() 87 | { 88 | _pguid = &c_guidDisplayAttributeConverted; 89 | _pDisplayAttribute = &_s_DisplayAttribute; 90 | _pszDescription = _s_szDescription; 91 | _pszValueName = _s_szValueName; 92 | } 93 | 94 | static const TF_DISPLAYATTRIBUTE _s_DisplayAttribute; 95 | static const WCHAR _s_szDescription[]; 96 | static const TCHAR _s_szValueName[]; 97 | }; 98 | 99 | #endif DISPLAYATTRIBUTEINFO_H 100 | -------------------------------------------------------------------------------- /CompositionStringUnderline/DisplayAttributeProvider.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // DisplayAttribureProvider.cpp 11 | // 12 | // ITfDisplayAttributeProvider implementation. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | #include "TextService.h" 18 | #include "DisplayAttributeInfo.h" 19 | #include "EnumDisplayAttributeInfo.h" 20 | 21 | //+--------------------------------------------------------------------------- 22 | // 23 | // EnumDisplayAttributeInfo 24 | // 25 | //---------------------------------------------------------------------------- 26 | 27 | STDAPI CTextService::EnumDisplayAttributeInfo(IEnumTfDisplayAttributeInfo **ppEnum) 28 | { 29 | CEnumDisplayAttributeInfo *pAttributeEnum; 30 | 31 | if (ppEnum == NULL) 32 | return E_INVALIDARG; 33 | 34 | *ppEnum = NULL; 35 | 36 | if ((pAttributeEnum = new CEnumDisplayAttributeInfo) == NULL) 37 | return E_OUTOFMEMORY; 38 | 39 | *ppEnum = pAttributeEnum; 40 | 41 | return S_OK; 42 | } 43 | 44 | //+--------------------------------------------------------------------------- 45 | // 46 | // GetDisplayAttributeInfo 47 | // 48 | //---------------------------------------------------------------------------- 49 | 50 | STDAPI CTextService::GetDisplayAttributeInfo(REFGUID guidInfo, ITfDisplayAttributeInfo **ppInfo) 51 | { 52 | if (ppInfo == NULL) 53 | return E_INVALIDARG; 54 | 55 | *ppInfo = NULL; 56 | 57 | // Which display attribute GUID? 58 | if (IsEqualGUID(guidInfo, c_guidDisplayAttributeInput)) 59 | { 60 | if ((*ppInfo = new CDisplayAttributeInfoInput()) == NULL) 61 | return E_OUTOFMEMORY; 62 | } 63 | else if (IsEqualGUID(guidInfo, c_guidDisplayAttributeConverted)) 64 | { 65 | if ((*ppInfo = new CDisplayAttributeInfoConverted()) == NULL) 66 | return E_OUTOFMEMORY; 67 | } 68 | else 69 | { 70 | return E_INVALIDARG; 71 | } 72 | 73 | 74 | return S_OK; 75 | } 76 | -------------------------------------------------------------------------------- /CompositionStringUnderline/DllMain.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // DllMain.cpp 11 | // 12 | // DllMain module entry point. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "Globals.h" 17 | 18 | //+--------------------------------------------------------------------------- 19 | // 20 | // DllMain 21 | // 22 | //---------------------------------------------------------------------------- 23 | 24 | BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID pvReserved) 25 | { 26 | switch (dwReason) 27 | { 28 | case DLL_PROCESS_ATTACH: 29 | 30 | g_hInst = hInstance; 31 | 32 | if (!InitializeCriticalSectionAndSpinCount(&g_cs, 0)) 33 | return FALSE; 34 | 35 | break; 36 | 37 | case DLL_PROCESS_DETACH: 38 | 39 | DeleteCriticalSection(&g_cs); 40 | 41 | break; 42 | } 43 | 44 | return TRUE; 45 | } 46 | -------------------------------------------------------------------------------- /CompositionStringUnderline/EditSession.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // EditSession.h 11 | // 12 | // CEditSessionBase declaration. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef EDITSESSION_H 17 | #define EDITSESSION_H 18 | 19 | #include "TextService.h" 20 | 21 | class CEditSessionBase : public ITfEditSession 22 | { 23 | public: 24 | CEditSessionBase(CTextService *pTextService, ITfContext *pContext) 25 | { 26 | _cRef = 1; 27 | _pContext = pContext; 28 | _pContext->AddRef(); 29 | 30 | _pTextService = pTextService; 31 | _pTextService->AddRef(); 32 | } 33 | virtual ~CEditSessionBase() 34 | { 35 | _pContext->Release(); 36 | _pTextService->Release(); 37 | } 38 | 39 | // IUnknown 40 | STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj) 41 | { 42 | if (ppvObj == NULL) 43 | return E_INVALIDARG; 44 | 45 | *ppvObj = NULL; 46 | 47 | if (IsEqualIID(riid, IID_IUnknown) || 48 | IsEqualIID(riid, IID_ITfEditSession)) 49 | { 50 | *ppvObj = (ITfLangBarItemButton *)this; 51 | } 52 | 53 | if (*ppvObj) 54 | { 55 | AddRef(); 56 | return S_OK; 57 | } 58 | 59 | return E_NOINTERFACE; 60 | } 61 | STDMETHODIMP_(ULONG) AddRef(void) 62 | { 63 | return ++_cRef; 64 | } 65 | STDMETHODIMP_(ULONG) Release(void) 66 | { 67 | LONG cr = --_cRef; 68 | 69 | assert(_cRef >= 0); 70 | 71 | if (_cRef == 0) 72 | { 73 | delete this; 74 | } 75 | 76 | return cr; 77 | } 78 | 79 | // ITfEditSession 80 | virtual STDMETHODIMP DoEditSession(TfEditCookie ec) = 0; 81 | 82 | protected: 83 | ITfContext *_pContext; 84 | CTextService *_pTextService; 85 | 86 | private: 87 | LONG _cRef; // COM ref count 88 | }; 89 | 90 | #endif // EDITSESSION_H 91 | -------------------------------------------------------------------------------- /CompositionStringUnderline/EndComposition.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // EndComposition.cpp 11 | // 12 | // terminate the compositon object 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "Globals.h" 17 | #include "EditSession.h" 18 | #include "TextService.h" 19 | 20 | //+--------------------------------------------------------------------------- 21 | // 22 | // CEndCompositionEditSession 23 | // 24 | //---------------------------------------------------------------------------- 25 | 26 | class CEndCompositionEditSession : public CEditSessionBase 27 | { 28 | public: 29 | CEndCompositionEditSession(CTextService *pTextService, ITfContext *pContext) : CEditSessionBase(pTextService, pContext) 30 | { 31 | } 32 | 33 | // ITfEditSession 34 | STDMETHODIMP DoEditSession(TfEditCookie ec) 35 | { 36 | _pTextService->_TerminateComposition(ec, _pContext); 37 | return S_OK; 38 | } 39 | 40 | }; 41 | 42 | //+--------------------------------------------------------------------------- 43 | // 44 | // _TerminateComposition 45 | // 46 | //---------------------------------------------------------------------------- 47 | 48 | void CTextService::_TerminateComposition(TfEditCookie ec, ITfContext *pContext) 49 | { 50 | if (_pComposition != NULL) 51 | { 52 | // 53 | // remove the display attribute from the composition range. 54 | // 55 | _ClearCompositionDisplayAttributes(ec, pContext); 56 | 57 | _pComposition->EndComposition(ec); 58 | _pComposition->Release(); 59 | _pComposition = NULL; 60 | } 61 | } 62 | 63 | //+--------------------------------------------------------------------------- 64 | // 65 | // _EndComposition 66 | // 67 | //---------------------------------------------------------------------------- 68 | 69 | void CTextService::_EndComposition(ITfContext *pContext) 70 | { 71 | CEndCompositionEditSession *pEditSession; 72 | HRESULT hr; 73 | 74 | if (pEditSession = new CEndCompositionEditSession(this, pContext)) 75 | { 76 | pContext->RequestEditSession(_tfClientId, pEditSession, TF_ES_ASYNCDONTCARE | TF_ES_READWRITE, &hr); 77 | pEditSession->Release(); 78 | } 79 | } 80 | 81 | -------------------------------------------------------------------------------- /CompositionStringUnderline/EnumDisplayAttributeInfo.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // EnumDisplayAttribureInfo.h 11 | // 12 | // ITfEnumDisplayAttributeInfo implementation. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef ENUMDISPLAYATTRIBUTEINFO_H 17 | #define ENUMDISPLAYATTRIBUTEINFO_H 18 | 19 | //+--------------------------------------------------------------------------- 20 | // 21 | // CEnumDisplayAttributeInfo 22 | // 23 | //---------------------------------------------------------------------------- 24 | 25 | class CEnumDisplayAttributeInfo : public IEnumTfDisplayAttributeInfo 26 | { 27 | public: 28 | CEnumDisplayAttributeInfo(); 29 | ~CEnumDisplayAttributeInfo(); 30 | 31 | // IUnknown 32 | STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj); 33 | STDMETHODIMP_(ULONG) AddRef(void); 34 | STDMETHODIMP_(ULONG) Release(void); 35 | 36 | // IEnumTfDisplayAttributeInfo 37 | STDMETHODIMP Clone(IEnumTfDisplayAttributeInfo **ppEnum); 38 | STDMETHODIMP Next(ULONG ulCount, ITfDisplayAttributeInfo **rgInfo, ULONG *pcFetched); 39 | STDMETHODIMP Reset(); 40 | STDMETHODIMP Skip(ULONG ulCount); 41 | 42 | private: 43 | LONG _iIndex; // next display attribute to enum 44 | LONG _cRef; // COM ref count 45 | }; 46 | 47 | #endif ENUMDISPLAYATTRIBUTEINFO_H 48 | -------------------------------------------------------------------------------- /CompositionStringUnderline/Globals.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Globals.cpp 11 | // 12 | // Global variables 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | 18 | HINSTANCE g_hInst; 19 | 20 | LONG g_cRefDll = -1; // -1 /w no refs, for win95 InterlockedIncrement/Decrement compat 21 | 22 | CRITICAL_SECTION g_cs; 23 | 24 | /* e7ea138e-69f8-11d7-a6ea-00065b84435c */ 25 | const CLSID c_clsidTextService = { 26 | 0xe7ea138e, 27 | 0x69f8, 28 | 0x11d7, 29 | {0xa6, 0xea, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 30 | }; 31 | /* e7ea138f-69f8-11d7-a6ea-00065b84435c */ 32 | const GUID c_guidProfile = { 33 | 0xe7ea138f, 34 | 0x69f8, 35 | 0x11d7, 36 | {0xa6, 0xea, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 37 | }; 38 | /* 41f46e67-86d5-49fb-a1d9-3dc0941a66a3 */ 39 | const GUID c_guidLangBarItemButton = { 40 | 0x41f46e67, 41 | 0x86d5, 42 | 0x49fb, 43 | {0xa1, 0xd9, 0x3d, 0xc0, 0x94, 0x1a, 0x66, 0xa3} 44 | }; 45 | 46 | 47 | // 48 | // define two guids for display attribute info. This textservice has 49 | // two display attribute. One is for input text and the other is for the 50 | // converted text. 51 | // 52 | // c_guidDisplayAttributeInput 53 | // c_guidDisplayAttributeConverted 54 | // 55 | /* 4e1aa3fe-6c7f-11d7-a6ec-00065b84435c */ 56 | const GUID c_guidDisplayAttributeInput = { 57 | 0x4e1aa3fe, 58 | 0x6c7f, 59 | 0x11d7, 60 | {0xa6, 0xec, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 61 | }; 62 | /* 4e1aa3ff-6c7f-11d7-a6ec-00065b84435c */ 63 | const GUID c_guidDisplayAttributeConverted = { 64 | 0x4e1aa3ff, 65 | 0x6c7f, 66 | 0x11d7, 67 | {0xa6, 0xec, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 68 | }; 69 | 70 | -------------------------------------------------------------------------------- /CompositionStringUnderline/Globals.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Globals.h 11 | // 12 | // Global variable declarations. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef GLOBALS_H 17 | #define GLOBALS_H 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include "msctf.h" 24 | 25 | void DllAddRef(); 26 | void DllRelease(); 27 | 28 | #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0])) 29 | 30 | #define TEXTSERVICE_LANGID MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT) 31 | 32 | #define TEXTSERVICE_DESC L"Sample Text Service" 33 | #define TEXTSERVICE_DESC_A "Sample Text Service" 34 | #define TEXTSERVICE_MODEL TEXT("Apartment") 35 | 36 | #define TEXTSERVICE_ICON_INDEX 0 37 | #define LANGBAR_ITEM_DESC L"Sample Text Service Button" 38 | 39 | //+--------------------------------------------------------------------------- 40 | // 41 | // SafeStringCopy 42 | // 43 | // Copies a string from one buffer to another. wcsncpy does not always 44 | // null-terminate the destination buffer; this function does. 45 | //---------------------------------------------------------------------------- 46 | 47 | inline void SafeStringCopy(WCHAR *pchDst, ULONG cchMax, const WCHAR *pchSrc) 48 | { 49 | if (cchMax > 0) 50 | { 51 | wcsncpy(pchDst, pchSrc, cchMax); 52 | pchDst[cchMax-1] = '\0'; 53 | } 54 | } 55 | 56 | extern HINSTANCE g_hInst; 57 | 58 | extern LONG g_cRefDll; 59 | 60 | extern CRITICAL_SECTION g_cs; 61 | 62 | extern const CLSID c_clsidTextService; 63 | 64 | extern const GUID c_guidProfile; 65 | 66 | extern const GUID c_guidLangBarItemButton; 67 | 68 | extern const GUID c_guidDisplayAttributeInput; 69 | extern const GUID c_guidDisplayAttributeConverted; 70 | 71 | #endif // GLOBALS_H 72 | -------------------------------------------------------------------------------- /CompositionStringUnderline/PreComp.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // PreComp.cpp 11 | // 12 | // Stub for vc precompiled header. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | -------------------------------------------------------------------------------- /CompositionStringUnderline/Resource.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Resource.h 11 | // 12 | // Resource declarations. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef RESOURCE_H 17 | #define RESOURCE_H 18 | 19 | // #define IDI_TEXTSERVICE 0 20 | 21 | #endif // RESOURCE_H 22 | -------------------------------------------------------------------------------- /CompositionStringUnderline/TextService.def: -------------------------------------------------------------------------------- 1 | LIBRARY TextService.dll 2 | 3 | EXPORTS 4 | DllGetClassObject PRIVATE 5 | DllCanUnloadNow PRIVATE 6 | DllRegisterServer PRIVATE 7 | DllUnregisterServer PRIVATE 8 | -------------------------------------------------------------------------------- /CompositionStringUnderline/TextService.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/CompositionStringUnderline/TextService.ico -------------------------------------------------------------------------------- /CompositionStringUnderline/TextService.rc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // TextService.rc 11 | // 12 | // Resources. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | 17 | IDI_TEXTSERVICE ICON TextService.ico 18 | 19 | -------------------------------------------------------------------------------- /CompositionStringUnderline/compositionstring.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/CompositionStringUnderline/compositionstring.JPG -------------------------------------------------------------------------------- /CompositionStringUnderline/compositionstring2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/CompositionStringUnderline/compositionstring2.jpg -------------------------------------------------------------------------------- /CompositionStringUnderline/compositionstring3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/CompositionStringUnderline/compositionstring3.jpg -------------------------------------------------------------------------------- /CompositionStringUnderline/default.asp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/CompositionStringUnderline/default.asp -------------------------------------------------------------------------------- /CompositionStringUnderline/sample.asp: -------------------------------------------------------------------------------- 1 | <% response.redirect "default.asp" %> 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /IconInLanguageBar.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/IconInLanguageBar.zip -------------------------------------------------------------------------------- /IconInLanguageBar/DllMain.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // DllMain.cpp 11 | // 12 | // DllMain module entry point. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "Globals.h" 17 | 18 | //+--------------------------------------------------------------------------- 19 | // 20 | // DllMain 21 | // 22 | //---------------------------------------------------------------------------- 23 | 24 | BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID pvReserved) 25 | { 26 | switch (dwReason) 27 | { 28 | case DLL_PROCESS_ATTACH: 29 | 30 | g_hInst = hInstance; 31 | 32 | if (!InitializeCriticalSectionAndSpinCount(&g_cs, 0)) 33 | return FALSE; 34 | 35 | break; 36 | 37 | case DLL_PROCESS_DETACH: 38 | 39 | DeleteCriticalSection(&g_cs); 40 | 41 | break; 42 | } 43 | 44 | return TRUE; 45 | } 46 | -------------------------------------------------------------------------------- /IconInLanguageBar/Globals.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Globals.cpp 11 | // 12 | // Global variables 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | 18 | HINSTANCE g_hInst; 19 | 20 | LONG g_cRefDll = -1; // -1 /w no refs, for win95 InterlockedIncrement/Decrement compat 21 | 22 | CRITICAL_SECTION g_cs; 23 | 24 | /* e7ea138e-69f8-11d7-a6ea-00065b84435c */ 25 | const CLSID c_clsidTextService = { 26 | 0xe7ea138e, 27 | 0x69f8, 28 | 0x11d7, 29 | {0xa6, 0xea, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 30 | }; 31 | /* e7ea138f-69f8-11d7-a6ea-00065b84435c */ 32 | const GUID c_guidProfile = { 33 | 0xe7ea138f, 34 | 0x69f8, 35 | 0x11d7, 36 | {0xa6, 0xea, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 37 | }; 38 | /* 41f46e67-86d5-49fb-a1d9-3dc0941a66a3 */ 39 | const GUID c_guidLangBarItemButton = { 40 | 0x41f46e67, 41 | 0x86d5, 42 | 0x49fb, 43 | {0xa1, 0xd9, 0x3d, 0xc0, 0x94, 0x1a, 0x66, 0xa3} 44 | }; 45 | 46 | -------------------------------------------------------------------------------- /IconInLanguageBar/Globals.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Globals.h 11 | // 12 | // Global variable declarations. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef GLOBALS_H 17 | #define GLOBALS_H 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include "msctf.h" 24 | 25 | void DllAddRef(); 26 | void DllRelease(); 27 | 28 | #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0])) 29 | 30 | #define TEXTSERVICE_LANGID MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US) 31 | 32 | #define TEXTSERVICE_DESC L"Sample Text Service" 33 | #define TEXTSERVICE_DESC_A "Sample Text Service" 34 | #define TEXTSERVICE_MODEL TEXT("Apartment") 35 | 36 | #define TEXTSERVICE_ICON_INDEX 0 37 | #define LANGBAR_ITEM_DESC L"Sample Text Service Button" 38 | 39 | //+--------------------------------------------------------------------------- 40 | // 41 | // SafeStringCopy 42 | // 43 | // Copies a string from one buffer to another. wcsncpy does not always 44 | // null-terminate the destination buffer; this function does. 45 | //---------------------------------------------------------------------------- 46 | 47 | inline void SafeStringCopy(WCHAR *pchDst, ULONG cchMax, const WCHAR *pchSrc) 48 | { 49 | if (cchMax > 0) 50 | { 51 | wcsncpy(pchDst, pchSrc, cchMax); 52 | pchDst[cchMax-1] = '\0'; 53 | } 54 | } 55 | 56 | extern HINSTANCE g_hInst; 57 | 58 | extern LONG g_cRefDll; 59 | 60 | extern CRITICAL_SECTION g_cs; 61 | 62 | extern const CLSID c_clsidTextService; 63 | 64 | extern const GUID c_guidProfile; 65 | 66 | extern const GUID c_guidLangBarItemButton; 67 | 68 | 69 | #endif // GLOBALS_H 70 | -------------------------------------------------------------------------------- /IconInLanguageBar/PreComp.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // PreComp.cpp 11 | // 12 | // Stub for vc precompiled header. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | -------------------------------------------------------------------------------- /IconInLanguageBar/Resource.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Resource.h 11 | // 12 | // Resource declarations. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef RESOURCE_H 17 | #define RESOURCE_H 18 | 19 | // #define IDI_TEXTSERVICE 0 20 | 21 | #endif // RESOURCE_H 22 | -------------------------------------------------------------------------------- /IconInLanguageBar/TextService.def: -------------------------------------------------------------------------------- 1 | LIBRARY TextService.dll 2 | 3 | EXPORTS 4 | DllGetClassObject PRIVATE 5 | DllCanUnloadNow PRIVATE 6 | DllRegisterServer PRIVATE 7 | DllUnregisterServer PRIVATE 8 | -------------------------------------------------------------------------------- /IconInLanguageBar/TextService.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // TextService.h 11 | // 12 | // CTextService declaration. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef TEXTSERVICE_H 17 | #define TEXTSERVICE_H 18 | 19 | class CLangBarItemButton; 20 | 21 | class CTextService : public ITfTextInputProcessor, 22 | public ITfThreadMgrEventSink, 23 | public ITfTextEditSink 24 | { 25 | public: 26 | CTextService(); 27 | ~CTextService(); 28 | 29 | // IUnknown 30 | STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj); 31 | STDMETHODIMP_(ULONG) AddRef(void); 32 | STDMETHODIMP_(ULONG) Release(void); 33 | 34 | // ITfTextInputProcessor 35 | STDMETHODIMP Activate(ITfThreadMgr *pThreadMgr, TfClientId tfClientId); 36 | STDMETHODIMP Deactivate(); 37 | 38 | // ITfThreadMgrEventSink 39 | STDMETHODIMP OnInitDocumentMgr(ITfDocumentMgr *pDocMgr); 40 | STDMETHODIMP OnUninitDocumentMgr(ITfDocumentMgr *pDocMgr); 41 | STDMETHODIMP OnSetFocus(ITfDocumentMgr *pDocMgrFocus, ITfDocumentMgr *pDocMgrPrevFocus); 42 | STDMETHODIMP OnPushContext(ITfContext *pContext); 43 | STDMETHODIMP OnPopContext(ITfContext *pContext); 44 | 45 | // ITfTextEditSink 46 | STDMETHODIMP OnEndEdit(ITfContext *pContext, TfEditCookie ecReadOnly, ITfEditRecord *pEditRecord); 47 | 48 | // CClassFactory factory callback 49 | static HRESULT CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObj); 50 | 51 | ITfThreadMgr *_GetThreadMgr() { return _pThreadMgr; } 52 | 53 | private: 54 | // initialize and uninitialize ThreadMgrEventSink. 55 | BOOL _InitThreadMgrEventSink(); 56 | void _UninitThreadMgrEventSink(); 57 | 58 | // initialize TextEditSink. 59 | BOOL _InitTextEditSink(ITfDocumentMgr *pDocMgr); 60 | 61 | // initialize and uninitialize LanguageBar Item. 62 | BOOL _InitLanguageBar(); 63 | void _UninitLanguageBar(); 64 | 65 | // 66 | // state 67 | // 68 | ITfThreadMgr *_pThreadMgr; 69 | 70 | // The cookie of ThreadMgrEventSink 71 | DWORD _dwThreadMgrEventSinkCookie; 72 | 73 | // 74 | // private variables for TextEditSink 75 | // 76 | ITfContext *_pTextEditSinkContext; 77 | DWORD _dwTextEditSinkCookie; 78 | 79 | CLangBarItemButton *_pLangBarItem; 80 | 81 | LONG _cRef; // COM ref count 82 | }; 83 | 84 | 85 | #endif // TEXTSERVICE_H 86 | -------------------------------------------------------------------------------- /IconInLanguageBar/TextService.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/IconInLanguageBar/TextService.ico -------------------------------------------------------------------------------- /IconInLanguageBar/TextService.rc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // TextService.rc 11 | // 12 | // Resources. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | 17 | IDI_TEXTSERVICE ICON TextService.ico 18 | 19 | -------------------------------------------------------------------------------- /IconInLanguageBar/TextServiceCP2.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/IconInLanguageBar/TextServiceCP2.JPG -------------------------------------------------------------------------------- /IconInLanguageBar/TextServiceLangBar.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/IconInLanguageBar/TextServiceLangBar.JPG -------------------------------------------------------------------------------- /IconInLanguageBar/default.asp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/IconInLanguageBar/default.asp -------------------------------------------------------------------------------- /IconInLanguageBar/makefile: -------------------------------------------------------------------------------- 1 | #----- set the project name -------------------------------------------------------------- 2 | Proj = TextService 3 | 4 | #----- Include the PSDK's WIN32.MAK to pick up defines ----------------------------------- 5 | !include 6 | 7 | #----- OUTDIR is defined in WIN32.MAK This is the name of the destination directory ------ 8 | all: $(OUTDIR)\$(Proj).dll 9 | 10 | LINK32_OBJS= \ 11 | $(OUTDIR)\TextService.obj \ 12 | $(OUTDIR)\ThreadMgrEventSink.obj \ 13 | $(OUTDIR)\TextEditSink.obj \ 14 | $(OUTDIR)\LanguageBar.obj \ 15 | $(OUTDIR)\Dllmain.obj \ 16 | $(OUTDIR)\Globals.obj \ 17 | $(OUTDIR)\PreComp.obj \ 18 | $(OUTDIR)\Register.obj \ 19 | $(OUTDIR)\Server.obj 20 | 21 | #----- If OUTDIR does not exist, then create directory 22 | $(OUTDIR) : 23 | if not exist "$(OUTDIR)/$(NULL)" mkdir $(OUTDIR) 24 | 25 | #----- add the preprocessor definitions needed by this project --------------------------- 26 | 27 | #----- set the libraries needed by this project ------------------------------------------ 28 | LINK_LIBS = $(dlllibs) $(guilibs) $(olelibs) 29 | 30 | #--------------------- DLL --------------------------------------------------------------- 31 | #PLEASE REFER TO WIN32.MAK for the different Linker options WIN32.MAK provides 32 | 33 | # Build rule for DLL 34 | $(OUTDIR)\$(Proj).dll: $(OUTDIR) $(LINK32_OBJS) $(OUTDIR)\$(Proj).res 35 | $(link) $(ldebug) $(dllllflags) \ 36 | $(LINK32_OBJS) $(OUTDIR)\$(Proj).res $(LINK_LIBS) \ 37 | -base:0x20000000 \ 38 | -out:$(OUTDIR)\$(Proj).dll \ 39 | -def:$(Proj).def 40 | 41 | #--------------------- Compiling C/CPP Files --------------------------------------------- 42 | #PLEASE REFER TO WIN32.MAK for the different Compiler options WIN32.MAK provides 43 | 44 | FILE=TextService 45 | 46 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 47 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 48 | 49 | FILE=ThreadMgrEventSink 50 | 51 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 52 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 53 | 54 | FILE=TextEditSink 55 | 56 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 57 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 58 | 59 | FILE=LanguageBar 60 | 61 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 62 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 63 | 64 | FILE=Dllmain 65 | 66 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 67 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 68 | 69 | FILE=Globals 70 | 71 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 72 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 73 | 74 | FILE=Precomp 75 | 76 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 77 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 78 | 79 | FILE=Register 80 | 81 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 82 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 83 | 84 | FILE=Server 85 | 86 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 87 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 88 | 89 | 90 | #--------------------- Compiling Resource Files ------------------------------------------ 91 | #PLEASE REFER TO WIN32.MAK for the different Resource Compiler options WIN32.MAK provides 92 | 93 | # Build rule for resource file 94 | FILE=TextService 95 | 96 | $(OUTDIR)\$(FILE).res: .\$(FILE).rc $(OUTDIR) 97 | $(rc) $(rcflags) $(rcvars) /fo $(OUTDIR)\$(FILE).res .\$(FILE).rc 98 | 99 | #--------------------- Clean Rule -------------------------------------------------------- 100 | # Rules for cleaning out those old files 101 | clean: 102 | $(CLEANUP) 103 | -------------------------------------------------------------------------------- /IconInLanguageBar/sample.asp: -------------------------------------------------------------------------------- 1 | <% response.redirect "default.asp" %> 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Keyboard.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/Keyboard.zip -------------------------------------------------------------------------------- /Keyboard/DllMain.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // DllMain.cpp 11 | // 12 | // DllMain module entry point. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "Globals.h" 17 | 18 | //+--------------------------------------------------------------------------- 19 | // 20 | // DllMain 21 | // 22 | //---------------------------------------------------------------------------- 23 | 24 | BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID pvReserved) 25 | { 26 | switch (dwReason) 27 | { 28 | case DLL_PROCESS_ATTACH: 29 | 30 | g_hInst = hInstance; 31 | 32 | if (!InitializeCriticalSectionAndSpinCount(&g_cs, 0)) 33 | return FALSE; 34 | 35 | break; 36 | 37 | case DLL_PROCESS_DETACH: 38 | 39 | DeleteCriticalSection(&g_cs); 40 | 41 | break; 42 | } 43 | 44 | return TRUE; 45 | } 46 | -------------------------------------------------------------------------------- /Keyboard/Globals.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Globals.cpp 11 | // 12 | // Global variables 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | 18 | HINSTANCE g_hInst; 19 | 20 | LONG g_cRefDll = -1; // -1 /w no refs, for win95 InterlockedIncrement/Decrement compat 21 | 22 | CRITICAL_SECTION g_cs; 23 | 24 | /* e7ea138e-69f8-11d7-a6ea-00065b84435c */ 25 | const CLSID c_clsidTextService = { 26 | 0xe7ea138e, 27 | 0x69f8, 28 | 0x11d7, 29 | {0xa6, 0xea, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 30 | }; 31 | /* e7ea138f-69f8-11d7-a6ea-00065b84435c */ 32 | const GUID c_guidProfile = { 33 | 0xe7ea138f, 34 | 0x69f8, 35 | 0x11d7, 36 | {0xa6, 0xea, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 37 | }; 38 | /* 41f46e67-86d5-49fb-a1d9-3dc0941a66a3 */ 39 | const GUID c_guidLangBarItemButton = { 40 | 0x41f46e67, 41 | 0x86d5, 42 | 0x49fb, 43 | {0xa1, 0xd9, 0x3d, 0xc0, 0x94, 0x1a, 0x66, 0xa3} 44 | }; 45 | 46 | -------------------------------------------------------------------------------- /Keyboard/Globals.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Globals.h 11 | // 12 | // Global variable declarations. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef GLOBALS_H 17 | #define GLOBALS_H 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include "msctf.h" 24 | 25 | void DllAddRef(); 26 | void DllRelease(); 27 | 28 | #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0])) 29 | 30 | #define TEXTSERVICE_LANGID MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT) 31 | 32 | #define TEXTSERVICE_DESC L"Sample Text Service" 33 | #define TEXTSERVICE_DESC_A "Sample Text Service" 34 | #define TEXTSERVICE_MODEL TEXT("Apartment") 35 | 36 | #define TEXTSERVICE_ICON_INDEX 0 37 | #define LANGBAR_ITEM_DESC L"Sample Text Service Button" 38 | 39 | //+--------------------------------------------------------------------------- 40 | // 41 | // SafeStringCopy 42 | // 43 | // Copies a string from one buffer to another. wcsncpy does not always 44 | // null-terminate the destination buffer; this function does. 45 | //---------------------------------------------------------------------------- 46 | 47 | inline void SafeStringCopy(WCHAR *pchDst, ULONG cchMax, const WCHAR *pchSrc) 48 | { 49 | if (cchMax > 0) 50 | { 51 | wcsncpy(pchDst, pchSrc, cchMax); 52 | pchDst[cchMax-1] = '\0'; 53 | } 54 | } 55 | 56 | extern HINSTANCE g_hInst; 57 | 58 | extern LONG g_cRefDll; 59 | 60 | extern CRITICAL_SECTION g_cs; 61 | 62 | extern const CLSID c_clsidTextService; 63 | 64 | extern const GUID c_guidProfile; 65 | 66 | extern const GUID c_guidLangBarItemButton; 67 | 68 | 69 | #endif // GLOBALS_H 70 | -------------------------------------------------------------------------------- /Keyboard/JapaneseTextServiceCP.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/Keyboard/JapaneseTextServiceCP.JPG -------------------------------------------------------------------------------- /Keyboard/LangBarOpenCloseDisable.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/Keyboard/LangBarOpenCloseDisable.JPG -------------------------------------------------------------------------------- /Keyboard/PreComp.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // PreComp.cpp 11 | // 12 | // Stub for vc precompiled header. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | -------------------------------------------------------------------------------- /Keyboard/Resource.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Resource.h 11 | // 12 | // Resource declarations. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef RESOURCE_H 17 | #define RESOURCE_H 18 | 19 | // #define IDI_TEXTSERVICE 0 20 | 21 | #endif // RESOURCE_H 22 | -------------------------------------------------------------------------------- /Keyboard/TextEditSink.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // TextEditSink.cpp 11 | // 12 | // ITfTextEditSink implementation. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | #include "TextService.h" 18 | 19 | //+--------------------------------------------------------------------------- 20 | // 21 | // OnEndEdit 22 | // 23 | // Called by the system whenever anyone releases a write-access document lock. 24 | //---------------------------------------------------------------------------- 25 | 26 | STDAPI CTextService::OnEndEdit(ITfContext *pContext, TfEditCookie ecReadOnly, ITfEditRecord *pEditRecord) 27 | { 28 | BOOL fSelectionChanged; 29 | IEnumTfRanges *pEnumTextChanges; 30 | ITfRange *pRange; 31 | 32 | // 33 | // did the selection change? 34 | // The selection change includes the movement of caret as well. 35 | // The caret position is represent as the empty selection range when 36 | // there is no selection. 37 | // 38 | if (pEditRecord->GetSelectionStatus(&fSelectionChanged) == S_OK && 39 | fSelectionChanged) 40 | { 41 | } 42 | 43 | // text modification? 44 | if (pEditRecord->GetTextAndPropertyUpdates(TF_GTP_INCL_TEXT, NULL, 0, &pEnumTextChanges) == S_OK) 45 | { 46 | if (pEnumTextChanges->Next(1, &pRange, NULL) == S_OK) 47 | { 48 | // 49 | // pRange is the updated range. 50 | // 51 | 52 | pRange->Release(); 53 | } 54 | 55 | pEnumTextChanges->Release(); 56 | } 57 | 58 | return S_OK; 59 | } 60 | 61 | //+--------------------------------------------------------------------------- 62 | // 63 | // _InitTextEditSink 64 | // 65 | // Init a text edit sink on the topmost context of the document. 66 | // Always release any previous sink. 67 | //---------------------------------------------------------------------------- 68 | 69 | BOOL CTextService::_InitTextEditSink(ITfDocumentMgr *pDocMgr) 70 | { 71 | ITfSource *pSource; 72 | BOOL fRet; 73 | 74 | // clear out any previous sink first 75 | 76 | if (_dwTextEditSinkCookie != TF_INVALID_COOKIE) 77 | { 78 | if (_pTextEditSinkContext->QueryInterface(IID_ITfSource, (void **)&pSource) == S_OK) 79 | { 80 | pSource->UnadviseSink(_dwTextEditSinkCookie); 81 | pSource->Release(); 82 | } 83 | 84 | _pTextEditSinkContext->Release(); 85 | _pTextEditSinkContext = NULL; 86 | _dwTextEditSinkCookie = TF_INVALID_COOKIE; 87 | } 88 | 89 | if (pDocMgr == NULL) 90 | return TRUE; // caller just wanted to clear the previous sink 91 | 92 | // setup a new sink advised to the topmost context of the document 93 | 94 | if (pDocMgr->GetTop(&_pTextEditSinkContext) != S_OK) 95 | return FALSE; 96 | 97 | if (_pTextEditSinkContext == NULL) 98 | return TRUE; // empty document, no sink possible 99 | 100 | fRet = FALSE; 101 | 102 | if (_pTextEditSinkContext->QueryInterface(IID_ITfSource, (void **)&pSource) == S_OK) 103 | { 104 | if (pSource->AdviseSink(IID_ITfTextEditSink, (ITfTextEditSink *)this, &_dwTextEditSinkCookie) == S_OK) 105 | { 106 | fRet = TRUE; 107 | } 108 | else 109 | { 110 | _dwTextEditSinkCookie = TF_INVALID_COOKIE; 111 | } 112 | pSource->Release(); 113 | } 114 | 115 | if (fRet == FALSE) 116 | { 117 | _pTextEditSinkContext->Release(); 118 | _pTextEditSinkContext = NULL; 119 | } 120 | 121 | return fRet; 122 | } 123 | -------------------------------------------------------------------------------- /Keyboard/TextService.def: -------------------------------------------------------------------------------- 1 | LIBRARY TextService.dll 2 | 3 | EXPORTS 4 | DllGetClassObject PRIVATE 5 | DllCanUnloadNow PRIVATE 6 | DllRegisterServer PRIVATE 7 | DllUnregisterServer PRIVATE 8 | -------------------------------------------------------------------------------- /Keyboard/TextService.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // TextService.h 11 | // 12 | // CTextService declaration. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef TEXTSERVICE_H 17 | #define TEXTSERVICE_H 18 | 19 | class CLangBarItemButton; 20 | 21 | class CTextService : public ITfTextInputProcessor, 22 | public ITfThreadMgrEventSink, 23 | public ITfTextEditSink, 24 | public ITfKeyEventSink 25 | { 26 | public: 27 | CTextService(); 28 | ~CTextService(); 29 | 30 | // IUnknown 31 | STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj); 32 | STDMETHODIMP_(ULONG) AddRef(void); 33 | STDMETHODIMP_(ULONG) Release(void); 34 | 35 | // ITfTextInputProcessor 36 | STDMETHODIMP Activate(ITfThreadMgr *pThreadMgr, TfClientId tfClientId); 37 | STDMETHODIMP Deactivate(); 38 | 39 | // ITfThreadMgrEventSink 40 | STDMETHODIMP OnInitDocumentMgr(ITfDocumentMgr *pDocMgr); 41 | STDMETHODIMP OnUninitDocumentMgr(ITfDocumentMgr *pDocMgr); 42 | STDMETHODIMP OnSetFocus(ITfDocumentMgr *pDocMgrFocus, ITfDocumentMgr *pDocMgrPrevFocus); 43 | STDMETHODIMP OnPushContext(ITfContext *pContext); 44 | STDMETHODIMP OnPopContext(ITfContext *pContext); 45 | 46 | // ITfTextEditSink 47 | STDMETHODIMP OnEndEdit(ITfContext *pContext, TfEditCookie ecReadOnly, ITfEditRecord *pEditRecord); 48 | 49 | // ITfKeyEventSink 50 | STDMETHODIMP OnSetFocus(BOOL fForeground); 51 | STDMETHODIMP OnTestKeyDown(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pfEaten); 52 | STDMETHODIMP OnKeyDown(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pfEaten); 53 | STDMETHODIMP OnTestKeyUp(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pfEaten); 54 | STDMETHODIMP OnKeyUp(ITfContext *pContext, WPARAM wParam, LPARAM lParam, BOOL *pfEaten); 55 | STDMETHODIMP OnPreservedKey(ITfContext *pContext, REFGUID rguid, BOOL *pfEaten); 56 | 57 | // CClassFactory factory callback 58 | static HRESULT CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObj); 59 | 60 | ITfThreadMgr *_GetThreadMgr() { return _pThreadMgr; } 61 | 62 | // utility function for compartment 63 | BOOL _IsKeyboardDisabled(); 64 | BOOL _IsKeyboardOpen(); 65 | HRESULT _SetKeyboardOpen(BOOL fOpen); 66 | 67 | private: 68 | // initialize and uninitialize ThreadMgrEventSink. 69 | BOOL _InitThreadMgrEventSink(); 70 | void _UninitThreadMgrEventSink(); 71 | 72 | // initialize TextEditSink. 73 | BOOL _InitTextEditSink(ITfDocumentMgr *pDocMgr); 74 | 75 | // initialize and uninitialize LanguageBar Item. 76 | BOOL _InitLanguageBar(); 77 | void _UninitLanguageBar(); 78 | 79 | // initialize and uninitialize KeyEventSink. 80 | BOOL _InitKeyEventSink(); 81 | void _UninitKeyEventSink(); 82 | 83 | // initialize and uninitialize PreservedKey. 84 | BOOL _InitPreservedKey(); 85 | void _UninitPreservedKey(); 86 | 87 | // utility function for KeyEventSink 88 | BOOL _IsKeyEaten(WPARAM wParam); 89 | 90 | // 91 | // state 92 | // 93 | ITfThreadMgr *_pThreadMgr; 94 | TfClientId _tfClientId; 95 | 96 | // The cookie of ThreadMgrEventSink 97 | DWORD _dwThreadMgrEventSinkCookie; 98 | 99 | // 100 | // private variables for TextEditSink 101 | // 102 | ITfContext *_pTextEditSinkContext; 103 | DWORD _dwTextEditSinkCookie; 104 | 105 | CLangBarItemButton *_pLangBarItem; 106 | 107 | LONG _cRef; // COM ref count 108 | }; 109 | 110 | 111 | #endif // TEXTSERVICE_H 112 | -------------------------------------------------------------------------------- /Keyboard/TextService.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/Keyboard/TextService.ico -------------------------------------------------------------------------------- /Keyboard/TextService.rc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // TextService.rc 11 | // 12 | // Resources. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | 17 | IDI_TEXTSERVICE ICON TextService.ico 18 | 19 | -------------------------------------------------------------------------------- /Keyboard/default.asp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/Keyboard/default.asp -------------------------------------------------------------------------------- /Keyboard/sample.asp: -------------------------------------------------------------------------------- 1 | <% response.redirect "default.asp" %> 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /PropertyMonitor.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/PropertyMonitor.zip -------------------------------------------------------------------------------- /PropertyMonitor/DllMain.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // DllMain.cpp 11 | // 12 | // DllMain module entry point. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "Globals.h" 17 | #include "PopupWindow.h" 18 | 19 | //+--------------------------------------------------------------------------- 20 | // 21 | // DllMain 22 | // 23 | //---------------------------------------------------------------------------- 24 | 25 | BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID pvReserved) 26 | { 27 | switch (dwReason) 28 | { 29 | case DLL_PROCESS_ATTACH: 30 | 31 | g_hInst = hInstance; 32 | 33 | if (!InitializeCriticalSectionAndSpinCount(&g_cs, 0)) 34 | return FALSE; 35 | 36 | CPropertyPopupWindow::StaticInit(); 37 | 38 | break; 39 | 40 | case DLL_PROCESS_DETACH: 41 | 42 | DeleteCriticalSection(&g_cs); 43 | 44 | break; 45 | } 46 | 47 | return TRUE; 48 | } 49 | -------------------------------------------------------------------------------- /PropertyMonitor/EditSession.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // EditSession.h 11 | // 12 | // CEditSessionBase declaration. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef EDITSESSION_H 17 | #define EDITSESSION_H 18 | 19 | #include "TextService.h" 20 | 21 | class CEditSessionBase : public ITfEditSession 22 | { 23 | public: 24 | CEditSessionBase(CPropertyMonitorTextService *pTextService, ITfContext *pContext) 25 | { 26 | _cRef = 1; 27 | _pContext = pContext; 28 | _pContext->AddRef(); 29 | 30 | _pTextService = pTextService; 31 | _pTextService->AddRef(); 32 | } 33 | virtual ~CEditSessionBase() 34 | { 35 | _pContext->Release(); 36 | _pTextService->Release(); 37 | } 38 | 39 | // IUnknown 40 | STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj) 41 | { 42 | if (ppvObj == NULL) 43 | return E_INVALIDARG; 44 | 45 | *ppvObj = NULL; 46 | 47 | if (IsEqualIID(riid, IID_IUnknown) || 48 | IsEqualIID(riid, IID_ITfEditSession)) 49 | { 50 | *ppvObj = (ITfLangBarItemButton *)this; 51 | } 52 | 53 | if (*ppvObj) 54 | { 55 | AddRef(); 56 | return S_OK; 57 | } 58 | 59 | return E_NOINTERFACE; 60 | } 61 | STDMETHODIMP_(ULONG) AddRef(void) 62 | { 63 | return ++_cRef; 64 | } 65 | STDMETHODIMP_(ULONG) Release(void) 66 | { 67 | LONG cr = --_cRef; 68 | 69 | assert(_cRef >= 0); 70 | 71 | if (_cRef == 0) 72 | { 73 | delete this; 74 | } 75 | 76 | return cr; 77 | } 78 | 79 | // ITfEditSession 80 | virtual STDMETHODIMP DoEditSession(TfEditCookie ec) = 0; 81 | 82 | protected: 83 | ITfContext *_pContext; 84 | CPropertyMonitorTextService *_pTextService; 85 | 86 | private: 87 | LONG _cRef; // COM ref count 88 | }; 89 | 90 | #endif // EDITSESSION_H 91 | -------------------------------------------------------------------------------- /PropertyMonitor/Globals.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// // 2 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 3 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 4 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 5 | // PARTICULAR PURPOSE. 6 | // 7 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 8 | // 9 | // Globals.cpp 10 | // 11 | // Global variables 12 | // 13 | ////////////////////////////////////////////////////////////////////// 14 | 15 | #include "globals.h" 16 | 17 | HINSTANCE g_hInst; 18 | 19 | LONG g_cRefDll = -1; // -1 /w no refs, for win95 InterlockedIncrement/Decrement compat 20 | 21 | CRITICAL_SECTION g_cs; 22 | 23 | /* 7c3d9fe0-6f60-11d7-a6ee-00065b84435c */ 24 | const CLSID c_clsidPropertyMonitorTextService = { 25 | 0x7c3d9fe0, 26 | 0x6f60, 27 | 0x11d7, 28 | {0xa6, 0xee, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 29 | }; 30 | 31 | /* 7c3d9fe1-6f60-11d7-a6ee-00065b84435c */ 32 | const GUID c_guidProfile = { 33 | 0x7c3d9fe1, 34 | 0x6f60, 35 | 0x11d7, 36 | {0xa6, 0xee, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 37 | }; 38 | 39 | /* 7c3d9fe2-6f60-11d7-a6ee-00065b84435c */ 40 | const GUID c_guidLangBarItemButton = { 41 | 0x7c3d9fe2, 42 | 0x6f60, 43 | 0x11d7, 44 | {0xa6, 0xee, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 45 | }; 46 | -------------------------------------------------------------------------------- /PropertyMonitor/Globals.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Globals.h 11 | // 12 | // Global variable declarations. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef GLOBALS_H 17 | #define GLOBALS_H 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include "msctf.h" 24 | 25 | void DllAddRef(); 26 | void DllRelease(); 27 | 28 | #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0])) 29 | 30 | #define TEXTSERVICE_LANGID (0xFFFF) 31 | 32 | #define TEXTSERVICE_DESC L"Property Monitor" 33 | #define TEXTSERVICE_DESC_A "Property Monitor" 34 | #define TEXTSERVICE_MODEL TEXT("Apartment") 35 | 36 | #define TEXTSERVICE_ICON_INDEX 0 37 | #define LANGBAR_ITEM_DESC L"Property Monitor" 38 | 39 | //+--------------------------------------------------------------------------- 40 | // 41 | // SafeStringCopy 42 | // 43 | // Copies a string from one buffer to another. wcsncpy does not always 44 | // null-terminate the destination buffer; this function does. 45 | //---------------------------------------------------------------------------- 46 | 47 | inline void SafeStringCopy(WCHAR *pchDst, ULONG cchMax, const WCHAR *pchSrc) 48 | { 49 | if (cchMax > 0) 50 | { 51 | wcsncpy(pchDst, pchSrc, cchMax); 52 | pchDst[cchMax-1] = '\0'; 53 | } 54 | } 55 | 56 | extern HINSTANCE g_hInst; 57 | 58 | extern LONG g_cRefDll; 59 | 60 | extern CRITICAL_SECTION g_cs; 61 | 62 | extern const CLSID c_clsidPropertyMonitorTextService; 63 | 64 | extern const GUID c_guidProfile; 65 | 66 | extern const GUID c_guidLangBarItemButton; 67 | 68 | 69 | #endif // GLOBALS_H 70 | -------------------------------------------------------------------------------- /PropertyMonitor/MemoryStream.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // MemoryStream.cpp 11 | // 12 | // IStream Service functions. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "Globals.h" 17 | 18 | //+--------------------------------------------------------------------------- 19 | // 20 | // CreateMemoryStream 21 | // 22 | //---------------------------------------------------------------------------- 23 | 24 | IStream* CreateMemoryStream() 25 | { 26 | LPSTREAM lpStream = NULL; 27 | 28 | // Create a stream object on a memory block. 29 | HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE|GMEM_SHARE, 0); 30 | if (hGlobal != NULL) 31 | { 32 | HRESULT hr ; 33 | if (FAILED(hr = CreateStreamOnHGlobal(hGlobal, TRUE, &lpStream))) 34 | { 35 | GlobalFree(hGlobal); 36 | } 37 | } 38 | 39 | return lpStream; 40 | } 41 | 42 | //+--------------------------------------------------------------------------- 43 | // 44 | // ClearStream 45 | // 46 | //---------------------------------------------------------------------------- 47 | 48 | void ClearStream(IStream *pStream) 49 | { 50 | ULARGE_INTEGER ull; 51 | ull.QuadPart = 0; 52 | pStream->SetSize(ull); 53 | } 54 | 55 | //+--------------------------------------------------------------------------- 56 | // 57 | // AddStringToStream 58 | // 59 | //---------------------------------------------------------------------------- 60 | 61 | void AddStringToStream(IStream *pStream, WCHAR *psz) 62 | { 63 | pStream->Write(psz, lstrlenW(psz) * sizeof(WCHAR), NULL); 64 | } 65 | 66 | -------------------------------------------------------------------------------- /PropertyMonitor/MemoryStream.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // MemoryStream.h 11 | // 12 | // IStream Service functions. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | extern IStream* CreateMemoryStream(); 17 | extern void ClearStream(IStream *pStream); 18 | extern void AddStringToStream(IStream *pStream, WCHAR *psz); 19 | 20 | -------------------------------------------------------------------------------- /PropertyMonitor/PopupWindow.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // PopupWindow.h 11 | // 12 | // CProeprtyPopupWindow 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef POPUPWINDOW_H 17 | #define POPUPWINDOW_H 18 | 19 | 20 | #define POPUP_CX 450 21 | #define POPUP_CY 300 22 | 23 | class CPropertyPopupWindow 24 | { 25 | public: 26 | CPropertyPopupWindow(); 27 | ~CPropertyPopupWindow(); 28 | 29 | HWND CreateWnd(); 30 | void Show(); 31 | void Hide(); 32 | void OnPaint(HWND hwnd, HDC hdc); 33 | void SetString(IStream *pStream); 34 | BOOL IsShown() 35 | { 36 | if (!IsWindow(_hwnd)) 37 | return FALSE; 38 | 39 | return IsWindowVisible(_hwnd); 40 | } 41 | 42 | static BOOL StaticInit(); 43 | 44 | static LRESULT CALLBACK _WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 45 | 46 | static void _SetThis(HWND hwnd, LPARAM lParam) 47 | { 48 | SetWindowLongPtr(hwnd, GWLP_USERDATA, 49 | (LONG_PTR)((CREATESTRUCT *)lParam)->lpCreateParams); 50 | } 51 | 52 | static CPropertyPopupWindow *_GetThis(HWND hwnd) 53 | { 54 | return (CPropertyPopupWindow *)GetWindowLongPtr(hwnd, GWLP_USERDATA); 55 | } 56 | 57 | HWND _hwnd; 58 | static TCHAR _szWndClass[]; 59 | 60 | WCHAR *_psz; 61 | }; 62 | 63 | #endif POPUPWINDOW_H 64 | -------------------------------------------------------------------------------- /PropertyMonitor/PreComp.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // PreComp.cpp 11 | // 12 | // Stub for vc precompiled header. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | -------------------------------------------------------------------------------- /PropertyMonitor/PropertyMonitor.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/PropertyMonitor/PropertyMonitor.JPG -------------------------------------------------------------------------------- /PropertyMonitor/PropertyTextService.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/PropertyMonitor/PropertyTextService.JPG -------------------------------------------------------------------------------- /PropertyMonitor/Resource.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Resource.h 11 | // 12 | // Resource declarations. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef RESOURCE_H 17 | #define RESOURCE_H 18 | 19 | // #define IDI_TEXTSERVICE 0 20 | 21 | #endif // RESOURCE_H 22 | -------------------------------------------------------------------------------- /PropertyMonitor/TextEditSink.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // TextEditSink.cpp 11 | // 12 | // ITfTextEditSink implementation. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | #include "TextService.h" 18 | 19 | //+--------------------------------------------------------------------------- 20 | // 21 | // OnEndEdit 22 | // 23 | // Called by the system whenever anyone releases a write-access document lock. 24 | //---------------------------------------------------------------------------- 25 | 26 | STDAPI CPropertyMonitorTextService::OnEndEdit(ITfContext *pContext, TfEditCookie ecReadOnly, ITfEditRecord *pEditRecord) 27 | { 28 | DumpProperties(pContext); 29 | return S_OK; 30 | } 31 | 32 | //+--------------------------------------------------------------------------- 33 | // 34 | // _InitTextEditSink 35 | // 36 | // Init a text edit sink on the topmost context of the document. 37 | // Always release any previous sink. 38 | //---------------------------------------------------------------------------- 39 | 40 | BOOL CPropertyMonitorTextService::_InitTextEditSink(ITfDocumentMgr *pDocMgr) 41 | { 42 | ITfSource *pSource; 43 | BOOL fRet; 44 | 45 | // clear out any previous sink first 46 | 47 | if (_dwTextEditSinkCookie != TF_INVALID_COOKIE) 48 | { 49 | if (_pTextEditSinkContext->QueryInterface(IID_ITfSource, (void **)&pSource) == S_OK) 50 | { 51 | pSource->UnadviseSink(_dwTextEditSinkCookie); 52 | pSource->Release(); 53 | } 54 | 55 | _pTextEditSinkContext->Release(); 56 | _pTextEditSinkContext = NULL; 57 | _dwTextEditSinkCookie = TF_INVALID_COOKIE; 58 | } 59 | 60 | if (pDocMgr == NULL) 61 | return TRUE; // caller just wanted to clear the previous sink 62 | 63 | // setup a new sink advised to the topmost context of the document 64 | 65 | if (pDocMgr->GetTop(&_pTextEditSinkContext) != S_OK) 66 | return FALSE; 67 | 68 | if (_pTextEditSinkContext == NULL) 69 | return TRUE; // empty document, no sink possible 70 | 71 | fRet = FALSE; 72 | 73 | if (_pTextEditSinkContext->QueryInterface(IID_ITfSource, (void **)&pSource) == S_OK) 74 | { 75 | if (pSource->AdviseSink(IID_ITfTextEditSink, (ITfTextEditSink *)this, &_dwTextEditSinkCookie) == S_OK) 76 | { 77 | fRet = TRUE; 78 | } 79 | else 80 | { 81 | _dwTextEditSinkCookie = TF_INVALID_COOKIE; 82 | } 83 | pSource->Release(); 84 | } 85 | 86 | if (fRet == FALSE) 87 | { 88 | _pTextEditSinkContext->Release(); 89 | _pTextEditSinkContext = NULL; 90 | } 91 | 92 | return fRet; 93 | } 94 | -------------------------------------------------------------------------------- /PropertyMonitor/ThreadFocusSink.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // ThreadFocusSink.cpp 11 | // 12 | // ITfThreadFocusSink interface 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "Globals.h" 17 | #include "TextService.h" 18 | #include "PopupWindow.h" 19 | 20 | //+--------------------------------------------------------------------------- 21 | // 22 | // OnSetThreadFocus 23 | // 24 | //---------------------------------------------------------------------------- 25 | 26 | STDAPI CPropertyMonitorTextService::OnSetThreadFocus() 27 | { 28 | if (_pPopupWindow) 29 | { 30 | _pPopupWindow->Show(); 31 | } 32 | return S_OK; 33 | } 34 | 35 | //+--------------------------------------------------------------------------- 36 | // 37 | // OnKillThreadFocus 38 | // 39 | //---------------------------------------------------------------------------- 40 | 41 | STDAPI CPropertyMonitorTextService::OnKillThreadFocus() 42 | { 43 | if (_pPopupWindow) 44 | { 45 | _pPopupWindow->Hide(); 46 | } 47 | 48 | return S_OK; 49 | } 50 | 51 | //+--------------------------------------------------------------------------- 52 | // 53 | // _InitThreadFocusSink 54 | // 55 | //---------------------------------------------------------------------------- 56 | 57 | BOOL CPropertyMonitorTextService::_InitThreadFocusSink() 58 | { 59 | ITfSource *pSource; 60 | 61 | if (_pThreadMgr->QueryInterface(IID_ITfSource, (void **)&pSource) == S_OK) 62 | { 63 | pSource->AdviseSink(IID_ITfThreadFocusSink, (ITfThreadFocusSink *)this, &_dwThreadFocusCookie); 64 | pSource->Release(); 65 | } 66 | 67 | return TRUE; 68 | } 69 | 70 | //+--------------------------------------------------------------------------- 71 | // 72 | // _UninitThreadFocusSink 73 | // 74 | //---------------------------------------------------------------------------- 75 | 76 | void CPropertyMonitorTextService::_UninitThreadFocusSink() 77 | { 78 | ITfSource *pSource; 79 | 80 | if (_pThreadMgr->QueryInterface(IID_ITfSource, (void **)&pSource) == S_OK) 81 | { 82 | pSource->UnadviseSink(_dwThreadFocusCookie); 83 | pSource->Release(); 84 | } 85 | } 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /PropertyMonitor/TsfPropertyMonitor.def: -------------------------------------------------------------------------------- 1 | LIBRARY TsfPropertyMonitor.dll 2 | 3 | EXPORTS 4 | DllGetClassObject PRIVATE 5 | DllCanUnloadNow PRIVATE 6 | DllRegisterServer PRIVATE 7 | DllUnregisterServer PRIVATE 8 | -------------------------------------------------------------------------------- /PropertyMonitor/TsfPropertyMonitor.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/PropertyMonitor/TsfPropertyMonitor.ico -------------------------------------------------------------------------------- /PropertyMonitor/TsfPropertyMonitor.rc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // TextService.rc 11 | // 12 | // Resources. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | 17 | IDI_TEXTSERVICE ICON TsfPropertyMonitor.ico 18 | 19 | -------------------------------------------------------------------------------- /PropertyMonitor/default.asp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/PropertyMonitor/default.asp -------------------------------------------------------------------------------- /PropertyMonitor/sample.asp: -------------------------------------------------------------------------------- 1 | <% response.redirect "default.asp" %> 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /PropertyTextService.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/PropertyTextService.zip -------------------------------------------------------------------------------- /PropertyTextService/CustomProperty.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // CustomProperty.cpp 11 | // 12 | // Attach custom compact property 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | #include "TextService.h" 18 | #include "EditSession.h" 19 | #include "CustomPropertyStore.h" 20 | 21 | //+--------------------------------------------------------------------------- 22 | // 23 | // CCustomPropertyEditSession 24 | // 25 | //---------------------------------------------------------------------------- 26 | 27 | class CCustomPropertyEditSession : public CEditSessionBase 28 | { 29 | public: 30 | CCustomPropertyEditSession(CTextService *pTextService, ITfContext *pContext) : CEditSessionBase(pTextService, pContext) 31 | { 32 | } 33 | 34 | // ITfEditSession 35 | STDMETHODIMP DoEditSession(TfEditCookie ec); 36 | }; 37 | 38 | //+--------------------------------------------------------------------------- 39 | // 40 | // DoEditSession 41 | // 42 | //---------------------------------------------------------------------------- 43 | 44 | STDAPI CCustomPropertyEditSession::DoEditSession(TfEditCookie ec) 45 | { 46 | ITfProperty *pProperty; 47 | TF_SELECTION tfSelection; 48 | ULONG cFetched; 49 | 50 | if (_pContext->GetSelection(ec, TF_DEFAULT_SELECTION, 1, &tfSelection, &cFetched) != S_OK || cFetched != 1) 51 | return S_FALSE; 52 | 53 | if (_pContext->GetProperty(c_guidPropCustom, &pProperty) == S_OK) 54 | { 55 | CCustomPropertyStore *pCustomPropertyStore = new CCustomPropertyStore(); 56 | if (pCustomPropertyStore != NULL) 57 | pProperty->SetValueStore(ec, tfSelection.range, pCustomPropertyStore); 58 | pProperty->Release(); 59 | } 60 | 61 | tfSelection.range->Release(); 62 | return S_OK; 63 | } 64 | 65 | 66 | //---------------------------------------------------------------------------- 67 | // 68 | // _AttachCustomProperty 69 | // 70 | //---------------------------------------------------------------------------- 71 | 72 | void CTextService::_AttachCustomProperty() 73 | { 74 | ITfDocumentMgr *pDocMgrFocus; 75 | ITfContext *pContext; 76 | 77 | if ((_pThreadMgr->GetFocus(&pDocMgrFocus) == S_OK) && 78 | (pDocMgrFocus != NULL)) 79 | { 80 | if (pDocMgrFocus->GetTop(&pContext) == S_OK) 81 | { 82 | CCustomPropertyEditSession *pEditSession; 83 | if (pEditSession = new CCustomPropertyEditSession(this, pContext)) 84 | { 85 | HRESULT hr; 86 | pContext->RequestEditSession(_tfClientId, pEditSession, TF_ES_ASYNCDONTCARE | TF_ES_READWRITE, &hr); 87 | pEditSession->Release(); 88 | } 89 | pContext->Release(); 90 | } 91 | pDocMgrFocus->Release(); 92 | } 93 | 94 | return; 95 | } 96 | -------------------------------------------------------------------------------- /PropertyTextService/CustomPropertyStore.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // CustomPropertyStore.h 11 | // 12 | // CCustomPropertyStore class 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef CUSTOMPROPERTYSTORE_H 17 | #define CUSTOMPROPERTYSTORE_H 18 | 19 | class CCustomPropertyStore : public ITfPropertyStore 20 | { 21 | public: 22 | CCustomPropertyStore(); 23 | ~CCustomPropertyStore(); 24 | 25 | // IUnknown 26 | STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj); 27 | STDMETHODIMP_(ULONG) AddRef(void); 28 | STDMETHODIMP_(ULONG) Release(void); 29 | 30 | // ITfPropertyStore 31 | STDMETHODIMP GetType(GUID *pguidType); 32 | STDMETHODIMP GetDataType(DWORD *pdwReserved); 33 | STDMETHODIMP GetData(VARIANT *pvarValue); 34 | STDMETHODIMP OnTextUpdated(DWORD dwFlags, ITfRange *pRangeNew, BOOL *pfAccept); 35 | STDMETHODIMP Shrink(ITfRange *pRangeNew, BOOL *pfFree); 36 | STDMETHODIMP Divide(ITfRange *pRangeThis, ITfRange *pRangeNew, ITfPropertyStore **ppPropertyStore); 37 | STDMETHODIMP Clone(ITfPropertyStore **ppClone); 38 | STDMETHODIMP GetPropertyRangeCreator(CLSID *pclsid); 39 | STDMETHODIMP Serialize(IStream *pStream, ULONG *pcb); 40 | 41 | void _SetState(DWORD dwState) 42 | { 43 | _dwState = dwState; 44 | } 45 | 46 | private: 47 | DWORD _dwState; 48 | LONG _cRef; // COM ref count 49 | }; 50 | 51 | #endif // CUSTOMPROPERTYSTORE_H 52 | -------------------------------------------------------------------------------- /PropertyTextService/DllMain.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // DllMain.cpp 11 | // 12 | // DllMain module entry point. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "Globals.h" 17 | 18 | //+--------------------------------------------------------------------------- 19 | // 20 | // DllMain 21 | // 22 | //---------------------------------------------------------------------------- 23 | 24 | BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID pvReserved) 25 | { 26 | switch (dwReason) 27 | { 28 | case DLL_PROCESS_ATTACH: 29 | 30 | g_hInst = hInstance; 31 | 32 | if (!InitializeCriticalSectionAndSpinCount(&g_cs, 0)) 33 | return FALSE; 34 | 35 | break; 36 | 37 | case DLL_PROCESS_DETACH: 38 | 39 | DeleteCriticalSection(&g_cs); 40 | 41 | break; 42 | } 43 | 44 | return TRUE; 45 | } 46 | -------------------------------------------------------------------------------- /PropertyTextService/EditSession.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // EditSession.h 11 | // 12 | // CEditSessionBase declaration. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef EDITSESSION_H 17 | #define EDITSESSION_H 18 | 19 | #include "TextService.h" 20 | 21 | class CEditSessionBase : public ITfEditSession 22 | { 23 | public: 24 | CEditSessionBase(CTextService *pTextService, ITfContext *pContext) 25 | { 26 | _cRef = 1; 27 | _pContext = pContext; 28 | _pContext->AddRef(); 29 | 30 | _pTextService = pTextService; 31 | _pTextService->AddRef(); 32 | } 33 | virtual ~CEditSessionBase() 34 | { 35 | _pContext->Release(); 36 | _pTextService->Release(); 37 | } 38 | 39 | // IUnknown 40 | STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj) 41 | { 42 | if (ppvObj == NULL) 43 | return E_INVALIDARG; 44 | 45 | *ppvObj = NULL; 46 | 47 | if (IsEqualIID(riid, IID_IUnknown) || 48 | IsEqualIID(riid, IID_ITfEditSession)) 49 | { 50 | *ppvObj = (ITfLangBarItemButton *)this; 51 | } 52 | 53 | if (*ppvObj) 54 | { 55 | AddRef(); 56 | return S_OK; 57 | } 58 | 59 | return E_NOINTERFACE; 60 | } 61 | STDMETHODIMP_(ULONG) AddRef(void) 62 | { 63 | return ++_cRef; 64 | } 65 | STDMETHODIMP_(ULONG) Release(void) 66 | { 67 | LONG cr = --_cRef; 68 | 69 | assert(_cRef >= 0); 70 | 71 | if (_cRef == 0) 72 | { 73 | delete this; 74 | } 75 | 76 | return cr; 77 | } 78 | 79 | // ITfEditSession 80 | virtual STDMETHODIMP DoEditSession(TfEditCookie ec) = 0; 81 | 82 | protected: 83 | ITfContext *_pContext; 84 | CTextService *_pTextService; 85 | 86 | private: 87 | LONG _cRef; // COM ref count 88 | }; 89 | 90 | #endif // EDITSESSION_H 91 | -------------------------------------------------------------------------------- /PropertyTextService/Globals.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Globals.cpp 11 | // 12 | // Global variables 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | 18 | HINSTANCE g_hInst; 19 | 20 | LONG g_cRefDll = -1; // -1 /w no refs, for win95 InterlockedIncrement/Decrement compat 21 | 22 | CRITICAL_SECTION g_cs; 23 | 24 | /* 22a956ef-6f8a-11d7-a6ee-00065b84435c */ 25 | const CLSID c_clsidTextService = { 26 | 0x22a956ef, 27 | 0x6f8a, 28 | 0x11d7, 29 | {0xa6, 0xee, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 30 | }; 31 | 32 | /* 22a956f0-6f8a-11d7-a6ee-00065b84435c */ 33 | const GUID c_guidProfile = { 34 | 0x22a956f0, 35 | 0x6f8a, 36 | 0x11d7, 37 | {0xa6, 0xee, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 38 | }; 39 | 40 | /* 22a956f1-6f8a-11d7-a6ee-00065b84435c */ 41 | const GUID c_guidLangBarItemButton = { 42 | 0x22a956f1, 43 | 0x6f8a, 44 | 0x11d7, 45 | {0xa6, 0xee, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 46 | }; 47 | 48 | 49 | /* b4126de5-6f8f-11d7-a6ee-00065b84435c */ 50 | const GUID c_guidPropStaticCompact = { 51 | 0xb4126de5, 52 | 0x6f8f, 53 | 0x11d7, 54 | {0xa6, 0xee, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 55 | }; 56 | /* b4126de6-6f8f-11d7-a6ee-00065b84435c */ 57 | const GUID c_guidPropStatic = { 58 | 0xb4126de6, 59 | 0x6f8f, 60 | 0x11d7, 61 | {0xa6, 0xee, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 62 | }; 63 | /* b4126de7-6f8f-11d7-a6ee-00065b84435c */ 64 | const GUID c_guidPropCustom = { 65 | 0xb4126de7, 66 | 0x6f8f, 67 | 0x11d7, 68 | {0xa6, 0xee, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 69 | }; 70 | -------------------------------------------------------------------------------- /PropertyTextService/Globals.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Globals.h 11 | // 12 | // Global variable declarations. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef GLOBALS_H 17 | #define GLOBALS_H 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include "msctf.h" 24 | 25 | void DllAddRef(); 26 | void DllRelease(); 27 | 28 | #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0])) 29 | 30 | #define TEXTSERVICE_LANGID (0xffff) 31 | 32 | #define TEXTSERVICE_DESC L"Property Text Service" 33 | #define TEXTSERVICE_DESC_A "Property Text Service" 34 | #define TEXTSERVICE_MODEL TEXT("Apartment") 35 | 36 | #define TEXTSERVICE_ICON_INDEX 0 37 | #define LANGBAR_ITEM_DESC L"Property Text Service" 38 | 39 | //+--------------------------------------------------------------------------- 40 | // 41 | // SafeStringCopy 42 | // 43 | // Copies a string from one buffer to another. wcsncpy does not always 44 | // null-terminate the destination buffer; this function does. 45 | //---------------------------------------------------------------------------- 46 | 47 | inline void SafeStringCopy(WCHAR *pchDst, ULONG cchMax, const WCHAR *pchSrc) 48 | { 49 | if (cchMax > 0) 50 | { 51 | wcsncpy(pchDst, pchSrc, cchMax); 52 | pchDst[cchMax-1] = '\0'; 53 | } 54 | } 55 | 56 | extern HINSTANCE g_hInst; 57 | 58 | extern LONG g_cRefDll; 59 | 60 | extern CRITICAL_SECTION g_cs; 61 | 62 | extern const CLSID c_clsidTextService; 63 | 64 | extern const GUID c_guidProfile; 65 | 66 | extern const GUID c_guidLangBarItemButton; 67 | 68 | extern const GUID c_guidPropStaticCompact; 69 | extern const GUID c_guidPropStatic; 70 | extern const GUID c_guidPropCustom; 71 | 72 | #endif // GLOBALS_H 73 | -------------------------------------------------------------------------------- /PropertyTextService/PreComp.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // PreComp.cpp 11 | // 12 | // Stub for vc precompiled header. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | -------------------------------------------------------------------------------- /PropertyTextService/PropertyMonitor.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/PropertyTextService/PropertyMonitor.JPG -------------------------------------------------------------------------------- /PropertyTextService/PropertyTextService.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/PropertyTextService/PropertyTextService.JPG -------------------------------------------------------------------------------- /PropertyTextService/PropertyTextService.aps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/PropertyTextService/PropertyTextService.aps -------------------------------------------------------------------------------- /PropertyTextService/PropertyTextService.def: -------------------------------------------------------------------------------- 1 | LIBRARY PropertyTextService.dll 2 | 3 | EXPORTS 4 | DllGetClassObject PRIVATE 5 | DllCanUnloadNow PRIVATE 6 | DllRegisterServer PRIVATE 7 | DllUnregisterServer PRIVATE 8 | -------------------------------------------------------------------------------- /PropertyTextService/PropertyTextService.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/PropertyTextService/PropertyTextService.ico -------------------------------------------------------------------------------- /PropertyTextService/PropertyTextService.rc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // PropertyTextService.rc 11 | // 12 | // Resources. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | 17 | IDI_TEXTSERVICE ICON PropertyTextService.ico 18 | 19 | -------------------------------------------------------------------------------- /PropertyTextService/Resource.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Resource.h 11 | // 12 | // Resource declarations. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef RESOURCE_H 17 | #define RESOURCE_H 18 | 19 | // #define IDI_TEXTSERVICE 0 20 | 21 | #endif // RESOURCE_H 22 | -------------------------------------------------------------------------------- /PropertyTextService/StaticCompactProperty.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // StaticCompactProperty.cpp 11 | // 12 | // Attach static compact property 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | #include "TextService.h" 18 | #include "EditSession.h" 19 | 20 | //+--------------------------------------------------------------------------- 21 | // 22 | // CStaticCompactPropertyEditSession 23 | // 24 | //---------------------------------------------------------------------------- 25 | 26 | class CStaticCompactPropertyEditSession : public CEditSessionBase 27 | { 28 | public: 29 | CStaticCompactPropertyEditSession(CTextService *pTextService, ITfContext *pContext, DWORD dwValue) : CEditSessionBase(pTextService, pContext) 30 | { 31 | _dwValue = dwValue; 32 | } 33 | 34 | // ITfEditSession 35 | STDMETHODIMP DoEditSession(TfEditCookie ec); 36 | 37 | private: 38 | DWORD _dwValue; 39 | }; 40 | 41 | //+--------------------------------------------------------------------------- 42 | // 43 | // DoEditSession 44 | // 45 | //---------------------------------------------------------------------------- 46 | 47 | STDAPI CStaticCompactPropertyEditSession::DoEditSession(TfEditCookie ec) 48 | { 49 | ITfProperty *pProperty; 50 | TF_SELECTION tfSelection; 51 | ULONG cFetched; 52 | 53 | if (_pContext->GetSelection(ec, TF_DEFAULT_SELECTION, 1, &tfSelection, &cFetched) != S_OK || cFetched != 1) 54 | return S_FALSE; 55 | 56 | if (_pContext->GetProperty(c_guidPropStaticCompact, &pProperty) == S_OK) 57 | { 58 | VARIANT var; 59 | var.vt = VT_I4; 60 | var.lVal = _dwValue; 61 | pProperty->SetValue(ec, tfSelection.range, &var); 62 | pProperty->Release(); 63 | } 64 | 65 | tfSelection.range->Release(); 66 | return S_OK; 67 | } 68 | 69 | 70 | //---------------------------------------------------------------------------- 71 | // 72 | // _AttachStaticCompactProperty 73 | // 74 | //---------------------------------------------------------------------------- 75 | 76 | void CTextService::_AttachStaticCompactProperty(DWORD dwValue) 77 | { 78 | ITfDocumentMgr *pDocMgrFocus; 79 | ITfContext *pContext; 80 | 81 | if ((_pThreadMgr->GetFocus(&pDocMgrFocus) == S_OK) && 82 | (pDocMgrFocus != NULL)) 83 | { 84 | if (pDocMgrFocus->GetTop(&pContext) == S_OK) 85 | { 86 | CStaticCompactPropertyEditSession *pEditSession; 87 | if (pEditSession = new CStaticCompactPropertyEditSession(this, pContext, dwValue)) 88 | { 89 | HRESULT hr; 90 | pContext->RequestEditSession(_tfClientId, pEditSession, TF_ES_ASYNCDONTCARE | TF_ES_READWRITE, &hr); 91 | pEditSession->Release(); 92 | } 93 | pContext->Release(); 94 | } 95 | pDocMgrFocus->Release(); 96 | } 97 | 98 | return; 99 | } 100 | -------------------------------------------------------------------------------- /PropertyTextService/StaticProperty.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // StaticProperty.cpp 11 | // 12 | // Attach static property 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | #include "TextService.h" 18 | #include "EditSession.h" 19 | 20 | //+--------------------------------------------------------------------------- 21 | // 22 | // CStaticPropertyEditSession 23 | // 24 | //---------------------------------------------------------------------------- 25 | 26 | class CStaticPropertyEditSession : public CEditSessionBase 27 | { 28 | public: 29 | CStaticPropertyEditSession(CTextService *pTextService, ITfContext *pContext, WCHAR *psz) : CEditSessionBase(pTextService, pContext) 30 | { 31 | SafeStringCopy(_sz, ARRAYSIZE(_sz), psz); 32 | } 33 | 34 | // ITfEditSession 35 | STDMETHODIMP DoEditSession(TfEditCookie ec); 36 | 37 | private: 38 | WCHAR _sz[32]; 39 | }; 40 | 41 | //+--------------------------------------------------------------------------- 42 | // 43 | // DoEditSession 44 | // 45 | //---------------------------------------------------------------------------- 46 | 47 | STDAPI CStaticPropertyEditSession::DoEditSession(TfEditCookie ec) 48 | { 49 | ITfProperty *pProperty; 50 | TF_SELECTION tfSelection; 51 | ULONG cFetched; 52 | 53 | if (_pContext->GetSelection(ec, TF_DEFAULT_SELECTION, 1, &tfSelection, &cFetched) != S_OK || cFetched != 1) 54 | return S_FALSE; 55 | 56 | if (_pContext->GetProperty(c_guidPropStatic, &pProperty) == S_OK) 57 | { 58 | VARIANT var; 59 | var.vt = VT_BSTR; 60 | var.bstrVal = SysAllocString(_sz); 61 | pProperty->SetValue(ec, tfSelection.range, &var); 62 | pProperty->Release(); 63 | } 64 | 65 | tfSelection.range->Release(); 66 | return S_OK; 67 | } 68 | 69 | 70 | //---------------------------------------------------------------------------- 71 | // 72 | // _AttachStaticProperty 73 | // 74 | //---------------------------------------------------------------------------- 75 | 76 | void CTextService::_AttachStaticProperty(WCHAR *psz) 77 | { 78 | ITfDocumentMgr *pDocMgrFocus; 79 | ITfContext *pContext; 80 | 81 | if ((_pThreadMgr->GetFocus(&pDocMgrFocus) == S_OK) && 82 | (pDocMgrFocus != NULL)) 83 | { 84 | if (pDocMgrFocus->GetTop(&pContext) == S_OK) 85 | { 86 | CStaticPropertyEditSession *pEditSession; 87 | if (pEditSession = new CStaticPropertyEditSession(this, pContext, psz)) 88 | { 89 | HRESULT hr; 90 | pContext->RequestEditSession(_tfClientId, pEditSession, TF_ES_ASYNCDONTCARE | TF_ES_READWRITE, &hr); 91 | pEditSession->Release(); 92 | } 93 | pContext->Release(); 94 | } 95 | pDocMgrFocus->Release(); 96 | } 97 | 98 | return; 99 | } 100 | -------------------------------------------------------------------------------- /PropertyTextService/TextService.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // TextService.h 11 | // 12 | // CTextService declaration. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef TEXTSERVICE_H 17 | #define TEXTSERVICE_H 18 | 19 | class CLangBarItemButton; 20 | 21 | class CTextService : public ITfTextInputProcessor, 22 | public ITfThreadMgrEventSink, 23 | public ITfTextEditSink, 24 | public ITfCreatePropertyStore 25 | { 26 | public: 27 | CTextService(); 28 | ~CTextService(); 29 | 30 | // IUnknown 31 | STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj); 32 | STDMETHODIMP_(ULONG) AddRef(void); 33 | STDMETHODIMP_(ULONG) Release(void); 34 | 35 | // ITfTextInputProcessor 36 | STDMETHODIMP Activate(ITfThreadMgr *pThreadMgr, TfClientId tfClientId); 37 | STDMETHODIMP Deactivate(); 38 | 39 | // ITfThreadMgrEventSink 40 | STDMETHODIMP OnInitDocumentMgr(ITfDocumentMgr *pDocMgr); 41 | STDMETHODIMP OnUninitDocumentMgr(ITfDocumentMgr *pDocMgr); 42 | STDMETHODIMP OnSetFocus(ITfDocumentMgr *pDocMgrFocus, ITfDocumentMgr *pDocMgrPrevFocus); 43 | STDMETHODIMP OnPushContext(ITfContext *pContext); 44 | STDMETHODIMP OnPopContext(ITfContext *pContext); 45 | 46 | // ITfTextEditSink 47 | STDMETHODIMP OnEndEdit(ITfContext *pContext, TfEditCookie ecReadOnly, ITfEditRecord *pEditRecord); 48 | 49 | // ITfCreatePropertyStore 50 | STDMETHODIMP IsStoreSerializable(REFGUID guidProperty, ITfRange *pRange, ITfPropertyStore *pPropertyStore, BOOL *pfSerializable); 51 | STDMETHODIMP CreatePropertyStore(REFGUID guidProperty, ITfRange *pRange, ULONG cb, IStream *pStream, ITfPropertyStore **ppStore); 52 | 53 | 54 | // CClassFactory factory callback 55 | static HRESULT CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObj); 56 | 57 | ITfThreadMgr *_GetThreadMgr() { return _pThreadMgr; } 58 | 59 | void _AttachStaticCompactProperty(DWORD dwValue); 60 | void _AttachStaticProperty(WCHAR *psz); 61 | void _AttachCustomProperty(); 62 | 63 | private: 64 | // initialize and uninitialize ThreadMgrEventSink. 65 | BOOL _InitThreadMgrEventSink(); 66 | void _UninitThreadMgrEventSink(); 67 | 68 | // initialize TextEditSink. 69 | BOOL _InitTextEditSink(ITfDocumentMgr *pDocMgr); 70 | 71 | // initialize and uninitialize LanguageBar Item. 72 | BOOL _InitLanguageBar(); 73 | void _UninitLanguageBar(); 74 | 75 | // 76 | // state 77 | // 78 | ITfThreadMgr *_pThreadMgr; 79 | TfClientId _tfClientId; 80 | 81 | // The cookie of ThreadMgrEventSink 82 | DWORD _dwThreadMgrEventSinkCookie; 83 | 84 | // 85 | // private variables for TextEditSink 86 | // 87 | ITfContext *_pTextEditSinkContext; 88 | DWORD _dwTextEditSinkCookie; 89 | 90 | CLangBarItemButton *_pLangBarItem; 91 | 92 | LONG _cRef; // COM ref count 93 | }; 94 | 95 | 96 | #endif // TEXTSERVICE_H 97 | -------------------------------------------------------------------------------- /PropertyTextService/default.asp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/PropertyTextService/default.asp -------------------------------------------------------------------------------- /PropertyTextService/dl/PropertyTextService.msi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/PropertyTextService/dl/PropertyTextService.msi -------------------------------------------------------------------------------- /PropertyTextService/sample.asp: -------------------------------------------------------------------------------- 1 | <% response.redirect "default.asp" %> 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /TextInsertion.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/TextInsertion.zip -------------------------------------------------------------------------------- /TextInsertion/DllMain.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // DllMain.cpp 11 | // 12 | // DllMain module entry point. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "Globals.h" 17 | 18 | //+--------------------------------------------------------------------------- 19 | // 20 | // DllMain 21 | // 22 | //---------------------------------------------------------------------------- 23 | 24 | BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID pvReserved) 25 | { 26 | switch (dwReason) 27 | { 28 | case DLL_PROCESS_ATTACH: 29 | 30 | g_hInst = hInstance; 31 | 32 | if (!InitializeCriticalSectionAndSpinCount(&g_cs, 0)) 33 | return FALSE; 34 | 35 | break; 36 | 37 | case DLL_PROCESS_DETACH: 38 | 39 | DeleteCriticalSection(&g_cs); 40 | 41 | break; 42 | } 43 | 44 | return TRUE; 45 | } 46 | -------------------------------------------------------------------------------- /TextInsertion/EditSession.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // EditSession.h 11 | // 12 | // CEditSessionBase declaration. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef EDITSESSION_H 17 | #define EDITSESSION_H 18 | 19 | class CEditSessionBase : public ITfEditSession 20 | { 21 | public: 22 | CEditSessionBase(ITfContext *pContext) 23 | { 24 | _cRef = 1; 25 | _pContext = pContext; 26 | _pContext->AddRef(); 27 | } 28 | virtual ~CEditSessionBase() 29 | { 30 | _pContext->Release(); 31 | } 32 | 33 | // IUnknown 34 | STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj) 35 | { 36 | if (ppvObj == NULL) 37 | return E_INVALIDARG; 38 | 39 | *ppvObj = NULL; 40 | 41 | if (IsEqualIID(riid, IID_IUnknown) || 42 | IsEqualIID(riid, IID_ITfEditSession)) 43 | { 44 | *ppvObj = (ITfLangBarItemButton *)this; 45 | } 46 | 47 | if (*ppvObj) 48 | { 49 | AddRef(); 50 | return S_OK; 51 | } 52 | 53 | return E_NOINTERFACE; 54 | } 55 | STDMETHODIMP_(ULONG) AddRef(void) 56 | { 57 | return ++_cRef; 58 | } 59 | STDMETHODIMP_(ULONG) Release(void) 60 | { 61 | LONG cr = --_cRef; 62 | 63 | assert(_cRef >= 0); 64 | 65 | if (_cRef == 0) 66 | { 67 | delete this; 68 | } 69 | 70 | return cr; 71 | } 72 | 73 | // ITfEditSession 74 | virtual STDMETHODIMP DoEditSession(TfEditCookie ec) = 0; 75 | 76 | protected: 77 | ITfContext *_pContext; 78 | 79 | private: 80 | LONG _cRef; // COM ref count 81 | }; 82 | 83 | #endif // EDITSESSION_H 84 | -------------------------------------------------------------------------------- /TextInsertion/Globals.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Globals.cpp 11 | // 12 | // Global variables 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | 18 | HINSTANCE g_hInst; 19 | 20 | LONG g_cRefDll = -1; // -1 /w no refs, for win95 InterlockedIncrement/Decrement compat 21 | 22 | CRITICAL_SECTION g_cs; 23 | 24 | /* e7ea138e-69f8-11d7-a6ea-00065b84435c */ 25 | const CLSID c_clsidTextService = { 26 | 0xe7ea138e, 27 | 0x69f8, 28 | 0x11d7, 29 | {0xa6, 0xea, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 30 | }; 31 | /* e7ea138f-69f8-11d7-a6ea-00065b84435c */ 32 | const GUID c_guidProfile = { 33 | 0xe7ea138f, 34 | 0x69f8, 35 | 0x11d7, 36 | {0xa6, 0xea, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 37 | }; 38 | /* 41f46e67-86d5-49fb-a1d9-3dc0941a66a3 */ 39 | const GUID c_guidLangBarItemButton = { 40 | 0x41f46e67, 41 | 0x86d5, 42 | 0x49fb, 43 | {0xa1, 0xd9, 0x3d, 0xc0, 0x94, 0x1a, 0x66, 0xa3} 44 | }; 45 | 46 | -------------------------------------------------------------------------------- /TextInsertion/Globals.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Globals.h 11 | // 12 | // Global variable declarations. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef GLOBALS_H 17 | #define GLOBALS_H 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include "msctf.h" 24 | 25 | void DllAddRef(); 26 | void DllRelease(); 27 | 28 | #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0])) 29 | 30 | #define TEXTSERVICE_LANGID MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US) 31 | 32 | #define TEXTSERVICE_DESC L"Sample Text Service" 33 | #define TEXTSERVICE_DESC_A "Sample Text Service" 34 | #define TEXTSERVICE_MODEL TEXT("Apartment") 35 | 36 | #define TEXTSERVICE_ICON_INDEX 0 37 | #define LANGBAR_ITEM_DESC L"Sample Text Service Button" 38 | 39 | //+--------------------------------------------------------------------------- 40 | // 41 | // SafeStringCopy 42 | // 43 | // Copies a string from one buffer to another. wcsncpy does not always 44 | // null-terminate the destination buffer; this function does. 45 | //---------------------------------------------------------------------------- 46 | 47 | inline void SafeStringCopy(WCHAR *pchDst, ULONG cchMax, const WCHAR *pchSrc) 48 | { 49 | if (cchMax > 0) 50 | { 51 | wcsncpy(pchDst, pchSrc, cchMax); 52 | pchDst[cchMax-1] = '\0'; 53 | } 54 | } 55 | 56 | extern HINSTANCE g_hInst; 57 | 58 | extern LONG g_cRefDll; 59 | 60 | extern CRITICAL_SECTION g_cs; 61 | 62 | extern const CLSID c_clsidTextService; 63 | 64 | extern const GUID c_guidProfile; 65 | 66 | extern const GUID c_guidLangBarItemButton; 67 | 68 | 69 | #endif // GLOBALS_H 70 | -------------------------------------------------------------------------------- /TextInsertion/HelloWorld.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/TextInsertion/HelloWorld.JPG -------------------------------------------------------------------------------- /TextInsertion/PreComp.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // PreComp.cpp 11 | // 12 | // Stub for vc precompiled header. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | -------------------------------------------------------------------------------- /TextInsertion/Resource.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Resource.h 11 | // 12 | // Resource declarations. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef RESOURCE_H 17 | #define RESOURCE_H 18 | 19 | // #define IDI_TEXTSERVICE 0 20 | 21 | #endif // RESOURCE_H 22 | -------------------------------------------------------------------------------- /TextInsertion/TextEditSink.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // TextEditSink.cpp 11 | // 12 | // ITfTextEditSink implementation. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | #include "TextService.h" 18 | 19 | //+--------------------------------------------------------------------------- 20 | // 21 | // OnEndEdit 22 | // 23 | // Called by the system whenever anyone releases a write-access document lock. 24 | //---------------------------------------------------------------------------- 25 | 26 | STDAPI CTextService::OnEndEdit(ITfContext *pContext, TfEditCookie ecReadOnly, ITfEditRecord *pEditRecord) 27 | { 28 | BOOL fSelectionChanged; 29 | IEnumTfRanges *pEnumTextChanges; 30 | ITfRange *pRange; 31 | 32 | // 33 | // did the selection change? 34 | // The selection change includes the movement of caret as well. 35 | // The caret position is represent as the empty selection range when 36 | // there is no selection. 37 | // 38 | if (pEditRecord->GetSelectionStatus(&fSelectionChanged) == S_OK && 39 | fSelectionChanged) 40 | { 41 | } 42 | 43 | // text modification? 44 | if (pEditRecord->GetTextAndPropertyUpdates(TF_GTP_INCL_TEXT, NULL, 0, &pEnumTextChanges) == S_OK) 45 | { 46 | if (pEnumTextChanges->Next(1, &pRange, NULL) == S_OK) 47 | { 48 | // 49 | // pRange is the updated range. 50 | // 51 | 52 | pRange->Release(); 53 | } 54 | 55 | pEnumTextChanges->Release(); 56 | } 57 | 58 | return S_OK; 59 | } 60 | 61 | //+--------------------------------------------------------------------------- 62 | // 63 | // _InitTextEditSink 64 | // 65 | // Init a text edit sink on the topmost context of the document. 66 | // Always release any previous sink. 67 | //---------------------------------------------------------------------------- 68 | 69 | BOOL CTextService::_InitTextEditSink(ITfDocumentMgr *pDocMgr) 70 | { 71 | ITfSource *pSource; 72 | BOOL fRet; 73 | 74 | // clear out any previous sink first 75 | 76 | if (_dwTextEditSinkCookie != TF_INVALID_COOKIE) 77 | { 78 | if (_pTextEditSinkContext->QueryInterface(IID_ITfSource, (void **)&pSource) == S_OK) 79 | { 80 | pSource->UnadviseSink(_dwTextEditSinkCookie); 81 | pSource->Release(); 82 | } 83 | 84 | _pTextEditSinkContext->Release(); 85 | _pTextEditSinkContext = NULL; 86 | _dwTextEditSinkCookie = TF_INVALID_COOKIE; 87 | } 88 | 89 | if (pDocMgr == NULL) 90 | return TRUE; // caller just wanted to clear the previous sink 91 | 92 | // setup a new sink advised to the topmost context of the document 93 | 94 | if (pDocMgr->GetTop(&_pTextEditSinkContext) != S_OK) 95 | return FALSE; 96 | 97 | if (_pTextEditSinkContext == NULL) 98 | return TRUE; // empty document, no sink possible 99 | 100 | fRet = FALSE; 101 | 102 | if (_pTextEditSinkContext->QueryInterface(IID_ITfSource, (void **)&pSource) == S_OK) 103 | { 104 | if (pSource->AdviseSink(IID_ITfTextEditSink, (ITfTextEditSink *)this, &_dwTextEditSinkCookie) == S_OK) 105 | { 106 | fRet = TRUE; 107 | } 108 | else 109 | { 110 | _dwTextEditSinkCookie = TF_INVALID_COOKIE; 111 | } 112 | pSource->Release(); 113 | } 114 | 115 | if (fRet == FALSE) 116 | { 117 | _pTextEditSinkContext->Release(); 118 | _pTextEditSinkContext = NULL; 119 | } 120 | 121 | return fRet; 122 | } 123 | -------------------------------------------------------------------------------- /TextInsertion/TextService.def: -------------------------------------------------------------------------------- 1 | LIBRARY TextService.dll 2 | 3 | EXPORTS 4 | DllGetClassObject PRIVATE 5 | DllCanUnloadNow PRIVATE 6 | DllRegisterServer PRIVATE 7 | DllUnregisterServer PRIVATE 8 | -------------------------------------------------------------------------------- /TextInsertion/TextService.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // TextService.h 11 | // 12 | // CTextService declaration. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef TEXTSERVICE_H 17 | #define TEXTSERVICE_H 18 | 19 | class CLangBarItemButton; 20 | 21 | class CTextService : public ITfTextInputProcessor, 22 | public ITfThreadMgrEventSink, 23 | public ITfTextEditSink 24 | { 25 | public: 26 | CTextService(); 27 | ~CTextService(); 28 | 29 | // IUnknown 30 | STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj); 31 | STDMETHODIMP_(ULONG) AddRef(void); 32 | STDMETHODIMP_(ULONG) Release(void); 33 | 34 | // ITfTextInputProcessor 35 | STDMETHODIMP Activate(ITfThreadMgr *pThreadMgr, TfClientId tfClientId); 36 | STDMETHODIMP Deactivate(); 37 | 38 | // ITfThreadMgrEventSink 39 | STDMETHODIMP OnInitDocumentMgr(ITfDocumentMgr *pDocMgr); 40 | STDMETHODIMP OnUninitDocumentMgr(ITfDocumentMgr *pDocMgr); 41 | STDMETHODIMP OnSetFocus(ITfDocumentMgr *pDocMgrFocus, ITfDocumentMgr *pDocMgrPrevFocus); 42 | STDMETHODIMP OnPushContext(ITfContext *pContext); 43 | STDMETHODIMP OnPopContext(ITfContext *pContext); 44 | 45 | // ITfTextEditSink 46 | STDMETHODIMP OnEndEdit(ITfContext *pContext, TfEditCookie ecReadOnly, ITfEditRecord *pEditRecord); 47 | 48 | // CClassFactory factory callback 49 | static HRESULT CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObj); 50 | 51 | ITfThreadMgr *_GetThreadMgr() { return _pThreadMgr; } 52 | void InsertHello(); 53 | 54 | private: 55 | // initialize and uninitialize ThreadMgrEventSink. 56 | BOOL _InitThreadMgrEventSink(); 57 | void _UninitThreadMgrEventSink(); 58 | 59 | // initialize TextEditSink. 60 | BOOL _InitTextEditSink(ITfDocumentMgr *pDocMgr); 61 | 62 | BOOL _InitLanguageBar(); 63 | void _UninitLanguageBar(); 64 | 65 | // 66 | // state 67 | // 68 | ITfThreadMgr *_pThreadMgr; 69 | TfClientId _tfClientId; 70 | 71 | // The cookie of ThreadMgrEventSink 72 | DWORD _dwThreadMgrEventSinkCookie; 73 | 74 | // 75 | // private variables for TextEditSink 76 | // 77 | ITfContext *_pTextEditSinkContext; 78 | DWORD _dwTextEditSinkCookie; 79 | 80 | CLangBarItemButton *_pLangBarItem; 81 | 82 | LONG _cRef; // COM ref count 83 | }; 84 | 85 | 86 | #endif // TEXTSERVICE_H 87 | -------------------------------------------------------------------------------- /TextInsertion/TextService.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/TextInsertion/TextService.ico -------------------------------------------------------------------------------- /TextInsertion/TextService.rc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // TextService.rc 11 | // 12 | // Resources. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | 17 | IDI_TEXTSERVICE ICON TextService.ico 18 | 19 | -------------------------------------------------------------------------------- /TextInsertion/default.asp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/TextInsertion/default.asp -------------------------------------------------------------------------------- /TextInsertion/sample.asp: -------------------------------------------------------------------------------- 1 | <% response.redirect "default.asp" %> 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /TrackFocus.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/TrackFocus.zip -------------------------------------------------------------------------------- /TrackFocus/DllMain.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // DllMain.cpp 11 | // 12 | // DllMain module entry point. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "Globals.h" 17 | 18 | //+--------------------------------------------------------------------------- 19 | // 20 | // DllMain 21 | // 22 | //---------------------------------------------------------------------------- 23 | 24 | BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID pvReserved) 25 | { 26 | switch (dwReason) 27 | { 28 | case DLL_PROCESS_ATTACH: 29 | 30 | g_hInst = hInstance; 31 | 32 | if (!InitializeCriticalSectionAndSpinCount(&g_cs, 0)) 33 | return FALSE; 34 | 35 | break; 36 | 37 | case DLL_PROCESS_DETACH: 38 | 39 | DeleteCriticalSection(&g_cs); 40 | 41 | break; 42 | } 43 | 44 | return TRUE; 45 | } 46 | -------------------------------------------------------------------------------- /TrackFocus/Globals.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Globals.cpp 11 | // 12 | // Global variables 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | 18 | HINSTANCE g_hInst; 19 | 20 | LONG g_cRefDll = -1; // -1 /w no refs, for win95 InterlockedIncrement/Decrement compat 21 | 22 | CRITICAL_SECTION g_cs; 23 | 24 | /* e7ea138e-69f8-11d7-a6ea-00065b84435c */ 25 | const CLSID c_clsidTextService = { 26 | 0xe7ea138e, 27 | 0x69f8, 28 | 0x11d7, 29 | {0xa6, 0xea, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 30 | }; 31 | /* e7ea138f-69f8-11d7-a6ea-00065b84435c */ 32 | const GUID c_guidProfile = { 33 | 0xe7ea138f, 34 | 0x69f8, 35 | 0x11d7, 36 | {0xa6, 0xea, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 37 | }; 38 | 39 | -------------------------------------------------------------------------------- /TrackFocus/PreComp.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // PreComp.cpp 11 | // 12 | // Stub for vc precompiled header. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | -------------------------------------------------------------------------------- /TrackFocus/Readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/TrackFocus/Readme.txt -------------------------------------------------------------------------------- /TrackFocus/Resource.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Resource.h 11 | // 12 | // Resource declarations. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef RESOURCE_H 17 | #define RESOURCE_H 18 | 19 | // #define IDI_TEXTSERVICE 0 20 | 21 | #endif // RESOURCE_H 22 | -------------------------------------------------------------------------------- /TrackFocus/TextService.aps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/TrackFocus/TextService.aps -------------------------------------------------------------------------------- /TrackFocus/TextService.def: -------------------------------------------------------------------------------- 1 | LIBRARY TextService.dll 2 | 3 | EXPORTS 4 | DllGetClassObject PRIVATE 5 | DllCanUnloadNow PRIVATE 6 | DllRegisterServer PRIVATE 7 | DllUnregisterServer PRIVATE 8 | -------------------------------------------------------------------------------- /TrackFocus/TextService.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // TextService.h 11 | // 12 | // CTextService declaration. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef TEXTSERVICE_H 17 | #define TEXTSERVICE_H 18 | 19 | class CTextService : public ITfTextInputProcessor, 20 | public ITfThreadMgrEventSink 21 | { 22 | public: 23 | CTextService(); 24 | ~CTextService(); 25 | 26 | // IUnknown 27 | STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj); 28 | STDMETHODIMP_(ULONG) AddRef(void); 29 | STDMETHODIMP_(ULONG) Release(void); 30 | 31 | // ITfTextInputProcessor 32 | STDMETHODIMP Activate(ITfThreadMgr *pThreadMgr, TfClientId tfClientId); 33 | STDMETHODIMP Deactivate(); 34 | 35 | // ITfThreadMgrEventSink 36 | STDMETHODIMP OnInitDocumentMgr(ITfDocumentMgr *pDocMgr); 37 | STDMETHODIMP OnUninitDocumentMgr(ITfDocumentMgr *pDocMgr); 38 | STDMETHODIMP OnSetFocus(ITfDocumentMgr *pDocMgrFocus, ITfDocumentMgr *pDocMgrPrevFocus); 39 | STDMETHODIMP OnPushContext(ITfContext *pContext); 40 | STDMETHODIMP OnPopContext(ITfContext *pContext); 41 | 42 | // CClassFactory factory callback 43 | static HRESULT CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObj); 44 | 45 | ITfThreadMgr *_GetThreadMgr() { return _pThreadMgr; } 46 | 47 | private: 48 | // initialize and uninitialize ThreadMgrEventSink. 49 | BOOL _InitThreadMgrEventSink(); 50 | void _UninitThreadMgrEventSink(); 51 | 52 | // 53 | // state 54 | // 55 | ITfThreadMgr *_pThreadMgr; 56 | 57 | // The cookie of ThreadMgrEventSink 58 | DWORD _dwThreadMgrEventSinkCookie; 59 | 60 | LONG _cRef; // COM ref count 61 | }; 62 | 63 | 64 | #endif // TEXTSERVICE_H 65 | -------------------------------------------------------------------------------- /TrackFocus/TextService.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/TrackFocus/TextService.ico -------------------------------------------------------------------------------- /TrackFocus/TextService.rc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // TextService.rc 11 | // 12 | // Resources. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | 17 | IDI_TEXTSERVICE ICON TextService.ico 18 | 19 | -------------------------------------------------------------------------------- /TrackFocus/default.asp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/TrackFocus/default.asp -------------------------------------------------------------------------------- /TrackFocus/globals.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Globals.h 11 | // 12 | // Global variable declarations. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef GLOBALS_H 17 | #define GLOBALS_H 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include "msctf.h" 24 | 25 | void DllAddRef(); 26 | void DllRelease(); 27 | 28 | #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0])) 29 | 30 | #define TEXTSERVICE_LANGID MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US) 31 | 32 | #define TEXTSERVICE_DESC L"Sample Text Service" 33 | #define TEXTSERVICE_DESC_A "Sample Text Service" 34 | #define TEXTSERVICE_MODEL TEXT("Apartment") 35 | 36 | #define TEXTSERVICE_ICON_INDEX 0 37 | 38 | extern HINSTANCE g_hInst; 39 | 40 | extern LONG g_cRefDll; 41 | 42 | extern CRITICAL_SECTION g_cs; 43 | 44 | extern const CLSID c_clsidTextService; 45 | 46 | extern const GUID c_guidProfile; 47 | 48 | 49 | #endif // GLOBALS_H 50 | -------------------------------------------------------------------------------- /TrackFocus/makefile: -------------------------------------------------------------------------------- 1 | #----- set the project name -------------------------------------------------------------- 2 | Proj = TextService 3 | 4 | #----- Include the PSDK's WIN32.MAK to pick up defines ----------------------------------- 5 | !include 6 | 7 | #----- OUTDIR is defined in WIN32.MAK This is the name of the destination directory ------ 8 | all: $(OUTDIR)\$(Proj).dll 9 | 10 | LINK32_OBJS= \ 11 | $(OUTDIR)\TextService.obj \ 12 | $(OUTDIR)\ThreadMgrEventSink.obj \ 13 | $(OUTDIR)\Dllmain.obj \ 14 | $(OUTDIR)\Globals.obj \ 15 | $(OUTDIR)\PreComp.obj \ 16 | $(OUTDIR)\Register.obj \ 17 | $(OUTDIR)\Server.obj 18 | 19 | #----- If OUTDIR does not exist, then create directory 20 | $(OUTDIR) : 21 | if not exist "$(OUTDIR)/$(NULL)" mkdir $(OUTDIR) 22 | 23 | #----- add the preprocessor definitions needed by this project --------------------------- 24 | 25 | #----- set the libraries needed by this project ------------------------------------------ 26 | LINK_LIBS = $(dlllibs) $(guilibs) $(olelibs) 27 | 28 | #--------------------- DLL --------------------------------------------------------------- 29 | #PLEASE REFER TO WIN32.MAK for the different Linker options WIN32.MAK provides 30 | 31 | # Build rule for DLL 32 | $(OUTDIR)\$(Proj).dll: $(OUTDIR) $(LINK32_OBJS) $(OUTDIR)\$(Proj).res 33 | $(link) $(ldebug) $(dllllflags) \ 34 | $(LINK32_OBJS) $(OUTDIR)\$(Proj).res $(LINK_LIBS) \ 35 | -base:0x20000000 \ 36 | -out:$(OUTDIR)\$(Proj).dll \ 37 | -def:$(Proj).def 38 | 39 | #--------------------- Compiling C/CPP Files --------------------------------------------- 40 | #PLEASE REFER TO WIN32.MAK for the different Compiler options WIN32.MAK provides 41 | 42 | FILE=TextService 43 | 44 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 45 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 46 | 47 | FILE=ThreadMgrEventSink 48 | 49 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 50 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 51 | 52 | FILE=Dllmain 53 | 54 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 55 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 56 | 57 | FILE=Globals 58 | 59 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 60 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 61 | 62 | FILE=Precomp 63 | 64 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 65 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 66 | 67 | FILE=Register 68 | 69 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 70 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 71 | 72 | FILE=Server 73 | 74 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 75 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 76 | 77 | 78 | #--------------------- Compiling Resource Files ------------------------------------------ 79 | #PLEASE REFER TO WIN32.MAK for the different Resource Compiler options WIN32.MAK provides 80 | 81 | # Build rule for resource file 82 | FILE=TextService 83 | 84 | $(OUTDIR)\$(FILE).res: .\$(FILE).rc $(OUTDIR) 85 | $(rc) $(rcflags) $(rcvars) /fo $(OUTDIR)\$(FILE).res .\$(FILE).rc 86 | 87 | #--------------------- Clean Rule -------------------------------------------------------- 88 | # Rules for cleaning out those old files 89 | clean: 90 | $(CLEANUP) 91 | -------------------------------------------------------------------------------- /TrackFocus/sample.asp: -------------------------------------------------------------------------------- 1 | <% response.redirect "default.asp" %> 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /TrackTextChange.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/TrackTextChange.zip -------------------------------------------------------------------------------- /TrackTextChange/DllMain.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // DllMain.cpp 11 | // 12 | // DllMain module entry point. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "Globals.h" 17 | 18 | //+--------------------------------------------------------------------------- 19 | // 20 | // DllMain 21 | // 22 | //---------------------------------------------------------------------------- 23 | 24 | BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID pvReserved) 25 | { 26 | switch (dwReason) 27 | { 28 | case DLL_PROCESS_ATTACH: 29 | 30 | g_hInst = hInstance; 31 | 32 | if (!InitializeCriticalSectionAndSpinCount(&g_cs, 0)) 33 | return FALSE; 34 | 35 | break; 36 | 37 | case DLL_PROCESS_DETACH: 38 | 39 | DeleteCriticalSection(&g_cs); 40 | 41 | break; 42 | } 43 | 44 | return TRUE; 45 | } 46 | -------------------------------------------------------------------------------- /TrackTextChange/Globals.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Globals.cpp 11 | // 12 | // Global variables 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | 18 | HINSTANCE g_hInst; 19 | 20 | LONG g_cRefDll = -1; // -1 /w no refs, for win95 InterlockedIncrement/Decrement compat 21 | 22 | CRITICAL_SECTION g_cs; 23 | 24 | /* e7ea138e-69f8-11d7-a6ea-00065b84435c */ 25 | const CLSID c_clsidTextService = { 26 | 0xe7ea138e, 27 | 0x69f8, 28 | 0x11d7, 29 | {0xa6, 0xea, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 30 | }; 31 | /* e7ea138f-69f8-11d7-a6ea-00065b84435c */ 32 | const GUID c_guidProfile = { 33 | 0xe7ea138f, 34 | 0x69f8, 35 | 0x11d7, 36 | {0xa6, 0xea, 0x00, 0x06, 0x5b, 0x84, 0x43, 0x5c} 37 | }; 38 | 39 | -------------------------------------------------------------------------------- /TrackTextChange/PreComp.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // PreComp.cpp 11 | // 12 | // Stub for vc precompiled header. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | -------------------------------------------------------------------------------- /TrackTextChange/Resource.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Resource.h 11 | // 12 | // Resource declarations. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef RESOURCE_H 17 | #define RESOURCE_H 18 | 19 | // #define IDI_TEXTSERVICE 0 20 | 21 | #endif // RESOURCE_H 22 | -------------------------------------------------------------------------------- /TrackTextChange/TextEditSink.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // TextEditSink.cpp 11 | // 12 | // ITfTextEditSink implementation. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #include "globals.h" 17 | #include "TextService.h" 18 | 19 | //+--------------------------------------------------------------------------- 20 | // 21 | // OnEndEdit 22 | // 23 | // Called by the system whenever anyone releases a write-access document lock. 24 | //---------------------------------------------------------------------------- 25 | 26 | STDAPI CTextService::OnEndEdit(ITfContext *pContext, TfEditCookie ecReadOnly, ITfEditRecord *pEditRecord) 27 | { 28 | BOOL fSelectionChanged; 29 | IEnumTfRanges *pEnumTextChanges; 30 | ITfRange *pRange; 31 | 32 | // 33 | // did the selection change? 34 | // The selection change includes the movement of caret as well. 35 | // The caret position is represent as the empty selection range when 36 | // there is no selection. 37 | // 38 | if (pEditRecord->GetSelectionStatus(&fSelectionChanged) == S_OK && 39 | fSelectionChanged) 40 | { 41 | } 42 | 43 | // text modification? 44 | if (pEditRecord->GetTextAndPropertyUpdates(TF_GTP_INCL_TEXT, NULL, 0, &pEnumTextChanges) == S_OK) 45 | { 46 | if (pEnumTextChanges->Next(1, &pRange, NULL) == S_OK) 47 | { 48 | // 49 | // pRange is the updated range. 50 | // 51 | 52 | pRange->Release(); 53 | } 54 | 55 | pEnumTextChanges->Release(); 56 | } 57 | 58 | return S_OK; 59 | } 60 | 61 | //+--------------------------------------------------------------------------- 62 | // 63 | // _InitTextEditSink 64 | // 65 | // Init a text edit sink on the topmost context of the document. 66 | // Always release any previous sink. 67 | //---------------------------------------------------------------------------- 68 | 69 | BOOL CTextService::_InitTextEditSink(ITfDocumentMgr *pDocMgr) 70 | { 71 | ITfSource *pSource; 72 | BOOL fRet; 73 | 74 | // clear out any previous sink first 75 | 76 | if (_dwTextEditSinkCookie != TF_INVALID_COOKIE) 77 | { 78 | if (_pTextEditSinkContext->QueryInterface(IID_ITfSource, (void **)&pSource) == S_OK) 79 | { 80 | pSource->UnadviseSink(_dwTextEditSinkCookie); 81 | pSource->Release(); 82 | } 83 | 84 | _pTextEditSinkContext->Release(); 85 | _pTextEditSinkContext = NULL; 86 | _dwTextEditSinkCookie = TF_INVALID_COOKIE; 87 | } 88 | 89 | if (pDocMgr == NULL) 90 | return TRUE; // caller just wanted to clear the previous sink 91 | 92 | // setup a new sink advised to the topmost context of the document 93 | 94 | if (pDocMgr->GetTop(&_pTextEditSinkContext) != S_OK) 95 | return FALSE; 96 | 97 | if (_pTextEditSinkContext == NULL) 98 | return TRUE; // empty document, no sink possible 99 | 100 | fRet = FALSE; 101 | 102 | if (_pTextEditSinkContext->QueryInterface(IID_ITfSource, (void **)&pSource) == S_OK) 103 | { 104 | if (pSource->AdviseSink(IID_ITfTextEditSink, (ITfTextEditSink *)this, &_dwTextEditSinkCookie) == S_OK) 105 | { 106 | fRet = TRUE; 107 | } 108 | else 109 | { 110 | _dwTextEditSinkCookie = TF_INVALID_COOKIE; 111 | } 112 | pSource->Release(); 113 | } 114 | 115 | if (fRet == FALSE) 116 | { 117 | _pTextEditSinkContext->Release(); 118 | _pTextEditSinkContext = NULL; 119 | } 120 | 121 | return fRet; 122 | } 123 | -------------------------------------------------------------------------------- /TrackTextChange/TextService.def: -------------------------------------------------------------------------------- 1 | LIBRARY TextService.dll 2 | 3 | EXPORTS 4 | DllGetClassObject PRIVATE 5 | DllCanUnloadNow PRIVATE 6 | DllRegisterServer PRIVATE 7 | DllUnregisterServer PRIVATE 8 | -------------------------------------------------------------------------------- /TrackTextChange/TextService.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // TextService.h 11 | // 12 | // CTextService declaration. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef TEXTSERVICE_H 17 | #define TEXTSERVICE_H 18 | 19 | class CTextService : public ITfTextInputProcessor, 20 | public ITfThreadMgrEventSink, 21 | public ITfTextEditSink 22 | { 23 | public: 24 | CTextService(); 25 | ~CTextService(); 26 | 27 | // IUnknown 28 | STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj); 29 | STDMETHODIMP_(ULONG) AddRef(void); 30 | STDMETHODIMP_(ULONG) Release(void); 31 | 32 | // ITfTextInputProcessor 33 | STDMETHODIMP Activate(ITfThreadMgr *pThreadMgr, TfClientId tfClientId); 34 | STDMETHODIMP Deactivate(); 35 | 36 | // ITfThreadMgrEventSink 37 | STDMETHODIMP OnInitDocumentMgr(ITfDocumentMgr *pDocMgr); 38 | STDMETHODIMP OnUninitDocumentMgr(ITfDocumentMgr *pDocMgr); 39 | STDMETHODIMP OnSetFocus(ITfDocumentMgr *pDocMgrFocus, ITfDocumentMgr *pDocMgrPrevFocus); 40 | STDMETHODIMP OnPushContext(ITfContext *pContext); 41 | STDMETHODIMP OnPopContext(ITfContext *pContext); 42 | 43 | // ITfTextEditSink 44 | STDMETHODIMP OnEndEdit(ITfContext *pContext, TfEditCookie ecReadOnly, ITfEditRecord *pEditRecord); 45 | 46 | // CClassFactory factory callback 47 | static HRESULT CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObj); 48 | 49 | ITfThreadMgr *_GetThreadMgr() { return _pThreadMgr; } 50 | 51 | private: 52 | // initialize and uninitialize ThreadMgrEventSink. 53 | BOOL _InitThreadMgrEventSink(); 54 | void _UninitThreadMgrEventSink(); 55 | 56 | // initialize TextEditSink. 57 | BOOL _InitTextEditSink(ITfDocumentMgr *pDocMgr); 58 | 59 | // 60 | // state 61 | // 62 | ITfThreadMgr *_pThreadMgr; 63 | 64 | // The cookie of ThreadMgrEventSink 65 | DWORD _dwThreadMgrEventSinkCookie; 66 | 67 | // 68 | // private variables for TextEditSink 69 | // 70 | ITfContext *_pTextEditSinkContext; 71 | DWORD _dwTextEditSinkCookie; 72 | 73 | LONG _cRef; // COM ref count 74 | }; 75 | 76 | 77 | #endif // TEXTSERVICE_H 78 | -------------------------------------------------------------------------------- /TrackTextChange/TextService.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/TrackTextChange/TextService.ico -------------------------------------------------------------------------------- /TrackTextChange/TextService.rc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // TextService.rc 11 | // 12 | // Resources. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | 17 | IDI_TEXTSERVICE ICON TextService.ico 18 | 19 | -------------------------------------------------------------------------------- /TrackTextChange/default.asp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathancorvussolis/code-gallery-tsf-samples/5a106af0c06dfda822c84938632b77b3255e6696/TrackTextChange/default.asp -------------------------------------------------------------------------------- /TrackTextChange/globals.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // 3 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 4 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 5 | // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | // PARTICULAR PURPOSE. 7 | // 8 | // Copyright (C) 2003 Microsoft Corporation. All rights reserved. 9 | // 10 | // Globals.h 11 | // 12 | // Global variable declarations. 13 | // 14 | ////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef GLOBALS_H 17 | #define GLOBALS_H 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include "msctf.h" 24 | 25 | void DllAddRef(); 26 | void DllRelease(); 27 | 28 | #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0])) 29 | 30 | #define TEXTSERVICE_LANGID MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US) 31 | 32 | #define TEXTSERVICE_DESC L"Sample Text Service" 33 | #define TEXTSERVICE_DESC_A "Sample Text Service" 34 | #define TEXTSERVICE_MODEL TEXT("Apartment") 35 | 36 | #define TEXTSERVICE_ICON_INDEX 0 37 | 38 | extern HINSTANCE g_hInst; 39 | 40 | extern LONG g_cRefDll; 41 | 42 | extern CRITICAL_SECTION g_cs; 43 | 44 | extern const CLSID c_clsidTextService; 45 | 46 | extern const GUID c_guidProfile; 47 | 48 | 49 | #endif // GLOBALS_H 50 | -------------------------------------------------------------------------------- /TrackTextChange/makefile: -------------------------------------------------------------------------------- 1 | #----- set the project name -------------------------------------------------------------- 2 | Proj = TextService 3 | 4 | #----- Include the PSDK's WIN32.MAK to pick up defines ----------------------------------- 5 | !include 6 | 7 | #----- OUTDIR is defined in WIN32.MAK This is the name of the destination directory ------ 8 | all: $(OUTDIR)\$(Proj).dll 9 | 10 | LINK32_OBJS= \ 11 | $(OUTDIR)\TextService.obj \ 12 | $(OUTDIR)\ThreadMgrEventSink.obj \ 13 | $(OUTDIR)\TextEditSink.obj \ 14 | $(OUTDIR)\Dllmain.obj \ 15 | $(OUTDIR)\Globals.obj \ 16 | $(OUTDIR)\PreComp.obj \ 17 | $(OUTDIR)\Register.obj \ 18 | $(OUTDIR)\Server.obj 19 | 20 | #----- If OUTDIR does not exist, then create directory 21 | $(OUTDIR) : 22 | if not exist "$(OUTDIR)/$(NULL)" mkdir $(OUTDIR) 23 | 24 | #----- add the preprocessor definitions needed by this project --------------------------- 25 | 26 | #----- set the libraries needed by this project ------------------------------------------ 27 | LINK_LIBS = $(dlllibs) $(guilibs) $(olelibs) 28 | 29 | #--------------------- DLL --------------------------------------------------------------- 30 | #PLEASE REFER TO WIN32.MAK for the different Linker options WIN32.MAK provides 31 | 32 | # Build rule for DLL 33 | $(OUTDIR)\$(Proj).dll: $(OUTDIR) $(LINK32_OBJS) $(OUTDIR)\$(Proj).res 34 | $(link) $(ldebug) $(dllllflags) \ 35 | $(LINK32_OBJS) $(OUTDIR)\$(Proj).res $(LINK_LIBS) \ 36 | -base:0x20000000 \ 37 | -out:$(OUTDIR)\$(Proj).dll \ 38 | -def:$(Proj).def 39 | 40 | #--------------------- Compiling C/CPP Files --------------------------------------------- 41 | #PLEASE REFER TO WIN32.MAK for the different Compiler options WIN32.MAK provides 42 | 43 | FILE=TextService 44 | 45 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 46 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 47 | 48 | FILE=ThreadMgrEventSink 49 | 50 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 51 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 52 | 53 | FILE=TextEditSink 54 | 55 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 56 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 57 | 58 | FILE=Dllmain 59 | 60 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 61 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 62 | 63 | FILE=Globals 64 | 65 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 66 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 67 | 68 | FILE=Precomp 69 | 70 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 71 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 72 | 73 | FILE=Register 74 | 75 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 76 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 77 | 78 | FILE=Server 79 | 80 | $(OUTDIR)\$(FILE).obj : .\$(FILE).cpp $(OUTDIR) 81 | $(cc) $(cdebug) $(cflags) $(cvarsdll) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" .\$(FILE).cpp 82 | 83 | 84 | #--------------------- Compiling Resource Files ------------------------------------------ 85 | #PLEASE REFER TO WIN32.MAK for the different Resource Compiler options WIN32.MAK provides 86 | 87 | # Build rule for resource file 88 | FILE=TextService 89 | 90 | $(OUTDIR)\$(FILE).res: .\$(FILE).rc $(OUTDIR) 91 | $(rc) $(rcflags) $(rcvars) /fo $(OUTDIR)\$(FILE).res .\$(FILE).rc 92 | 93 | #--------------------- Clean Rule -------------------------------------------------------- 94 | # Rules for cleaning out those old files 95 | clean: 96 | $(CLEANUP) 97 | -------------------------------------------------------------------------------- /TrackTextChange/sample.asp: -------------------------------------------------------------------------------- 1 | <% response.redirect "default.asp" %> 2 | 3 | 4 | 5 | --------------------------------------------------------------------------------