UCanCode
Software focuses on general application software development. We provide complete solution for developers. No matter you want to develop a simple database
workflow application, or an large flow/diagram based system, our product will provide a complete solution for you. Our product had been used by hundreds of top companies around the world!
"100% source code provided! Free you from not daring to use components because of unable to master the key technology of components!"
VC++ Code:
Drag and Drop File in Dialog with
WM_DROPFILES
and WM_NCLBUTTONDOWN
Here is a
simple
method to
have a
Drag
and
Drop
feature
in
our
dialog
based
applications.
To provide
Drag
and
Drop
we have a
windows
Message
Handler
called WM_DROPFILES.Handle
this message
through
ON_MESSAGE
message map
to capture
the
dropped
files.
Finally we
have a
function to
capture the
drop
events. The
wParam
is a handle
to the
HDROP
structure
describing
the
dropped
files.
To get the
info about
the dropped
file i.e.
the file
name used :-
DragQueryFile(hDrop, // Struture Identifier
-1, // -1 to Drop more than one file or ( integer 0 to max )
// to drop selected No of files szDroppedFile,// Droped File Name
MAX_PATH); // Max char
So now we
did all
possible
coding in
our dialog
based
application
to handle
Drag
&
Drop
feature. But
still it is
handicapped.
Handling the
Drop
event is not
enough to
ensure the
Drag & Drop
feature. We
need to
register our
window to
accept the
dropped file
using
BOOL CComGuidFinderDlg::OnInitDialog()
{
......
.....
DragAcceptFile(TRUE) // To Accept Dropped file Set this TRUE
}
Good...
That's all
and we have
done well!
I added one
more feature
in this
sample i.e.
Moving the
our
dialog
by clicking
on anywhere
on the
window. This
can be do by
posting
WM_NCLBUTTONDOWN
message to
HTCAPTION
Handle this
statement in
OnLButtonDownMessage(...)
Copyright ?1998-2022 UCanCode.Net Software , all rights reserved.
Other product and company names herein may be the trademarks of their respective owners.