InkOverlayEv.h
C:\home\SVGCats_src\src\InkOverlayEv.h
[–ÚŽŸ | Œ^EƒNƒ‰ƒXE\‘¢‘Ì | ƒ}ƒNƒ]
–ÚŽŸ
- 1. IUnknown Interface
- 2. IDispatch Interface
- 3. Events - overridden functions
- 4. Methods
- 5. Data Members
Œ^EƒNƒ‰ƒXE\‘¢‘̈ꗗ
ƒ}ƒNƒˆê——
1|/* 2|* This file was made by refering from Tablet PC SDK. 3|* "E:\Program Files\Microsoft Tablet PC Platform SDK\Samples\EventSink\TpcConpt.h" 4|*/ 5| 6|#ifndef INKOVERLEYEV_H 7|#define INKOVERLEYEV_H 8| 9|class InkOverlayEvents : public _IInkOverlayEvents 10|{ 11|public: 12| 13| // 14| // 1. <<< IUnknown Interface >>> ========================================= 15| // 16| HRESULT __stdcall QueryInterface( 17| REFIID riid, 18| void **ppvObject) 19| { 20| 21| // Validate the input 22| if (NULL == ppvObject) 23| { 24| return E_POINTER; 25| } 26| 27| // This object only supports IDispatch/_IInkOverlayEvents 28| if ((riid == IID_IUnknown) 29| || (riid == IID_IDispatch) 30| || (riid == DIID__IInkOverlayEvents)) 31| { 32| *ppvObject = (IDispatch *) this; 33| 34| // Note: we do not AddRef here because the lifetime 35| // of this object does not depend on reference counting 36| // but on the duration of the connection set up by 37| // the user of this class. 38| 39| return S_OK; 40| } 41| else if (riid == IID_IMarshal) 42| { 43| // Assert that the free threaded marshaller has been 44| // initialized. It is necessary to call Init() before 45| // invoking this method. 46| ASSERT(NULL != m_punkFTM); 47| 48| // Use free threaded marshalling. 49| return m_punkFTM->QueryInterface(riid, ppvObject); 50| } 51| 52| return E_NOINTERFACE; 53| } 54| 55| virtual ULONG STDMETHODCALLTYPE AddRef() 56| { 57| 58| // Note: we do not AddRef here because the lifetime 59| // of this object does not depend on reference counting 60| // but on the duration of the connection set up by 61| // the user of this class. 62| return 1; 63| } 64| 65| virtual ULONG STDMETHODCALLTYPE Release() 66| { 67| 68| // Note: we do not do Release here because the lifetime 69| // of this object does not depend on reference counting 70| // but on the duration of the connection set up by 71| // the user of this class. 72| return 1; 73| } 74| 75| 76| // 77| // 2. <<< IDispatch Interface >>> ========================================= 78| // 79| STDMETHOD(GetTypeInfoCount)(UINT* pctinfo) 80| { 81| // This method is not needed for processing events. 82| return E_NOTIMPL; 83| } 84| 85| STDMETHOD(GetTypeInfo)( 86| UINT itinfo, 87| LCID lcid, 88| ITypeInfo** pptinfo) 89| { 90| // This method is not needed for processing events. 91| return E_NOTIMPL; 92| } 93| 94| STDMETHOD(GetIDsOfNames)( 95| REFIID riid, 96| LPOLESTR* rgszNames, 97| UINT cNames, 98| LCID lcid, 99| DISPID* rgdispid) 100| { 101| // This method is not needed for processing events. 102| return E_NOTIMPL; 103| } 104| 105| // Invoke translates from IDispatch to an event callout 106| // that can be overriden by a subclass of this class. 107| STDMETHOD(Invoke)( 108| DISPID dispidMember, 109| REFIID riid, 110| LCID lcid, 111| WORD /*wFlags*/, 112| DISPPARAMS* pdispparams, 113| VARIANT* pvarResult, 114| EXCEPINFO* /*pexcepinfo*/, 115| UINT* /*puArgErr*/) 116| { 117| switch(dispidMember) 118| { 119| case DISPID_ICEStroke: 120| Stroke( 121| (IInkCursor*) pdispparams->rgvarg[2].pdispVal, 122| (IInkStrokeDisp*) pdispparams->rgvarg[1].pdispVal, 123| (VARIANT_BOOL *)pdispparams->rgvarg[0].pboolVal); 124| break; 125| 126| case DISPID_ICECursorDown: 127| CursorDown( 128| (IInkCursor*) pdispparams->rgvarg[1].pdispVal, 129| (IInkStrokeDisp*) pdispparams->rgvarg[0].pdispVal); 130| break; 131| 132| case DISPID_ICENewPackets: 133| NewPackets( 134| (IInkCursor*) pdispparams->rgvarg[3].pdispVal, 135| (IInkStrokeDisp*) pdispparams->rgvarg[2].pdispVal, 136| pdispparams->rgvarg[1].lVal, 137| pdispparams->rgvarg[0].pvarVal); 138| break; 139| 140| case DISPID_IOEStrokesDeleting: 141| StrokesDeleting( 142| (IInkStrokes*)pdispparams->rgvarg[0].pboolVal); 143| break; 144| 145| case DISPID_IPEDblClick: 146| DblClick( 147| (VARIANT_BOOL *)pdispparams->rgvarg[0].pboolVal); 148| break; 149| 150| case DISPID_IPEMouseMove: 151| MouseMove( 152| (InkMouseButton) pdispparams->rgvarg[4].lVal, 153| (InkShiftKeyModifierFlags) pdispparams->rgvarg[3].lVal, 154| pdispparams->rgvarg[2].lVal, 155| pdispparams->rgvarg[1].lVal, 156| (VARIANT_BOOL *)pdispparams->rgvarg[0].pboolVal); 157| break; 158| 159| case DISPID_IPEMouseDown: 160| MouseDown( 161| (InkMouseButton) pdispparams->rgvarg[4].lVal, 162| (InkShiftKeyModifierFlags) pdispparams->rgvarg[3].lVal, 163| pdispparams->rgvarg[2].lVal, 164| pdispparams->rgvarg[1].lVal, 165| (VARIANT_BOOL *)pdispparams->rgvarg[0].pboolVal); 166| break; 167| 168| case DISPID_IPEMouseUp: 169| MouseUp( 170| (InkMouseButton) pdispparams->rgvarg[4].lVal, 171| (InkShiftKeyModifierFlags) pdispparams->rgvarg[3].lVal, 172| pdispparams->rgvarg[2].lVal, 173| pdispparams->rgvarg[1].lVal, 174| (VARIANT_BOOL *)pdispparams->rgvarg[0].pboolVal); 175| break; 176| 177| case DISPID_IPEMouseWheel: 178| MouseWheel( 179| (InkMouseButton) pdispparams->rgvarg[5].lVal, 180| (InkShiftKeyModifierFlags) pdispparams->rgvarg[4].lVal, 181| pdispparams->rgvarg[3].lVal, 182| pdispparams->rgvarg[2].lVal, 183| pdispparams->rgvarg[1].lVal, 184| (VARIANT_BOOL *)pdispparams->rgvarg[0].pboolVal); 185| break; 186| 187| case DISPID_ICENewInAirPackets: 188| NewInAirPackets( 189| (IInkCursor*) pdispparams->rgvarg[2].pdispVal, 190| pdispparams->rgvarg[1].lVal, 191| pdispparams->rgvarg[0].pvarVal); 192| break; 193| 194| case DISPID_ICECursorButtonDown: 195| CursorButtonDown( 196| (IInkCursor*) pdispparams->rgvarg[1].pdispVal, 197| (IInkCursorButton*) pdispparams->rgvarg[0].pdispVal); 198| break; 199| 200| case DISPID_ICECursorButtonUp: 201| CursorButtonUp( 202| (IInkCursor*) pdispparams->rgvarg[1].pdispVal, 203| (IInkCursorButton*) pdispparams->rgvarg[0].pdispVal); 204| break; 205| 206| case DISPID_ICECursorInRange: 207| CursorInRange( 208| (IInkCursor*) pdispparams->rgvarg[2].pdispVal, 209| (VARIANT_BOOL) pdispparams->rgvarg[1].iVal, 210| pdispparams->rgvarg[0]); 211| break; 212| 213| case DISPID_ICECursorOutOfRange: 214| CursorOutOfRange( 215| (IInkCursor*) pdispparams->rgvarg[0].pdispVal); 216| break; 217| 218| case DISPID_ICESystemGesture: 219| SystemGesture( 220| (IInkCursor*) pdispparams->rgvarg[6].pdispVal, 221| (InkSystemGesture) pdispparams->rgvarg[5].lVal, 222| pdispparams->rgvarg[4].lVal, 223| pdispparams->rgvarg[3].lVal, 224| pdispparams->rgvarg[2].lVal, 225| pdispparams->rgvarg[1].bstrVal, 226| pdispparams->rgvarg[0].lVal); 227| break; 228| 229| case DISPID_ICEGesture: 230| Gesture( 231| (IInkCursor*) pdispparams->rgvarg[3].pdispVal, 232| (IInkStrokes*) pdispparams->rgvarg[2].pdispVal, 233| pdispparams->rgvarg[1], 234| (VARIANT_BOOL *)pdispparams->rgvarg[0].pboolVal); 235| break; 236| 237| case DISPID_ICETabletAdded: 238| TabletAdded( 239| (IInkTablet*) pdispparams->rgvarg[0].pdispVal); 240| break; 241| 242| case DISPID_ICETabletRemoved: 243| TabletRemoved( 244| pdispparams->rgvarg[0].lVal); 245| break; 246| 247| default: 248| break; 249| } 250| 251| return S_OK; 252| } 253| 254| 255| // 256| // 3. <<< Events - overridden functions >>> ========================= 257| // 258| 259| virtual void Stroke( 260| IInkCursor* Cursor, 261| IInkStrokeDisp* Stroke, 262| VARIANT_BOOL *Cancel) 263| { 264| ASSERT( m_obj != NULL ); 265| m_obj->OnStroke( Cursor, Stroke, Cancel ); 266| return; 267| } 268| 269| virtual void CursorDown( 270| IInkCursor* Cursor, 271| IInkStrokeDisp* Stroke) 272| { 273| ASSERT( m_obj != NULL ); 274| m_obj->OnCursorDown( Cursor, Stroke ); 275| return; 276| } 277| 278| virtual void NewPackets( 279| IInkCursor* Cursor, 280| IInkStrokeDisp* Stroke, 281| long PacketCount, 282| VARIANT* PacketData) 283| { 284| ASSERT( m_obj != NULL ); 285| m_obj->OnNewPackets( Cursor, Stroke, PacketCount, PacketData ); 286| return; 287| } 288| 289| virtual void StrokesDeleting( 290| IInkStrokes* Strokes) 291| { 292| ASSERT( m_obj != NULL ); 293| m_obj->OnStrokesDeleting( Strokes ); 294| return; 295| } 296| 297| virtual void DblClick( 298| VARIANT_BOOL *Cancel) 299| { 300| // This is a place holder designed to be overridden by 301| // user of this class. 302| return; 303| } 304| 305| virtual void MouseMove( 306| InkMouseButton Button, 307| InkShiftKeyModifierFlags Shift, 308| long pX, 309| long pY, 310| VARIANT_BOOL *Cancel) 311| { 312| // This is a place holder designed to be overridden by 313| // user of this class. 314| return; 315| } 316| 317| virtual void MouseDown( 318| InkMouseButton Button, 319| InkShiftKeyModifierFlags Shift, 320| long pX, 321| long pY, 322| VARIANT_BOOL *Cancel) 323| { 324| // This is a place holder designed to be overridden by 325| // user of this class. 326| return; 327| } 328| 329| virtual void MouseUp( 330| InkMouseButton Button, 331| InkShiftKeyModifierFlags Shift, 332| long pX, 333| long pY, 334| VARIANT_BOOL *Cancel) 335| { 336| // This is a place holder designed to be overridden by 337| // user of this class. 338| return; 339| } 340| 341| virtual void MouseWheel( 342| InkMouseButton Button, 343| InkShiftKeyModifierFlags Shift, 344| long Delta, 345| long X, 346| long Y, 347| VARIANT_BOOL *Cancel) 348| { 349| // This is a place holder designed to be overridden by 350| // user of this class. 351| return; 352| } 353| 354| virtual void NewInAirPackets( 355| IInkCursor* Cursor, 356| long lPacketCount, 357| VARIANT* PacketData) 358| { 359| // This is a place holder designed to be overridden by 360| // user of this class. 361| return; 362| } 363| 364| virtual void CursorButtonDown( 365| IInkCursor* Cursor, 366| IInkCursorButton* Button) 367| { 368| // This is a place holder designed to be overridden by 369| // user of this class. 370| return; 371| } 372| 373| virtual void CursorButtonUp( 374| IInkCursor* Cursor, 375| IInkCursorButton* Button) 376| { 377| // This is a place holder designed to be overridden by 378| // user of this class. 379| return; 380| } 381| 382| virtual void CursorInRange( 383| IInkCursor* Cursor, 384| VARIANT_BOOL NewCursor, 385| VARIANT ButtonsState) 386| { 387| // This is a place holder designed to be overridden by 388| // user of this class. 389| return; 390| } 391| 392| virtual void CursorOutOfRange( 393| IInkCursor* Cursor) 394| { 395| // This is a place holder designed to be overridden by 396| // user of this class. 397| return; 398| } 399| 400| virtual void SystemGesture( 401| IInkCursor* Cursor, 402| InkSystemGesture Id, 403| long X, 404| long Y, 405| long Modifier, 406| BSTR Character, 407| long CursorMode) 408| { 409| ASSERT( m_obj != NULL ); 410| m_obj->OnSystemGesture( Cursor, Id, X, Y, Modifier, Character, CursorMode ); 411| return; 412| } 413| 414| virtual void Gesture( 415| IInkCursor* Cursor, 416| IInkStrokes* Strokes, 417| VARIANT Gestures, 418| VARIANT_BOOL* Cancel) 419| { 420| // This is a place holder designed to be overridden by 421| // user of this class. 422| return; 423| } 424| 425| virtual void TabletAdded( 426| IInkTablet* Tablet) 427| { 428| // This is a place holder designed to be overridden by 429| // user of this class. 430| return; 431| } 432| 433| virtual void TabletRemoved( 434| long TabletId) 435| { 436| // This is a place holder designed to be overridden by 437| // user of this class. 438| return; 439| } 440| 441| 442| // 443| // 4. <<< Methods >>> ============================================ 444| // 445| 446| // Constructor: initialize memory to null. 447| InkOverlayEvents() 448| { 449| m_pIConnectionPoint = NULL; 450| m_punkFTM = NULL; 451| m_obj = NULL; 452| } 453| 454| // Destructor: free resources 455| ~InkOverlayEvents() 456| { 457| UnadviseInkOverlay(); 458| 459| if (m_punkFTM != NULL) 460| { 461| m_punkFTM->Release(); 462| } 463| } 464| 465| // Init: set up free threaded marshaller. 466| // It is necessary to call this method before using 467| // this class to handle events. 468| HRESULT Init() 469| { 470| return CoCreateFreeThreadedMarshaler(this, &m_punkFTM); 471| } 472| 473| // Set up connection between sink and Ink Collector 474| HRESULT AdviseInkOverlay( 475| IInkOverlay *pIInkOverlay) 476| { 477| HRESULT hr = S_OK; 478| 479| // Check to ensure that the sink is not currently connected 480| // with another Ink Collector... 481| if (NULL == m_pIConnectionPoint) 482| { 483| // Get the connection point container 484| IConnectionPointContainer *pIConnectionPointContainer; 485| hr = pIInkOverlay->QueryInterface( 486| IID_IConnectionPointContainer, 487| (void **) &pIConnectionPointContainer); 488| 489| if (FAILED(hr)) 490| { 491| return hr; 492| } 493| 494| // Find the connection point for Ink Collector events 495| hr = pIConnectionPointContainer->FindConnectionPoint( 496| __uuidof(_IInkOverlayEvents), &m_pIConnectionPoint); 497| 498| if (SUCCEEDED(hr)) 499| { 500| // Hook up sink to connection point 501| hr = m_pIConnectionPoint->Advise(this, &m_dwCookie); 502| } 503| 504| if (FAILED(hr)) 505| { 506| // Clean up after an error. 507| if (m_pIConnectionPoint) 508| { 509| m_pIConnectionPoint->Release(); 510| m_pIConnectionPoint = NULL; 511| } 512| } 513| 514| // We don't need the connection point container any more. 515| pIConnectionPointContainer->Release(); 516| } 517| // If the sink is already connected to an Ink Collector, return a 518| // failure; only one Ink Collector can be attached at any given time. 519| else 520| { 521| hr = E_FAIL; 522| } 523| 524| return hr; 525| } 526| 527| // Remove the connection of the sink to the Ink Collector 528| HRESULT UnadviseInkOverlay() 529| { 530| HRESULT hr = S_OK; 531| 532| // If there the ink collector is connected to the sink, 533| // remove it. Otherwise, do nothing (there is nothing 534| // to unadvise). 535| if (m_pIConnectionPoint != NULL) 536| { 537| hr = m_pIConnectionPoint->Unadvise(m_dwCookie); 538| m_pIConnectionPoint->Release(); 539| m_pIConnectionPoint = NULL; 540| } 541| 542| return hr; 543| } 544| 545|private: 546| 547| // 548| // 5. <<< Data Members >>> ============================================ 549| // 550| 551| // Connection point on InkOverlay 552| IConnectionPoint *m_pIConnectionPoint; 553| 554| // Cookie returned from advise 555| DWORD m_dwCookie; 556| 557| // Free threaded marshaler. 558| IUnknown *m_punkFTM; 559| 560|public: 561| // owner 562| CChildView* m_obj; // You can access directly. 563|}; 564| 565| 566| 567|#endif 568| 569|
'COM, ATL' 카테고리의 다른 글
엑셀 오토메이션 (1) | 2008.09.03 |
---|---|
ATL_NO_VTABLE (2) | 2008.08.30 |
BSTR 자료형 고찰과 사용시 주의점 (2) | 2008.08.29 |
How ATL Implements Connections (0) | 2008.08.28 |
http://blog.naver.com/c_user/40052542493 - 블로그 링크 com atl 자료 링크 (1) | 2008.08.28 |
what is different between dispinterface and interface in IDL ? (0) | 2008.08.28 |
The AtlSink.exe sample demonstrates how to implement a dispinterface sink by using the Active Template Library (ATL) in Visual C++ (1) | 2008.08.28 |