Skip to content

Commit 027e138

Browse files
committed
CDropSource::DoDragDropを追加する
1 parent 516b11b commit 027e138

5 files changed

Lines changed: 27 additions & 26 deletions

File tree

sakura_core/_os/CDropTarget.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,15 @@ STDMETHODIMP CDropSource::GiveFeedback( [[maybe_unused]] DWORD dropEffect )
171171
return DRAGDROP_S_USEDEFAULTCURSORS;
172172
}
173173

174+
DWORD CDropSource::DoDragDrop(LPDATAOBJECT pDataObject, DWORD dwDesiredEffects)
175+
{
176+
if (DWORD dwEffects; SUCCEEDED(::DoDragDrop(pDataObject, this, dwDesiredEffects, &dwEffects))) {
177+
return dwEffects;
178+
}
179+
180+
return DROPEFFECT_NONE;
181+
}
182+
174183
/** 転送対象の文字列を設定する
175184
@param lpszText [in] 文字列
176185
@param nTextLen [in] pszTextの長さ
@@ -224,15 +233,6 @@ void CDataObject::SetText( LPCWSTR lpszText, size_t nTextLen, BOOL bColumnSelect
224233
}
225234
}
226235

227-
DWORD CDataObject::DragDrop( BOOL bLeft, DWORD dwEffects )
228-
{
229-
DWORD dwEffect;
230-
CDropSource drop( bLeft );
231-
if( SUCCEEDED( ::DoDragDrop( this, &drop, dwEffects, &dwEffect ) ) )
232-
return dwEffect;
233-
return DROPEFFECT_NONE;
234-
}
235-
236236
/** IDataObject::GetData
237237
@date 2008.03.26 ryoji 複数フォーマット対応
238238
*/

sakura_core/_os/CDropTarget.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ class CDropSource : public CYbInterfaceImpl<IDropSource> {
122122

123123
STDMETHOD( QueryContinueDrag )( BOOL bEscapePressed, DWORD dwKeyState );
124124
STDMETHOD( GiveFeedback )( DWORD dropEffect );
125+
126+
DWORD DoDragDrop(LPDATAOBJECT pDataObject, DWORD dwDesiredEffects);
125127
};
126128

127129
class CDataObject : public CYbInterfaceImpl<IDataObject> {
@@ -148,7 +150,6 @@ class CDataObject : public CYbInterfaceImpl<IDataObject> {
148150
}
149151
~CDataObject(){SetText( nullptr, 0, FALSE );}
150152
void SetText( LPCWSTR lpszText, size_t nTextLen, BOOL bColumnSelect );
151-
DWORD DragDrop( BOOL bLeft, DWORD dwEffects );
152153

153154
STDMETHOD( GetData )( LPFORMATETC, LPSTGMEDIUM );
154155
STDMETHOD( GetDataHere )( LPFORMATETC, LPSTGMEDIUM );

sakura_core/view/CEditView_Mouse.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2234,6 +2234,8 @@ void CEditView::DragSelection()
22342234
// ドラッグ開始前のドキュメント操作番号を記憶する
22352235
const auto nOpe = GetDocument()->m_cDocEditor.m_cOpeBuf.GetCurrentPointer();
22362236

2237+
CDropSource drop(true);
2238+
22372239
// ドラッグ元ビューを設定する
22382240
GetEditWnd().SetDragSourceView(this);
22392241

@@ -2244,7 +2246,7 @@ void CEditView::DragSelection()
22442246
}
22452247

22462248
// ドラッグ&ドロップを開始する
2247-
const auto actualEffects = data->DragDrop(TRUE, desiredEffects);
2249+
const auto actualEffects = drop.DoDragDrop(data.get(), desiredEffects);
22482250

22492251
// ドラッグ元ビューの設定を解除する
22502252
GetEditWnd().SetDragSourceView(nullptr);

sakura_core/window/CEditWnd.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3389,10 +3389,8 @@ LRESULT CEditWnd::OnMouseMove( WPARAM wParam, LPARAM lParam )
33893389
if (cxx::com_pointer<IDataObject> pDataObject; SUCCEEDED(GetDocument()->GetDataObject(&pDataObject))) {
33903390
CDropSource drop(true);
33913391

3392-
DWORD dwEffect = 0;
3393-
33943392
//移動禁止なので、戻り値を見ない
3395-
::DoDragDrop(pDataObject, &drop, DROPEFFECT_COPY | DROPEFFECT_LINK, &dwEffect);
3393+
drop.DoDragDrop(pDataObject, DROPEFFECT_COPY | DROPEFFECT_LINK);
33963394
}
33973395
}
33983396
return 0;

src/test/cpp/tests1/test-cclipboard.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,18 @@ TEST(CDropSource, GiveFeedback001)
761761
EXPECT_HRESULT_EQ(target->GiveFeedback(DROPEFFECT_MOVE), DRAGDROP_S_USEDEFAULTCURSORS);
762762
}
763763

764+
/*!
765+
* DoDragDrop のテスト。
766+
*/
767+
TEST(CDropSource, DoDragDrop101)
768+
{
769+
const auto target = std::make_unique<CDropSource>(true);
770+
771+
LPDATAOBJECT pDataObject = nullptr;
772+
DWORD dwEffects = 0;
773+
EXPECT_HRESULT_EQ(target->DoDragDrop(pDataObject, dwEffects), DROPEFFECT_NONE);
774+
}
775+
764776
/*!
765777
* 意図的にサポートしないメソッド のテスト。
766778
*/
@@ -979,18 +991,6 @@ TEST(CopiedTextData, GetDataHere101)
979991
EXPECT_HRESULT_EQ(target->GetDataHere(&format, &smallMedium), STG_E_MEDIUMFULL);
980992
}
981993

982-
/*!
983-
* DragDrop のテスト。
984-
*/
985-
TEST(CopiedTextData, DragDrop101)
986-
{
987-
const auto target = std::make_unique<CDataObject>(L"abc", 3, FALSE);
988-
989-
BOOL bLeft = FALSE;
990-
DWORD dwEffects = 0;
991-
EXPECT_THAT(target->DragDrop(bLeft, dwEffects), DROPEFFECT_NONE);
992-
}
993-
994994
/*!
995995
* CEnumFORMATETC のテスト。
996996
*/

0 commit comments

Comments
 (0)