Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "WinAPI";
Текущий архив: 2005.06.29;
Скачать: [xml.tar.bz2];

Вниз

Как переташить файл на к.л. компонент программы?   Найти похожие ветки 

 
ronyn   (2005-05-05 04:09) [0]

Хочу переташить файл на мою программу, z.B. звуковые файлы перетащить из папки в список воспроизведения. Пожайлуста помогите. Заранее благодарен.


 
Antonn ©   (2005-05-05 07:57) [1]

protected
    procedure CreateParams(var Params: TCreateParams); override;
private
    procedure WMDropFiles(var Message: TWMDropFiles); message WM_DROPFILES;  
...

procedure TForm.CreateParams(var Params: TCreateParams);
begin
inherited
CreateParams(Params);
Params.ExStyle := Params.ExStyle or WS_EX_ACCEPTFILES;
end;

procedure TForm.WMDropFiles(var Message: TWMDropFiles);
var aFile: array [0..255] of Char; FilesCount,N : Integer;
begin
     inherited;
FilesCount := DragQueryFile(Message.drop, $FFFFFFFF, nil, 0);
      begin
      for N := 0 to FilesCount - 1 do begin
       DragQueryFile(Message.drop, N, aFile, 256);
       //В aFile хранится путь и название файла, тут добавляешь как тебе надо и куда надо
       end;
      end;
      DragFinish(Message.Drop);
end;


 
ronyn   (2005-05-07 22:15) [2]

Почему то не получается. По курсору видно, что файлы перетащить можно, но в ЛистБокс файлы не добавляются. Может я что-то не правильно делаю, не знаю...Хотелось бы побольше коментариев к коду, т.к. я начинающий. Заранее спасибо.


 
easy ©   (2005-05-07 22:38) [3]

http://delphimaster.ru/articles/dragndrop/index.html


 
Antonn ©   (2005-05-08 05:51) [4]

ronyn   (07.05.05 22:15) [2]

> //В aFile хранится путь и название файла, тут
> добавляешь как тебе надо и куда надо

под этим пишешь:
ListBox1.items.add(aFile);


 
ronyn   (2005-05-10 02:01) [5]

Он требует, что бы я идентифицировал DragQueryFile. Как его прописать в разделе var, какой тип?


 
Marser ©   (2005-05-10 02:09) [6]


> ronyn   (10.05.05 2:01) [5][Ответить]

Это функция API. Нажми F1


 
ronyn   (2005-05-10 02:36) [7]

Нажал, а том вот что

The compiler could not find the given identifier - most likely it has been misspelled either at the point of declaration or the point of use. It might be from another unit that has not mentioned a uses clause.

program Produce;
var
 Counter: Integer;
begin
 Count := 0;
 Inc(Count);
 Writeln(Count);
end.

In the example, the variable has been declared as "Counter", but used as "Count". The solution is to either change the declaration or the places where the variable is used.

program Solve;
var
 Count: Integer;
begin
 Count := 0;
 Inc(Count);
 Writeln(Count);
end.

In the example we have chosen to change the declaration - that was less work.  

Ничего не понятно. Как же все таки необходимо избавиться от ошибки      [Error] Unit3.pas(79): Undeclared identifier: "DragQueryFile"? Курсор остнавливается на надписи в коде - FilesCount := DragQueryFile(Message.drop, $FFFFFFFF, nil, 0);


 
Marser ©   (2005-05-10 02:40) [8]


> Как же все таки необходимо избавиться от ошибки

Просто.
uses ShellAPI


 
ronyn   (2005-05-10 02:54) [9]

ошибка устранена. Но перетаскиваемый файл не помещается в ЛистБокс. может быть с переменной aFile нужно ещё что-то делать?



Страницы: 1 вся ветка

Форум: "WinAPI";
Текущий архив: 2005.06.29;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.46 MB
Время: 0.035 c
3-1116402505
SLP
2005-05-18 11:48
2005.06.29
копирование результатов запроса в буфер обмена


1-1118185122
Bagle
2005-06-08 02:58
2005.06.29
что за проблема


3-1116063132
Shnayder
2005-05-14 13:32
2005.06.29
Borland Delphi 5 ->MS SQL


1-1117607686
vidiv
2005-06-01 10:34
2005.06.29
device pixels/inch


14-1117814291
Новичоккк
2005-06-03 19:58
2005.06.29
Delphi 7 vs Delphi 8 vs Delphi 2005





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский