{"id":249,"date":"2008-05-07T21:08:20","date_gmt":"2008-05-07T21:08:20","guid":{"rendered":"http:\/\/6teen.ru\/?p=41"},"modified":"2008-05-07T21:08:20","modified_gmt":"2008-05-07T21:08:20","slug":"8592","status":"publish","type":"post","link":"http:\/\/pblog.ru\/lab\/?p=249","title":{"rendered":"TListBox \u0438 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440"},"content":{"rendered":"<p>TListBox \u0438 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440<br \/>\n<!--more--><\/p>\n<pre class=\"alt2\" style=\"margin:0px; padding:6px; border:1px inset; width:580px; height:320px; overflow:auto\"><div>TListBox \u0438 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\n\nTo use File Manager Drag & Drop, add a method to your form that handles the WM_DROPFILES message.  For example, the following would be placed in the TForm1 declaration in the protected section:\n...\nprocedure WMDropFiles(var msg : TMessage); message WM_DROPFILES;\n...\n\nYou would typically activate file drag & drop by calling DragAcceptFiles() in the OnCreate event, and turn it off with a subsequent call to DragAcceptFiles() in the OnClose or OnDestroy events.  The code follows:\nprocedure TForm1.WMDropFiles(var msg : TMessage);\nvar\ni, n  : word;\nsize  : word;\nfname : string;\nhdrop : word;\nbegin\n{1. Get the drop handle.}\nhdrop := msg.WParam;\n{2. Find out how many files were dropped by passing $ffff in arg #2.}\nn := DragQueryFile(hdrop, $ffff, nil, 0);\n{3. Loop through, reading in the filenames (w\/full paths).}\nfor i := 0 to (n - 1) do begin\n{4. Get the size of the filename string by passing 0 in arg #4.}\nsize := DragQueryFile(hdrop, i, nil, 0);\n{5. Make sure it won't overflow our string (255 char. limit)}\nif size < 255 then begin\nfname[0] := Chr(size);\n{6. Get the dropped filename.}\nDragQueryFile(hdrop, i, @fname[1], size + 1);\n{-- Do whatever you want to do with fname. --}\nend;\nend;\n{7. Return zero.}\nmsg.Result := 0;\n{8. Let the inherited message handler (if there is one) go at it.}\ninherited;\nend;\n\nprocedure TForm1.FormCreate(Sender: TObject);\nbegin\nDragAcceptFiles(Handle, true);\nend;\n\nprocedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);\nbegin\nDragAcceptFiles(Handle, false);\nend;\n\nKeep in mind that you don't have to put all of this stuff on a form.  Any windowed control that has an HWnd handle (descendants of TWinControl) should be able to accept dropped files.\n<\/div><\/pre>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>TListBox \u0438 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[413,386],"tags":[582,834,1030],"_links":{"self":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/249"}],"collection":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=249"}],"version-history":[{"count":0,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/249\/revisions"}],"wp:attachment":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=249"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}