2015년 12월 31일 목요일

델파이에서 다른 프로그램(탐색기)에서 드래그 드롭구현하기

폼에 드래드&드롭이 있어 간단 할 줄 알았는데 Source 에서 탐색기를 가려낼 수 가 없어서.
procedure TFrmFire.FormDragDrop(Sender, Source: TObject; X, Y: Integer);
begin
end;

인터페이스 부분에서
  protected
    procedure WMDROPFILES(var Msg: TMessage); message WM_DROPFILES;

구현부에서
procedure TFrmFire.WMDROPFILES(var Msg: TMessage);
var
i, amount, Size: integer;
Filename: PChar;
S: String;
begin
inherited;
amount := DragQueryFile(Msg.WParam, $FFFFFFFF, Filename, 255);
for i := 0 to (amount - 1) do begin
Size := DragQueryFile(Msg.WParam, i, nil, 0) + 1;
Filename := StrAlloc(Size);
DragQueryFile(Msg.WParam, i, Filename, Size);
S := ExtractFileExt(Filename);
if not ZTable1.Active then ZTable1.Open; //이곳부턴 그때 그때 달라요.
ZTable1.Edit;
DBMemo1.Lines.Add(String(Filename)); //이곳 까지
StrDispose(Filename);
end;
DragFinish(Msg.WParam);
end;

폼 생성시
procedure TFrmFire.FormCreate(Sender: TObject);
begin
  DragAcceptFiles(Handle, True); // 드래그&드롭이 가능하도록
end;

폼 닫을때
procedure TFrmFire.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  DragAcceptFiles(FrmEditor.Handle, false);
end;

또 다른 방법은..

선언부에서
  protected
    iEdMp3WindowProc: TWndMethod;
    procedure EdMp3WindowProc(var Msg: TMessage);
    procedure EdMp3Drop(var Msg: TWMDROPFILES);

구현부에서

procedure TfrmStudyLaw2.Edmp3WindowProc(var Msg: TMessage);
begin
  if Msg.Msg = WM_DROPFILES then EdMp3Drop(TWMDROPFILES(Msg))
  else iEdMp3WindowProc(Msg);
end;

procedure TfrmStudyLaw2.EdMp3Drop(var Msg: TWMDROPFILES);
var
buffer: array [0 .. MAX_PATH] of Char;
iStr: string;
begin
if DragQueryFile(Msg.Drop, $FFFFFFFF, nil, 0) <> 1 then exit;
DragQueryFile(Msg.Drop, 0, @buffer, Sizeof(buffer));
ZQuery1.Edit; // 이곳 부터 그때 그때 달라요
iStr := 'Mp3\' + ExtractFileName(buffer);
ZQuery1.FieldByName('igichul').AsString := iStr;
ZQuery1.Post; // 이곳 까지
DragFinish(Msg.Drop);
// EdMp3Drop(Msg) 이것 넣어주어야 정상일 것 같기도 하고 아닌 것 같기도 하고
end;


역시 폼 생성시
procedure TfrmStudyLaw2.FormCreate(Sender: TObject);
var
// Drag & Drop
iEdMp3WindowProc := edMp3.WindowProc;
edMp3.WindowProc := Edmp3WindowProc;
DragAcceptFiles(edMp3.Handle, True);
end;

역시나 폼 닫을 때
procedure TFrmFire.FormClose(Sender: TObject; var Action: TCloseAction);
begin
DragAcceptFiles(edMp3.Handle, false);
end;



tensorflow gpu 사용하기에서

 tensorflow 설치시 주의해야 한다. # Anything above 2.10 is not supported on the GPU on Windows Native python - m pip install "tensorflow<2.11...