Home > Software engineering >  MFC modify drag files open order
MFC modify drag files open order

Time:09-23

Implements a SDI MFC procedures, in the main interface has a edit box CEdit, now in order to achieve a drag multiple files displayed in the edit box,
My way is, if a drag multiple files one by one, save, and finally unified display on top of CEdit,

The question now is selected after a bunch of files, drag into the interface, open is not in accordance with the order of from top to bottom, but from the beginning of the middle, is the file open order is not affirmatory,
 
LRESULT CMainFrame: : WindowProc (UINT message, WPARAM WPARAM, LPARAM LPARAM)
{
//TODO: Add your specialized code here and/or call the base class
The switch (the message)
{
Case WM_DROPFILES:
{
HDROP HDROP=(wParam HDROP);
//2.1 0 XFFFFFFFF parameters, will receive a number of drag and drop files
TheApp. NDragFileNum=DragQueryFile (hDrop, 0 XFFFFFFFF, NULL, 0).
TRACE (" drag the file, and num is: % d \ n ", theApp. NDragFileNum);
TheApp. OpenFirstDragDoc=TRUE;
break;
}
}
Return CFrameWnd: : WindowProc (message, wParam, lParam);
}

I have realize this message and get the file number, now the question is, can what method can change the order of the open file?
Themselves with a train of thought, but I don't know how to achieve: because hDrop point to areas include name of the file information, is now want to modify hDrop pointing to content, such as the file name order, don't know whether it is feasible?

O master told,

CodePudding user response:

For the file name list, do a sorting

CodePudding user response:

File name list can access, sorting can also, but I guess the sequence where I want to be there, otherwise return CFrameWnd: : WindowProc (message, wParam, lParam); This sentence report file or the original order,
More clearly whether the trouble?

CodePudding user response:

Is there any way to modify mWparam pointing to content?

CodePudding user response:

Or someone who knows how to simulate WM_DROPFILES news

CodePudding user response:

1 DragQueryFile
Retrieves the file names of dropped files that have resulted from a successful drag - and - drop operation.
Returns the path (multiple) file name, you put it in a CStringArray, then sorting, himself a another open reading,
Edit, not through the WindowProc namely
2 don't break; But the return

CodePudding user response:

Drag and drop the essence is to obtain a heap of filename mechanism, after you get the file name, to completely brought in the name of the file you want to do what use

CodePudding user response:

Access to the file list, realize the processing logic behind the ~

CodePudding user response:

Themselves define a message, sorting through a custom message sent in the past,

CodePudding user response:

Fyi:
 void MyGetListViewItem (HWND hWindow) {

Int nLVItemCount;
Int nColumns;
DWORD dwProcessID;
HANDLE hProcess;
The HWND hHeaderCtrl;
LVITEM lvItemLocal;
HDITEM hdItemLocal;
DWORD dwBytesRead dwBytesWrite;
BOOL bSuccess, bWriteOK;
LPVOID lpTextRemote;
LPVOID lpListItemRemote;
LPVOID lpHeadItemRemote;
int i,j;

GetWindowThreadProcessId (hWindow, & amp; DwProcessID);
HProcess=OpenProcess (PROCESS_ALL_ACCESS, FALSE, dwProcessID);
if (! HProcess) goto ABORT0;
LpTextRemote=VirtualAllocEx (hProcess, NULL, nMaxLen + 1, MEM_COMMIT, PAGE_READWRITE);
if (! LpTextRemote) goto ABORT1;
LpListItemRemote=VirtualAllocEx (hProcess, NULL, sizeof (LVITEM), MEM_COMMIT, PAGE_READWRITE);
if (! LpListItemRemote) goto ABORT2;
LpHeadItemRemote=VirtualAllocEx (hProcess, NULL, sizeof (HDITEM), MEM_COMMIT, PAGE_READWRITE);
if (! LpHeadItemRemote) goto ABORT3;

NLVItemCount=ListView_GetItemCount (hWindow);
HHeaderCtrl=ListView_GetHeader (hWindow);
NColumns=Header_GetItemCount (hHeaderCtrl);

//init ();
If (nColumns<=0) {
NColumns=1;
//} else {
Ln [0]=0;
for (j=0; JZeroMemory (szBuf, nMaxLen + 1);
BWriteOK=WriteProcessMemory (hProcess, lpTextRemote, (LPVOID) szBuf, nMaxLen + 1, (LPDWORD) & amp; DwBytesWrite);
if (! BWriteOK) goto ABORT4;
HdItemLocal. Mask=HDI_TEXT;
HdItemLocal. CchTextMax=nMaxLen;
HdItemLocal. PszText=(LPTSTR lpTextRemote);
DwBytesWrite=0;
BWriteOK=WriteProcessMemory (hProcess, lpHeadItemRemote, (LPVOID) & amp; HdItemLocal, sizeof (HDITEM), (LPDWORD) & amp; DwBytesWrite);
if (! BWriteOK) goto ABORT4;
SendMessage (hHeaderCtrl HDM_GETITEM, (WPARAM), j (LPARAM) lpHeadItemRemote);
BSuccess=ReadProcessMemory (hProcess, lpTextRemote szBuf, nMaxLen + 1, & amp; DwBytesRead);
if (! BSuccess) goto ABORT4;
If (j> 0) strcat (ln, "|");
Strstrip (szBuf1 szBuf);
Strcat (ln, szBuf1);
}
Add1 (ln);
}
//printf (" the number of Columns ListView: % d \ n ", nColumns);
//printf (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n ");
If (nLVItemCount<=0) nLVItemCount=1;
for (i=0; ILn [0]=0;
for (j=0; JZeroMemory (szBuf, nMaxLen + 1);
BWriteOK=WriteProcessMemory (hProcess, lpTextRemote, (LPVOID) szBuf, nMaxLen + 1, (LPDWORD) & amp; DwBytesWrite);
if (! BWriteOK) goto ABORT4;
LvItemLocal. IItem=I;
LvItemLocal. ISubItem=j;
LvItemLocal. Mask=LVIF_TEXT;
LvItemLocal. CchTextMax=nMaxLen;
LvItemLocal. PszText=(LPTSTR lpTextRemote);
DwBytesWrite=0;
BWriteOK=WriteProcessMemory (hProcess, lpListItemRemote, (LPVOID) & amp; LvItemLocal, sizeof (LVITEM), (LPDWORD) & amp; DwBytesWrite);
if (! BWriteOK) goto ABORT4;
SendMessage (hWindow LVM_GETITEMTEXT, (WPARAM), I (LPARAM) lpListItemRemote);
BSuccess=ReadProcessMemory (hProcess, lpTextRemote szBuf, nMaxLen + 1, & amp; DwBytesRead);
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related