void CMainWindow::Init() { tstring strPath = ZYM::CPath::GetCurDir() + _T("Face\\FaceConfig.xml"); m_FaceList.LoadConfigFile(strPath.c_str()); m_pMinSysBtn = static_cast<CButtonUI*>(paint_manager_.FindControl(_T("btnMinSys"))); m_pMaxSysBtn = static_cast<CButtonUI*>(paint_manager_.FindControl(_T("btnMaxSys"))); m_pRestoreSysBtn = static_cast<CButtonUI*>(paint_manager_.FindControl(_T("btnRestoreSys"))); m_pCloseSysBtn = static_cast<CButtonUI*>(paint_manager_.FindControl(_T("btnCloseSys"))); m_pFontBtn = static_cast<CButtonUI*>(paint_manager_.FindControl(_T("btnFont"))); m_pFaceBtn = static_cast<CButtonUI*>(paint_manager_.FindControl(_T("btnFace"))); m_pImageBtn = static_cast<CButtonUI*>(paint_manager_.FindControl(_T("btnImage"))); m_pFontNameCombo = static_cast<CComboUI*>(paint_manager_.FindControl(_T("cboFontName"))); m_pFontSizeCombo = static_cast<CComboUI*>(paint_manager_.FindControl(_T("cboFontSize"))); m_pBoldBtn = static_cast<COptionUI*>(paint_manager_.FindControl(_T("btnBold"))); m_pItalicBtn = static_cast<COptionUI*>(paint_manager_.FindControl(_T("btnItalic"))); m_pUnderLineBtn = static_cast<COptionUI*>(paint_manager_.FindControl(_T("btnUnderLine"))); m_pColorBtn = static_cast<CButtonUI*>(paint_manager_.FindControl(_T("btnColor"))); m_pCloseBtn = static_cast<CButtonUI*>(paint_manager_.FindControl(_T("btnClose"))); m_pSendBtn = static_cast<CButtonUI*>(paint_manager_.FindControl(_T("btnSend"))); m_pSendEdit = static_cast<CRichEditUI*>(paint_manager_.FindControl(_T("richSend"))); m_pRecvEdit = static_cast<CRichEditUI*>(paint_manager_.FindControl(_T("richRecv"))); DragAcceptFiles(m_hWnd, true); IRichEditOleCallback2* pRichEditOleCallback2 = NULL; HRESULT hr = ::CoCreateInstance(CLSID_ImageOle, NULL, CLSCTX_INPROC_SERVER, __uuidof(IRichEditOleCallback2), (void**)&pRichEditOleCallback2); if (SUCCEEDED(hr)) { pRichEditOleCallback2->SetNotifyHwnd(m_hWnd); ITextServices * pTextServices = m_pRecvEdit->GetTextServices(); pRichEditOleCallback2->SetTextServices(pTextServices); pTextServices->Release(); m_pRecvEdit->SetOleCallback(pRichEditOleCallback2); pRichEditOleCallback2->Release(); } pRichEditOleCallback2 = NULL; hr = ::CoCreateInstance(CLSID_ImageOle, NULL, CLSCTX_INPROC_SERVER, __uuidof(IRichEditOleCallback2), (void**)&pRichEditOleCallback2); if (SUCCEEDED(hr)) { pRichEditOleCallback2->SetNotifyHwnd(m_hWnd); ITextServices * pTextServices = m_pSendEdit->GetTextServices(); pRichEditOleCallback2->SetTextServices(pTextServices); pTextServices->Release(); m_pSendEdit->SetOleCallback(pRichEditOleCallback2); pRichEditOleCallback2->Release(); } IDropTarget *pdt = m_pSendEdit->GetTxDropTarget(); hr = ::RegisterDragDrop(m_hWnd, pdt); pdt->Release(); }
void CFolderHander::OnInit( SWindow *pFolderRoot ) { m_pFolderRoot = pFolderRoot; SASSERT(m_pFolderRoot); SWindow *pEditDir = m_pFolderRoot->FindChildByName(L"edit_dir"); SASSERT(pEditDir); IDropTarget *pDT = new CDropTarget(this); m_pFolderRoot->GetContainer()->RegisterDragDrop(pEditDir->GetSwnd(),pDT); pDT->Release(); m_pDirTree = m_pFolderRoot->FindChildByName2<STreeCtrl>(L"tree_dir"); }
void CFolderScanHandler::OnInit(SWindow *pRoot) { m_pPageRoot = pRoot->FindChildByName(L"page_folderscan"); SASSERT(m_pPageRoot); SWindow *pEditDir = m_pPageRoot->FindChildByName(L"edit_dir"); SASSERT(pEditDir); IDropTarget *pDT = new CDropTarget(this); m_pPageRoot->GetContainer()->RegisterDragDrop(pEditDir->GetSwnd(),pDT); pDT->Release(); m_pTreelist = m_pPageRoot->FindChildByName2<SFolderTreeList>(L"tree_dir"); SASSERT(m_pTreelist); m_pTreelist->GetFolderTreeCtrl()->GetEventSet()->subscribeEvent(EventTCDbClick::EventID,Subscriber(&CFolderScanHandler::OnTreeDbclick,this)); }
void CDropHandler::HandleRightClickDrop(void) { IShellFolder *pDesktop = NULL; IShellFolder *pShellFolder = NULL; IDropTarget *pDrop = NULL; LPITEMIDLIST pidlDirectory = NULL; DWORD dwe; HRESULT hr; hr = GetIdlFromParsingName(m_szDestDirectory,&pidlDirectory); if(SUCCEEDED(hr)) { hr = SHGetDesktopFolder(&pDesktop); if(SUCCEEDED(hr)) { hr = pDesktop->BindToObject(pidlDirectory,0,IID_IShellFolder,(void **)&pShellFolder); if(SUCCEEDED(hr)) { dwe = *m_pdwEffect; hr = pShellFolder->CreateViewObject(m_hwndDrop,IID_IDropTarget,(void **)&pDrop); if(SUCCEEDED(hr)) { pDrop->DragEnter(m_pDataObject,MK_RBUTTON,m_ptl,&dwe); dwe = *m_pdwEffect; pDrop->Drop(m_pDataObject,m_grfKeyState,m_ptl,&dwe); pDrop->DragLeave(); pDrop->Release(); } pShellFolder->Release(); } pDesktop->Release(); } CoTaskMemFree(pidlDirectory); } }
// @pymethod |PyIDocHostUIHandler|GetDropTarget|Description of GetDropTarget. PyObject *PyIDocHostUIHandler::GetDropTarget(PyObject *self, PyObject *args) { IDocHostUIHandler *pIDHUIH = GetI(self); if ( pIDHUIH == NULL ) return NULL; // @pyparm <o PyIDropTarget>|pDropTarget||Description for pDropTarget PyObject *obpDropTarget; IDropTarget * pDropTarget; IDropTarget * ppDropTarget; if ( !PyArg_ParseTuple(args, "O:GetDropTarget", &obpDropTarget) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obpDropTarget, IID_IDropTarget, (void **)&pDropTarget, TRUE /* bNoneOK */)) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIDHUIH->GetDropTarget( pDropTarget, &ppDropTarget ); if (pDropTarget) pDropTarget->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIDHUIH, IID_IDocHostUIHandler ); return PyCom_PyObjectFromIUnknown(ppDropTarget, IID_IDropTarget, FALSE); }
bool tomEdit::Init() { WLDC dc(this) ; s_XPixelPerInch = dc.GetDeviceCaps(LOGPIXELSX) ; s_YPixelPerInch = dc.GetDeviceCaps(LOGPIXELSY) ; m_ref_count = 1 ; m_show_vert_scroll_bar = false ; m_show_horz_scroll_bar = false ; m_background_transparent = true ; m_use_system_background_color = true ; m_use_system_highlight_text_color = true ; m_use_system_highlight_text_background_color = true ; m_word_wrap = !(GetStyle() & (WS_HSCROLL | ES_AUTOHSCROLL)) ; HRESULT hr ; IUnknown * pUnknown ; // 由于CreateTextServices会触发TxGetCharFormat和TxGetParaFormat, // 所以要在此之前初始化CharFormat和ParaFormat // 初始化CharFormat InitDefaultCharFormat() ; // 初始化ParaFormat InitDefaultParaFormat() ; RECT bound_in_host ; GetRectInHost(&bound_in_host) ; if (FAILED(CreateBorder(IID_IRectangleBorder, (IUnknown**)&m_border))) return FALSE ; m_border->SetPos(bound_in_host.left, bound_in_host.top) ; m_border->SetSize(bound_in_host.right - bound_in_host.left, bound_in_host.bottom - bound_in_host.top) ; m_border->SetInset(m_border_inset.left, m_border_inset.top, m_border_inset.right, m_border_inset.bottom) ; if (FAILED(CreateTextServices(NULL, this, &pUnknown))) return false ; hr = pUnknown->QueryInterface(IID_ITextServices, (void**)&m_services) ; pUnknown->Release() ; if (FAILED(hr)) return false ; // 输入的客户区矩形范围似乎无用,总是会调用ITextHost::TxGetClientRect来获取区域 if (FAILED(m_services->OnTxInPlaceActivate(&bound_in_host))) return false ; LRESULT mask ; m_services->TxSendMessage(EM_GETEVENTMASK, 0, 0, &mask) ; mask |= ENM_SELCHANGE ; m_services->TxSendMessage(EM_SETEVENTMASK, 0, mask, NULL) ; m_call_back = new tomEditCallback(this) ; SetOLECallback(m_call_back) ; // 注册拖拽 IDropTarget * dt = NULL ; if (S_OK == m_services->TxGetDropTarget(&dt)) { RegisterDragDrop(dt) ; dt->Release() ; } return true ; }