bool LLDragDropWin32::init( HWND hWnd ) { if ( NOERROR != OleInitialize( NULL ) ) return FALSE; mDropTarget = new LLDragDropWin32Target( hWnd ); if ( mDropTarget ) { HRESULT result = CoLockObjectExternal( mDropTarget, TRUE, FALSE ); if ( S_OK == result ) { result = RegisterDragDrop( hWnd, mDropTarget ); if ( S_OK != result ) { // RegisterDragDrop failed return false; }; // all ok mDropWindowHandle = hWnd; } else { // Unable to lock OLE object return false; }; }; // success return true; }
BOOL COleDropTarget::Register(CWnd* pWnd) { ASSERT_VALID(this); ASSERT(m_hWnd == NULL); // registering drop target twice? ASSERT_VALID(pWnd); LPUNKNOWN lpUnknown = (LPUNKNOWN)GetInterface(&IID_IUnknown); ASSERT(lpUnknown != NULL); // the object must be locked externally to keep LRPC connections alive if (CoLockObjectExternal(lpUnknown, TRUE, FALSE) != S_OK) return FALSE; // connect the HWND to the IDropTarget implementation if (RegisterDragDrop(pWnd->m_hWnd, (LPDROPTARGET)GetInterface(&IID_IDropTarget)) != S_OK) { CoLockObjectExternal(lpUnknown, FALSE, FALSE); return FALSE; } // connect internal data m_hWnd = pWnd->m_hWnd; ASSERT(pWnd->m_pDropTarget == NULL); pWnd->m_pDropTarget = this; return TRUE; }
void Explorerplusplus::InitializeTabs(void) { /* The tab backing will hold the tab window. */ CreateTabBacking(); if(m_bForceSameTabWidth) { TabCtrlStyles |= TCS_FIXEDWIDTH; } m_hTabCtrl = CreateTabControl(m_hTabBacking,TabCtrlStyles); /* TODO: The image list is been leaked. */ HIMAGELIST himlSmall = ImageList_Create(16,16,ILC_COLOR32|ILC_MASK,0,100); AddDefaultTabIcons(himlSmall); TabCtrl_SetImageList(m_hTabCtrl,himlSmall); /* TODO: Needs to be freed when closing. */ m_pTabContainer = new CTabContainer(m_hTabCtrl,m_pShellBrowser,this); CTabDropHandler *pTabDropHandler = new CTabDropHandler(m_hTabCtrl,m_pTabContainer); RegisterDragDrop(m_hTabCtrl,pTabDropHandler); pTabDropHandler->Release(); SetWindowSubclass(m_hTabCtrl,TabSubclassProcStub,0,reinterpret_cast<DWORD_PTR>(this)); /* Create the toolbar that will appear on the tab control. Only contains the close button used to close tabs. */ TCHAR szTabCloseTip[64]; LoadString(m_hLanguageModule,IDS_TAB_CLOSE_TIP,szTabCloseTip,SIZEOF_ARRAY(szTabCloseTip)); m_hTabWindowToolbar = CreateTabToolbar(m_hTabBacking,TABTOOLBAR_CLOSE,szTabCloseTip); }
bool DesktopShellView::InitDragDrop() { CONTEXT("DesktopShellView::InitDragDrop()"); DesktopDropTarget * pDropTarget = new DesktopDropTarget(_hwnd); if (!pDropTarget) return false; pDropTarget->AddRef(); if (FAILED(RegisterDragDrop(_hwnd, pDropTarget))) { pDropTarget->Release(); return false; } FORMATETC ftetc; ftetc.dwAspect = DVASPECT_CONTENT; ftetc.lindex = -1; ftetc.tymed = TYMED_HGLOBAL; ftetc.cfFormat = CF_HDROP; pDropTarget->AddSuportedFormat(ftetc); pDropTarget->Release(); return true; }
bool ISimpleDropTarget::Register(HWND hwnd) { if (IsWindow(m_hwnd)) { Unregister(); } if (!IsWindow(hwnd)) { throw L"Tried to register non window for Drag&Drop!"; return false; } HRESULT result = OleInitialize(NULL); if (SUCCEEDED(result)) { result = RegisterDragDrop(hwnd, this); if (SUCCEEDED(result)) { m_hwnd = hwnd; return true; } else { RevokeDragDrop(hwnd); OleUninitialize(); throw L"Drag&Drop already attached to window!"; } } else { throw L"Drag&Drop already attached to window!"; OleUninitialize(); } return false; }
bool DropHandler::RegisterHandler(HWND dropWindow, bool revokeOnDtor) { // ensure not already registered if (_isRegistered) return false; // save the IDropTarget of the shell folder of the working directory LOG(QString_NT("Drop registered to %1").arg(native(scnManager->getWorkingDirectory()))); IShellFolder2 * shellFolder = winOS->GetShellFolderFromAbsDirPath( native(scnManager->getWorkingDirectory())); if (shellFolder) { // try and coerce the drop target interface from the shell folder IDropTarget * dropTarget = NULL; shellFolder->CreateViewObject(NULL, IID_IDropTarget, (void **) &dropTarget); if (dropTarget) { _workingDirectoryDropTarget = dropTarget; } shellFolder->Release(); } // register and return status _revokeOnDestroy = revokeOnDtor; _dropWindow = dropWindow; _isRegistered = SUCCEEDED(RegisterDragDrop(_dropWindow, this)); return _isRegistered; }
bool ShellBrowserChild::InitDragDrop() { CONTEXT("ShellBrowserChild::InitDragDrop()"); _pDropTarget = new TreeDropTarget(_left_hwnd); if (!_pDropTarget) return false; _pDropTarget->AddRef(); if (FAILED(RegisterDragDrop(_left_hwnd, _pDropTarget))) {//calls addref _pDropTarget->Release(); // free TreeDropTarget _pDropTarget = NULL; return false; } else _pDropTarget->Release(); FORMATETC ftetc; ftetc.dwAspect = DVASPECT_CONTENT; ftetc.lindex = -1; ftetc.tymed = TYMED_HGLOBAL; ftetc.cfFormat = CF_HDROP; _pDropTarget->AddSuportedFormat(ftetc); return true; }
void QWindowsWindow::registerDropSite() { if (m_data.hwnd && !m_dropTarget) { m_dropTarget = new QWindowsOleDropTarget(window()); RegisterDragDrop(m_data.hwnd, m_dropTarget); CoLockObjectExternal(m_dropTarget, true, true); } }
BOOL CDLListWindow::OnInitDialog(CWindow wndFocus, LPARAM lInitParam) { m_nDownloading = 0; WM_DLCOMPLETE = ::RegisterWindowMessage(REGISTERMESSAGE_DLCOMPLETE); DoDataExchange(DDX_LOAD); m_editDLFolder = m_cmbDLFolder.GetDlgItem(1001); // ダイアログリサイズ初期化 DlgResize_Init(true, true, WS_THICKFRAME | WS_CLIPCHILDREN); for (int i = 1; i <= 5; ++i) { CString str; str.Append(i); m_cmbParallelDL.AddString(str); } /* 設定を復元する */ CIniFileI pr(CDLOptions::s_DLIniFilePath, _T("DLList")); m_cmbParallelDL.SetCurSel(pr.GetValue(_T("ParallelDL"), 0)); CRect rcWindow; rcWindow.top = pr.GetValue(_T("top"), -1); rcWindow.left = pr.GetValue(_T("left"), -1); rcWindow.right = pr.GetValue(_T("right"), -1); rcWindow.bottom = pr.GetValue(_T("bottom"), -1); if (rcWindow != CRect(-1, -1, -1, -1)) MoveWindow(rcWindow); // 位置を復元 // リストビューを準備 m_DLList.InsertColumn(0, _T("URL")); m_DLList.SetColumnWidth(0, pr.GetValue(_T("ColumnWidthURL"), 300)); int nCount = (int)CDLOptions::s_vecImageDLFolderHistory.size(); for (int i = 0; i < nCount; ++i) { m_cmbDLFolder.AddString(CDLOptions::s_vecImageDLFolderHistory[i]); } // ImageDLFolderのパスに設定 m_cmbDLFolder.SetWindowText(CDLOptions::strImgDLFolderPath); m_cmbDLOption.AddString(_T("上書きの確認をする")); m_cmbDLOption.AddString(_T("上書きの確認をしない")); m_cmbDLOption.AddString(_T("連番を付ける")); m_cmbDLOption.SetCurSel(pr.GetValue(_T("DLOption"), 0)); RegisterDragDrop(); CMessageLoop *pLoop = _Module.GetMessageLoop(); pLoop->AddMessageFilter(this); return FALSE; }
BOOL DropTarget::DragRegister(HWND hwnd) { ASSERT(hwnd_ == NULL); HRESULT result = RegisterDragDrop(hwnd, this); if(result != S_OK) return FALSE; hwnd_ = hwnd; return TRUE; }
NUIRenderHandler::NUIRenderHandler(NUIClient* client) : m_paintingPopup(false), m_owner(client), m_currentDragOp(DRAG_OPERATION_NONE) { auto hWnd = FindWindow(L"grcWindow", nullptr); m_dropTarget = DropTargetWin::Create(this, hWnd); HRESULT hr = RegisterDragDrop(hWnd, m_dropTarget); if (FAILED(hr)) { trace("registering drag/drop failed. hr: %08x\n", hr); } }
// Fix to avoid black corners temorarily artifact void Ctrl::Create0(Ctrl::CreateBox *cr) { GuiLock __; ASSERT(IsMainThread()); LLOG("Ctrl::Create(parent = " << (void *)parent << ") in " <<UPP::Name(this) << BeginIndent); ASSERT(!IsChild() && !IsOpen()); Rect r = GetRect(); AdjustWindowRectEx(r, cr->style, FALSE, cr->exstyle); isopen = true; top = new Top; ASSERT(!cr->parent || IsWindow(cr->parent)); cr->style &= ~WS_VISIBLE; if(!IsWinXP()) cr->dropshadow = false; #ifdef PLATFORM_WINCE if(parent) top->hwnd = CreateWindowExW(cr->exstyle, cr->savebits ? cr->dropshadow ? L"UPP-CLASS-SB-DS-W" : L"UPP-CLASS-SB-W" : cr->dropshadow ? L"UPP-CLASS-DS-W" : L"UPP-CLASS-W", L"", cr->style, 0, 0, 0, 0, cr->parent, NULL, hInstance, this); else top->hwnd = CreateWindowW(L"UPP-CLASS-W", L"", WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, cr->parent, NULL, hInstance, this); #else if(IsWinNT() && (!cr->parent || IsWindowUnicode(cr->parent))) top->hwnd = CreateWindowExW(cr->exstyle, cr->savebits ? cr->dropshadow ? L"UPP-CLASS-SB-DS-W" : L"UPP-CLASS-SB-W" : cr->dropshadow ? L"UPP-CLASS-DS-W" : L"UPP-CLASS-W", L"", cr->style, 0, 0, 0, 0, cr->parent, NULL, hInstance, this); else top->hwnd = CreateWindowEx(cr->exstyle, cr->savebits ? cr->dropshadow ? "UPP-CLASS-SB-DS-A" : "UPP-CLASS-SB-A" : cr->dropshadow ? "UPP-CLASS-DS-A" : "UPP-CLASS-A", "", cr->style, 0, 0, 0, 0, cr->parent, NULL, hInstance, this); #endif inloop = false; ASSERT(top->hwnd); ::MoveWindow(top->hwnd, r.left, r.top, r.Width(), r.Height(), false); // To avoid "black corners" artifact effect ::ShowWindow(top->hwnd, visible ? cr->show : SW_HIDE); // ::UpdateWindow(hwnd); StateH(OPEN); LLOG(EndIndent << "//Ctrl::Create in " <<UPP::Name(this)); RegisterDragDrop(top->hwnd, (LPDROPTARGET) (top->dndtgt = NewUDropTarget(this))); CancelMode(); RefreshLayoutDeep(); }
void MCStack::start_externals() { loadexternals(); if (!MCnoui && window != DNULL) { droptarget = new CDropTarget; droptarget->setstack(this); CoLockObjectExternal(droptarget, TRUE, TRUE); RegisterDragDrop((HWND)window->handle.window, droptarget); } }
void Ctrl::Create(HWND parent, DWORD style, DWORD exstyle, bool savebits, int show, bool dropshadow) { GuiLock __; ASSERT_(IsMainThread(), "Window creation can only happen in the main thread"); LLOG("Ctrl::Create(parent = " << (void *)parent << ") in " <<UPP::Name(this) << LOG_BEGIN); ASSERT(!IsChild() && !IsOpen()); Rect r = GetRect(); AdjustWindowRectEx(r, style, FALSE, exstyle); isopen = true; top = new Top; ASSERT(!parent || IsWindow(parent)); style &= ~WS_VISIBLE; if(!IsWinXP()) dropshadow = false; #ifdef PLATFORM_WINCE if(parent) top->hwnd = CreateWindowExW(exstyle, savebits ? dropshadow ? L"UPP-CLASS-SB-DS-W" : L"UPP-CLASS-SB-W" : dropshadow ? L"UPP-CLASS-DS-W" : L"UPP-CLASS-W", L"", style, 0, 0, 0, 0, parent, NULL, hInstance, this); else top->hwnd = CreateWindowW(L"UPP-CLASS-W", L"", WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, parent, NULL, hInstance, this); #else if(IsWinNT() && (!parent || IsWindowUnicode(parent))) top->hwnd = CreateWindowExW(exstyle, savebits ? dropshadow ? L"UPP-CLASS-SB-DS-W" : L"UPP-CLASS-SB-W" : dropshadow ? L"UPP-CLASS-DS-W" : L"UPP-CLASS-W", L"", style, 0, 0, 0, 0, parent, NULL, hInstance, this); else top->hwnd = CreateWindowEx(exstyle, savebits ? dropshadow ? "UPP-CLASS-SB-DS-A" : "UPP-CLASS-SB-A" : dropshadow ? "UPP-CLASS-DS-A" : "UPP-CLASS-A", "", style, 0, 0, 0, 0, parent, NULL, hInstance, this); #endif inloop = false; ASSERT(top->hwnd); ::MoveWindow(top->hwnd, r.left, r.top, r.Width(), r.Height(), false); // To avoid "black corners" artifact effect ::ShowWindow(top->hwnd, visible ? show : SW_HIDE); // ::UpdateWindow(hwnd); StateH(OPEN); LLOG(LOG_END << "//Ctrl::Create in " <<UPP::Name(this)); RegisterDragDrop(top->hwnd, (LPDROPTARGET) (top->dndtgt = NewUDropTarget(this))); CancelMode(); RefreshLayoutDeep(); }
DropTarget::DropTarget(WindowFrame* _window, CLIPFORMAT _format, uint32 _allowedEffects) { refCount = 1; window = _window; format.cfFormat = _format; format.ptd = NULL; format.dwAspect = DVASPECT_CONTENT; format.lindex = -1; format.tymed = TYMED_HGLOBAL; allowedEffects = _allowedEffects; allowDrop = false; RegisterDragDrop(window->getHandle(), this); }
TaskArea::TaskArea(bool pVertical, LPCSTR p_itemName): Collection(pVertical, p_itemName, 0, 2), stretchTaskarea(s_settingsManager.AssociateBool(m_pluginPrefix, m_itemPrefix, "Stretch", true)), m_basePrefix(p_itemName) { m_basePrefix.resize(m_basePrefix.find_first_of(".")); m_dragTask = NULL; m_dragTimer = getTimerID(); readSettings(); populateTasks(); m_dropTarget = new DropTarget(this, DragAction); RegisterDragDrop(barWnd, m_dropTarget); }
//--------------------------------------------------------------------------- void __fastcall TForm1::FormShow(TObject *Sender) { //----------------------------------- //ドラッグ&ドロップクラス //----------------------------------- OleInitialize(NULL); //FormをCreateしてからでないと呼び出せない DragAndDropTarget = new TDragAndDrop(Form1); DragAndDropTarget->FilesDragOver = FilesDragOver; DragAndDropTarget->FilesDragLeave = FilesDragLeave; DragAndDropTarget->FilesDragEnd = FilesDragEnd; RegisterDragDrop(Form1->Handle, (IDropTarget*)DragAndDropTarget); }
QOleDropTarget* qt_olednd_register( QWidget* widget ) { #ifdef DEBUG_QDND_WIN qDebug("qt_olednd_register( %p ) winID: %08x", widget, widget ? widget->winId() : 0 ); #endif QOleDropTarget * dst = new QOleDropTarget( widget ); #ifndef Q_OS_TEMP HRESULT ret = RegisterDragDrop( widget->winId(), dst ); #ifdef DEBUG_QDND_WIN qDebug("ret RegisterDragDrop = %x", ret ); #endif CoLockObjectExternal( dst, true, true ); #endif return dst; }
void SetupDragAndDrop(void) { HRESULT hRes; #if 0 return; #endif if(!isInitialized) { stDropTarget.vtbl = vtDropTarget; stDropTarget.ref = 0; isInitialized = 1; } hRes = RegisterDragDrop(stWindow, (LPDROPTARGET)&stDropTarget); if(hRes == S_OK) { DPRINTF(("Registered drop target\n")); } else { DPRINTF(("Drop registration failed (errCode: %x)\n", hRes)); } }
void playlist_switcher_t::notify_on_create() { m_playlist_api = standard_api_create_t<playlist_manager_v3>(); m_playback_api = standard_api_create_t<playback_control>(); m_playing_playlist = get_playing_playlist(); refresh_columns(); refresh_all_items(); m_playlist_api->register_callback(this, playlist_callback::flag_all); standard_api_create_t<play_callback_manager>()->register_callback(this, play_callback::flag_on_playback_all, false); pfc::com_ptr_t<IDropTarget_t> drop_target = new IDropTarget_t(this); RegisterDragDrop(get_wnd(), drop_target.get_ptr()); g_windows.add_item(this); }
static void test_DoDragDrop(void) { DWORD effect; HRESULT hr; HWND hwnd; hwnd = CreateWindowA("WineOleTestClass", "Test", 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, NULL, NULL); ok(IsWindow(hwnd), "failed to create window\n"); hr = OleInitialize(NULL); ok(hr == S_OK, "got 0x%08x\n", hr); hr = RegisterDragDrop(hwnd, &DropTarget); ok(hr == S_OK, "got 0x%08x\n", hr); /* incomplete arguments set */ hr = DoDragDrop(NULL, NULL, 0, NULL); ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); hr = DoDragDrop(NULL, &DropSource, 0, NULL); ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); hr = DoDragDrop(&DataObject, NULL, 0, NULL); ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); hr = DoDragDrop(NULL, NULL, 0, &effect); ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); hr = DoDragDrop(&DataObject, &DropSource, 0, NULL); ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); hr = DoDragDrop(NULL, &DropSource, 0, &effect); ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); hr = DoDragDrop(&DataObject, NULL, 0, &effect); ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); OleUninitialize(); DestroyWindow(hwnd); }
BOOL CMainDlg::OnInitDialog(HWND hWnd, LPARAM lParam) { m_bLayoutInited = TRUE; shellNotifyIcon.Create(m_hWnd,GETRESPROVIDER->LoadIcon(_T("ICON_LOGO"),16)); shellNotifyIcon.Show(); //InitListCtrl(); //拖拽功能 SWindow *pListBox = FindChildByName(L"music_lbe"); if(pListBox) { HRESULT hr=::RegisterDragDrop(m_hWnd,GetDropTarget()); CTestDropTarget1 *pDrop=new CTestDropTarget1(pListBox); RegisterDragDrop(pListBox->GetSwnd(),pDrop); pDrop->GetDragData(GetAudioAllPath,this); } //初始化音频操作类 m_pMuOPreat=new CMusicOpreat(m_hWnd); m_pMuOPreat->InitDatas(); //找到列表控件 SScrollLrc *pTreeBox=FindChildByName2<SScrollLrc>(L"music_lrc"); if(pTreeBox) { SStringW m_sTemp; STreeItem *pItem; HSTREEITEM rootItem; for (int i=0;i<20;i++) { m_sTemp.Format(L"<item><text pos=\"10,0,-5,-0\" name=\"数据_%d\" valign=\"middle\" align=\"left\" colorText=\"#ff0000\" align=\"center\" font=\"face:微软雅黑,adding:5\">%s</text></item>",i,szLrc[i]); //m_sTemp=_T(,strTemp); pItem=pTreeBox->InsertItem((LPCWSTR )m_sTemp,(DWORD)rootItem,STVI_ROOT,STVI_LAST,FALSE); m_TreItemInfo.insert(std::make_pair(i,pItem)); } pTreeBox->GetSetLrcFun(SetLrcStyle,this); pTreeBox->StarsRollLrc(); } return 0; }
void UninstallerShortcutsListbox::connect(HWND hwndParent, HWND hwndListbox) { if (m_listbox == 0) { m_dialogbox = hwndParent; m_listbox = hwndListbox; m_tooltip.init(hwndParent, hwndListbox); SetWindowSubclass(hwndListbox, listboxSubclassProc, 0, (DWORD_PTR) this); SetWindowSubclass(hwndListbox, GdiUtils::subclassProcForListboxWithEmptyText, 0, (DWORD_PTR) m_emptyText); RegisterDragDrop(hwndListbox, this); try { append(ShortcutsDisconnector::findShortcuts()); } catch (AutoSaveException& exc) { m_lastException = exc; PostMessage(m_dialogbox, LB_EXCEPTIONTHROWN, 0, 0); } } }
void CBookmarksToolbar::InitializeToolbar() { SendMessage(m_hToolbar,TB_SETBITMAPSIZE,0,MAKELONG(16,16)); SendMessage(m_hToolbar,TB_BUTTONSTRUCTSIZE,sizeof(TBBUTTON),0); m_himl = ImageList_Create(16,16,ILC_COLOR32|ILC_MASK,0,48); HBITMAP hBitmap = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_SHELLIMAGES)); ImageList_Add(m_himl,hBitmap,NULL); SendMessage(m_hToolbar,TB_SETIMAGELIST,0,reinterpret_cast<LPARAM>(m_himl)); DeleteObject(hBitmap); m_pbtdh = new CBookmarksToolbarDropHandler(m_hToolbar,m_AllBookmarks,m_guidBookmarksToolbar); RegisterDragDrop(m_hToolbar,m_pbtdh); SetWindowSubclass(m_hToolbar,BookmarksToolbarProcStub,SUBCLASS_ID,reinterpret_cast<DWORD_PTR>(this)); /* Also subclass the parent window, so that WM_COMMAND/WM_NOTIFY messages can be caught. */ SetWindowSubclass(GetParent(m_hToolbar),BookmarksToolbarParentProcStub,PARENT_SUBCLASS_ID, reinterpret_cast<DWORD_PTR>(this)); InsertBookmarkItems(); }
//----------------------------------------------------------------------------- Win32Frame::Win32Frame (IPlatformFrameCallback* frame, const CRect& size, HWND parent) : IPlatformFrame (frame) , windowHandle (0) , parentWindow (parent) , tooltipWindow (0) , backBuffer (0) , deviceContext (0) , inPaint (false) , mouseInside (false) , updateRegionList (0) , updateRegionListSize (0) { initWindowClass (); DWORD style = isParentLayered (parent) ? WS_EX_TRANSPARENT : 0; #if !DEBUG_DRAWING if (getD2DFactory ()) // workaround for Direct2D hotfix (KB2028560) { // when WS_EX_COMPOSITED is set drawing does not work correctly. This seems like a bug in Direct2D wich happens with this hotfix } else if (getSystemVersion ().dwMajorVersion >= 6) // Vista and above style |= WS_EX_COMPOSITED; else backBuffer = createOffscreenContext (size.getWidth (), size.getHeight ()); #endif windowHandle = CreateWindowEx (style, gClassName, TEXT("Window"), WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0, 0, (int)size.width (), (int)size.height (), parentWindow, NULL, GetInstance (), NULL); if (windowHandle) { SetWindowLongPtr (windowHandle, GWLP_USERDATA, (__int3264)(LONG_PTR)this); RegisterDragDrop (windowHandle, new CDropTarget (this)); } }
void Win32DropTarget::registerWithOS() { CoLockObjectExternal(this, TRUE, FALSE); RegisterDragDrop(mHWnd, this); }
void FWindowsWindow::Initialize( FWindowsApplication* const Application, const TSharedRef< FGenericWindowDefinition >& InDefinition, HINSTANCE InHInstance, const TSharedPtr< FWindowsWindow >& InParent, const bool bShowImmediately ) { Definition = InDefinition; OwningApplication = Application; // Finally, let's initialize the new native window object. Calling this function will often cause OS // window messages to be sent! (such as activation messages) uint32 WindowExStyle = 0; uint32 WindowStyle = 0; RegionWidth = RegionHeight = INDEX_NONE; const float XInitialRect = Definition->XDesiredPositionOnScreen; const float YInitialRect = Definition->YDesiredPositionOnScreen; const float WidthInitial = Definition->WidthDesiredOnScreen; const float HeightInitial = Definition->HeightDesiredOnScreen; int32 X = FMath::TruncToInt( XInitialRect ); int32 Y = FMath::TruncToInt( YInitialRect ); int32 ClientWidth = FMath::TruncToInt( WidthInitial ); int32 ClientHeight = FMath::TruncToInt( HeightInitial ); int32 WindowWidth = ClientWidth; int32 WindowHeight = ClientHeight; const bool bApplicationSupportsPerPixelBlending = #if ALPHA_BLENDED_WINDOWS Application->GetWindowTransparencySupport() == EWindowTransparency::PerPixel; #else false; #endif if( !Definition->HasOSWindowBorder ) { WindowExStyle = WS_EX_WINDOWEDGE; if( Definition->TransparencySupport == EWindowTransparency::PerWindow ) { WindowExStyle |= WS_EX_LAYERED; } #if ALPHA_BLENDED_WINDOWS else if( Definition->TransparencySupport == EWindowTransparency::PerPixel ) { if( bApplicationSupportsPerPixelBlending ) { WindowExStyle |= WS_EX_COMPOSITED; } } #endif WindowStyle = WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; if ( Definition->AppearsInTaskbar ) { WindowExStyle |= WS_EX_APPWINDOW; } else { WindowExStyle |= WS_EX_TOOLWINDOW; } if( Definition->IsTopmostWindow ) { // Tool tips are always top most windows WindowExStyle |= WS_EX_TOPMOST; } if ( !Definition->AcceptsInput ) { // Window should never get input WindowExStyle |= WS_EX_TRANSPARENT; } } else { // OS Window border setup WindowExStyle = WS_EX_APPWINDOW; WindowStyle = WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION; if (IsRegularWindow()) { if (Definition->SupportsMaximize) { WindowStyle |= WS_MAXIMIZEBOX; } if (Definition->SupportsMinimize) { WindowStyle |= WS_MINIMIZEBOX; } if (Definition->HasSizingFrame) { WindowStyle |= WS_THICKFRAME; } else { WindowStyle |= WS_BORDER; } } else { WindowStyle |= WS_POPUP | WS_BORDER; } // Note SizeX and SizeY should be the size of the client area. We need to get the actual window size by adjusting the client size to account for standard windows border around the window RECT WindowRect = { 0, 0, ClientWidth, ClientWidth }; ::AdjustWindowRectEx(&WindowRect,WindowStyle,0,WindowExStyle); X += WindowRect.left; Y += WindowRect.top; WindowWidth = WindowRect.right - WindowRect.left; WindowHeight = WindowRect.bottom - WindowRect.top; } // Creating the Window HWnd = CreateWindowEx( WindowExStyle, AppWindowClass, *Definition->Title, WindowStyle, X, Y, WindowWidth, WindowHeight, ( InParent.IsValid() ) ? static_cast<HWND>( InParent->HWnd ) : NULL, NULL, InHInstance, NULL); VirtualWidth = ClientWidth; VirtualHeight = ClientHeight; // We call reshape window here because we didn't take into account the non-client area // in the initial creation of the window. Slate should only pass client area dimensions. // Reshape window may resize the window if the non-client area is encroaching on our // desired client area space. ReshapeWindow( X, Y, ClientWidth, ClientHeight ); if( HWnd == NULL ) { // @todo Error message should be localized! MessageBox(NULL, TEXT("Window Creation Failed!"), TEXT("Error!"), MB_ICONEXCLAMATION | MB_OK); checkf(0, TEXT("Window Creation Failed (%d)"), ::GetLastError() ); return; } if ( Definition->TransparencySupport == EWindowTransparency::PerWindow ) { SetOpacity( Definition->Opacity ); } #if WINVER > 0x502 // Windows Vista or better required for DWM // Disable DWM Rendering and Nonclient Area painting if not showing the os window border // This prevents the standard windows frame from ever being drawn if( !Definition->HasOSWindowBorder ) { const DWMNCRENDERINGPOLICY RenderingPolicy = DWMNCRP_DISABLED; verify(SUCCEEDED(DwmSetWindowAttribute(HWnd, DWMWA_NCRENDERING_POLICY, &RenderingPolicy, sizeof(RenderingPolicy)))); const BOOL bEnableNCPaint = false; verify(SUCCEEDED(DwmSetWindowAttribute(HWnd, DWMWA_ALLOW_NCPAINT, &bEnableNCPaint, sizeof(bEnableNCPaint)))); #if ALPHA_BLENDED_WINDOWS if ( bApplicationSupportsPerPixelBlending && Definition->TransparencySupport == EWindowTransparency::PerPixel ) { MARGINS Margins = {-1}; verify(SUCCEEDED(::DwmExtendFrameIntoClientArea(HWnd, &Margins))); } #endif } #endif // WINVER // No region for non regular windows or windows displaying the os window border if ( IsRegularWindow() && !Definition->HasOSWindowBorder ) { WindowStyle |= WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU; if ( Definition->SupportsMaximize ) { WindowStyle |= WS_MAXIMIZEBOX; } if ( Definition->SupportsMinimize ) { WindowStyle |= WS_MINIMIZEBOX; } if ( Definition->HasSizingFrame ) { WindowStyle |= WS_THICKFRAME; } verify(SetWindowLong(HWnd, GWL_STYLE, WindowStyle)); ::SetWindowPos(HWnd, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); AdjustWindowRegion( ClientWidth, ClientHeight ); } if ( IsRegularWindow() ) { // Tell OLE that we are opting into drag and drop. // Only makes sense for regular windows (windows that last a while.) RegisterDragDrop( HWnd, this ); } }
void RegisterFileDropping( HWND hwnd, CDropTarget* pdropTarget ) { RegisterDragDrop( hwnd, (IDropTarget*)pdropTarget ); }
// call after the bar window is created with it's hwnd class TinyDropTarget *init_drop_targ(HWND hwnd) { class TinyDropTarget *m_TinyDropTarget = new TinyDropTarget(hwnd); RegisterDragDrop(hwnd, m_TinyDropTarget); return m_TinyDropTarget; }
static void init_DeskDropTarget(HWND hwnd) { m_DeskDropTarget = new DeskDropTarget(); RegisterDragDrop(hwnd, m_DeskDropTarget); }