На главную

On-line справка по Win32 API

Написать письмо
БЕСПЛАТНАЯ ежедневная online лотерея! Выигрывай каждый день БЕСПЛАТНО!
Список всех статей A-B-C-D-E-F-G-H-I-J-K-L-M-N-O-P-Q-R-S-T-U-V-W-X-Y-Z | Скачать Вниз

Using the Drag-Drop Feature



When an application implements the drag-drop feature, a user can select one or more files in File Manager, drag them to an open application, and drop them there. The application in which the files were dropped receives a message it can use to retrieve the filenames and the coordinates of the point at which the files were dropped.

An application that can accept dropped files from File Manager calls the DragAcceptFiles function for one or more of its windows. When the user releases the mouse button to drop a file or files in the window specified in the call to DragAcceptFiles, File Manager sends the application a WM_DROPFILES message. (File Manager does not send the WM_DROPFILES message to an application unless the application calls DragAcceptFiles.) WM_DROPFILES contains a handle of a structure the application can query to retrieve the name of the dropped file and the coordinates of the cursor when the file was dropped. The application can use the DragQueryFile function to retrieve a count of the files that were dropped and their names. The DragQueryPoint function returns the window coordinates of the cursor when the user released the mouse button.

To free the memory allocated by the system for the WM_DROPFILES message, an application calls the DragFinish function when it is finished.
For example, an application can call the DragAcceptFiles function when it starts and call a drag-drop function when it receives a WM_DROPFILES message, as shown in the following example.

case WM_CREATE:
DragAcceptFiles(hwnd, TRUE);
break;

case WM_DROPFILES:
DragFunc(hwnd, wParam); /* application-defined function */
break;

case WM_DESTROY:
DragAcceptFiles(hwnd, FALSE);
break;


The following example uses the DragQueryPoint function to determine where to begin to write text. The first call to the DragQueryFile function determines the number of dropped files. The loop writes the name of each file, beginning at the point returned by DragQueryPoint.

POINT pt;
WORD cFiles, a;
char lpszFile[80];

DragQueryPoint((HANDLE) wParam, &pt);

cFiles = DragQueryFile((HANDLE) wParam, 0xFFFF, (LPSTR) NULL, 0);
for(a = 0; a < cFiles; pt.y += 20, a++) {
DragQueryFile((HANDLE) wParam, a, lpszFile, sizeof(lpszFile));
TextOut(hdc, pt.x, pt.y, lpszFile, lstrlen(lpszFile));
}

DragFinish((HANDLE) wParam);



Пригласи друзей и счет твоего мобильника всегда будет положительным!
Предыдущая статья
 
Сайт Народ.Ру Интернет
Следующая статья
Пригласи друзей и счет твоего мобильника всегда будет положительным!

Использование Характеристики Drag-Drop



Когда приложение осуществляет помеху-каплю характеристики, потребитель может выбраться один или более файлов в Файловом Менеджере, потащите им в открытое приложение, и бросьте им там. Приложение в котором файлы были брошены приемники сообщение это может использоваться, чтобы извлекать filenames и координаты точки в которой файлы были упадены.

Приложение, которое может принять потерянные файлы с Файловых вызовов Менеджера функция DragAcceptFiles для одного или более из своего окна. Когда потребитель выпускает кнопку мыши, чтобы бросать файл или файлы в окне определенном на вызове на DragAcceptFiles, Менеджер File посылает приложению сообщение WM_DROPFILES. (Файловый Менеджер не посылает сообщение WM_DROPFILES в приложение если приложение не вызывает DragAcceptFiles.) WM_DROPFILES содержит ручку структуры, которая приложение может запрос, чтобы извлекать имя потерянного файла и координаты курсора когда файл был упаден. Приложение может использовать функцию DragQueryFile, чтобы извлекать счет файлов, которые были брошены и их имена. Функция DragQueryPoint возвращает координаты окна курсора когда потребитель выпускал кнопку мыши.

Чтобы освобождать память распределенную системой для сообщения WM_DROPFILES, приложение вызывает функцию DragFinish когда оно завершено.
Например, приложение может вызвать функцию DragAcceptFiles когда оно начинает и вызывает помеху-каплю функции когда это получает сообщение WM_DROPFILES, как показано в следующем примере.

случай WM_CREATE: DragAcceptFiles(hwnd, ИСТИНА);
прерывание;

случай WM_DROPFILES:
DragFunc(hwnd, wParam); /* определенная прикладная функция */ прерывание;

случай WM_DESTROY: DragAcceptFiles(hwnd, ЛОЖЬ);
прерывание;


Следующий пример использует функцию DragQueryPoint, чтобы определяться где, чтобы начинать писать текст. Первый вызов в функцию DragQueryFile определяет количество потерянных файлов. Цикл пишет имя каждого файла, начинающего на данном этапе возвращанное DragQueryPoint.

ТОЧКА пт;
СЛОВО cFiles, a;
символ lpszFile[80];

DragQueryPoint((РУЧКА) wParam, &пт);

cFiles = DragQueryFile((РУЧКА) wParam, 0xFFFF, (LPSTR) НЕДЕЙСТВИТЕЛЬНЫЙ, 0);
для( = 0; < cFiles; pt.y += 20,++) { DragQueryFile((РУЧКА) wParam, a, lpszFile, sizeof(lpszFile));
TextOut(hdc, pt.x, pt.y, lpszFile, lstrlen(lpszFile));
}

DragFinish((РУЧКА) wParam);



Вверх Version 1.3, Oct 26 2010 © 2007, 2010, mrhx Вверх
 mrhx software  Русский перевод OpenGL  Русский перевод Win32 API
 
Используются технологии uCoz