915
case WM_DROPFILES:
916
{
917
HDROP hDrop = (HDROP) wParam;
918
// How many files were dropped?
919
int count = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);
920
#define _MAX_PATH 260 // FIXME: fixed array length bad
921
char szFileName[_MAX_PATH];
922
int i,pathlength;
923
for (i=0; i<count; i++)
924
{
925
pathlength = DragQueryFile(hDrop, i, NULL, 0);
926
if (pathlength < _MAX_PATH)
927
{
928
DragQueryFile(hDrop, i, szFileName, _MAX_PATH);
929
XAP_App * pApp = XAP_App::getApp();
930
UT_ASSERT(pApp);
931
FV_View* pView = (FV_View *) f->getCurrentView();
932
XAP_Frame * pNewFrame = 0;
933
IEGraphicFileType iegft = IEGFT_Unknown;
934
IE_ImpGraphic *pIEG;
935
FG_Graphic* pFG;
936
UT_Error errorCode = UT_ERROR;
937
938
/*
939
The user may be dropping any kind of file
940
Check first if the file is a graphic. If it's a graphic we insert it
941
in the document, if not we assume that it's a document
942
*/
943
// If there is no import graphic, it's a document...
944
errorCode = IE_ImpGraphic::constructImporter(szFileName, iegft, &pIEG);
945
if(errorCode == UT_OK)
946
{
947
errorCode = pIEG->importGraphic(szFileName, &pFG);
948
949
DELETEP(pIEG);
950
if(errorCode == UT_OK && pFG)
951
{
952
errorCode = pView->cmdInsertGraphic(pFG);
953
DELETEP(pFG);
954
}
955
}
956
957
if (errorCode != UT_OK)
958
{
959
// Check if the current document is empty.
960
if (f->isDirty() || f->getFilename() ||
961
(f->getViewNumber() > 0))
962
{
963
pNewFrame = pApp->newFrame();
964
if (pNewFrame == NULL)
965
{
966
errorCode = UT_ERROR;
967
f->setStatusMessage("Could not open another window");
968
return 0;
969
}
970
}
971
else
972
{
973
pNewFrame = f;
974
}
975
976
errorCode = pNewFrame->loadDocument(szFileName, IEFT_Unknown);
977
if (errorCode != UT_OK)
978
{
979
if (f != pNewFrame)
980
pNewFrame->close();
981
}
982
else
983
{
984
pNewFrame->show();
985
}
986
}
987
988
if (errorCode != UT_OK)
989
{
990
s_CouldNotLoadFileMessage(f, szFileName, errorCode);
991
}
992
}
993
else
994
{
995
}
996
}
997
DragFinish(hDrop);
998
}
999
return 0;
另外一个关于拖曳文件的代码片段:
99
// The main message loop
100
BOOL CALLBACK DialogFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
101
{
102
103
switch(uMsg){
104
case WM_INITDIALOG:
105
OnStartUp(hwndDlg);
106
break;
107
108
// Button clicks
109
case WM_COMMAND:
110
switch(LOWORD(wParam)){
111
// UDP echo server start
112
case IDC_CMDSTART:
113
OnStartServer(hwndDlg);
114
break;
115
116
case IDC_CMDSTOP:
117
OnStopServer(hwndDlg);
118
break;
119
120
case IDC_CMDABOUT:
121
OnAbout(hwndDlg);
122
break;
123
124
case IDC_CMDBROWSE:
125
OnBrowse(hwndDlg);
126
break;
127
}
128
return 1;
129
130
case WM_DROPFILES:
131
{
132
HDROP hDrop=(HDROP)wParam;
133
int numFiles=DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);
134
char pFileName[MAX_PATH];
135
136
//CProcessData oProcess;
137
138
for(int i=0; i<numFiles; i++)
139
{
140
DragQueryFile(hDrop, i, pFileName, MAX_PATH);
141
s_oProcess.OnFile(pFileName);
142
}
143
144
DragFinish(hDrop);
145
146
return 1;
147
}
148
149
case WM_CLOSE:
150
OnStopServer(hwndDlg);
151
CSysLog::Get().StopLog();
152
CSettings::Get().SaveIni();
153
154
EndDialog(hwndDlg, 0);
155
return 1;
156
}
157
158
return 0;
159
}
浙公网安备 33010602011771号