Click here to Skip to main content
11,704,315 members (44,626 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C++ MFC VS2010
Hi all,

I have a MFC dialog C++ application in VS2010, And my application has two textbox is source folder(txtSrcfolder) and destination folder(txtDesFolder) so when I drag and drop a file to txtxDesFolder, I want to assign full file path to txtDesFolder and the same to txtSrcFolder.
But how to determine which textbox is draged to?
(if there is only one textbox i can handle it but with many control I can't)

Can you help me, please?
Posted 20-Jun-12 1:05am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Try to pass a box pointer to this test Smile | :) :
/*static*/ bool CYourDialog::TestDropWnd(CWnd* pcWndTest)
  CPoint cPoint;
  if (::GetCursorPos(&cPoint)) {
    return (pcWndTest == CWnd::WindowFromPoint(cPoint));
  return false;
ngthtra at 20-Jun-12 22:19pm
how to use this code?
Eugen Podsypalnikov at 21-Jun-12 1:55am
At your "dropped" event, call this test for the both boxes (pass their pointers). The function will return true, if a testing box is under the mouse :)
ngthtra at 21-Jun-12 22:37pm
so what will pcWndTest parameter be inputed? I am using CAppDlg::OnDropFiles(HDROP hDropInfo){} to get folder path
Eugen Podsypalnikov at 22-Jun-12 3:24am
In the context of your dialog:
bool bDroppedOnSrcBox(GetDlgItem(IDC_SRC_BOX)); // IDC_SRC_BOX is the resource ID of the box
bool bDroppedOnTrgBox(GetDlgItem(IDC_TRG_BOX)); // IDC_TRG_BOX is the resource ID of the box

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 740
1 OriginalGriff 520
2 Maciej Los 355
3 Andy Lanng 284
4 CPallini 275
0 OriginalGriff 8,824
1 Sergey Alexandrovich Kryukov 8,247
2 CPallini 5,197
3 Maciej Los 4,726
4 Mika Wendelius 3,606

Advertise | Privacy | Mobile
Web01 | 2.8.150819.1 | Last Updated 20 Jun 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100