Delphi Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
델파이 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
FreePascal/Lazarus
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
델마당
볼랜드포럼 광고 모집

델파이 Q&A
Delphi Programming Q&A
[9724] Re:[질문] 그림파일 아이콘을 드래그하여 이미지콘트롤 위에 놓으면 그림이 보여지게 하고 싶습니다
civilian [civilian] 1103 읽음    2004-07-13 13:41
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls;

type
  TForm1 = class(TForm)
    Image1: TImage;
    procedure FormCreate(Sender: TObject);
  private
    procedure ExtractFromLNK(FileName: String);
    procedure WMDROPFILES (var Msg: TMessage); message WM_DROPFILES;
  public
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses
  ShellAPI; // API함수 사용을 위해 반드시 포함

// // 바로가기에서 아이콘을 뽑아 TImage에 뿌리는 함수 //
procedure TForm1.ExtractFromLNK(FileName: String);
var
  Icons: PWORD;
  ico: TIcon;
  hic: HIcon;
begin
  GetMem(Icons, sizeof(word));
  Icons^ := 0;
  ico := TIcon.Create;
  hic := ExtractAssociatedIcon(Hinstance, PChar(FileName), Icons^);
  try
    ico.handle := hic;
    DrawIcon(ico.handle, 0, 0, hic);
    if not (ico.Empty) then
      Image1.Picture.Icon := ico;
  finally
    FreeMem(Icons, sizeof(word));
    ico.free;
  end;
end;

// // 파일이 드롭되었을 때 처리하는 함수 //
procedure TForm1.WMDROPFILES(var Msg: TMessage);
var
  i: Integer;
  Amount: Integer;
  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 s = '.lnk' then
    begin
      ExtractFromLNK(FileName);
    end;
    StrDispose(Filename);
  end;
  DragFinish(Msg.WParam);
end;

// // 드롭 메세지를 받을 수 있도록... //
procedure TForm1.FormCreate(Sender: TObject);
begin
  DragAcceptFiles(Form1.Handle, True));
end;

end.
곽성주 님이 쓰신 글 :
:
:
: 그림파일 아이콘을 드래그하여 이미지콘트롤 위에 놓으면 그림이 보여지게 하고 싶습니다. 어찌해야 하나요?
:
: 아이콘은 바탕화면에서 긁어올것입니다.
:
: 고수님들의 조언 바랍니다~

+ -

관련 글 리스트
9721 [질문] 그림파일 아이콘을 드래그하여 이미지콘트롤 위에 놓으면 그림이 보여지게 하고 싶습니다 곽성주 875 2004/07/12
9724     Re:[질문] 그림파일 아이콘을 드래그하여 이미지콘트롤 위에 놓으면 그림이 보여지게 하고 싶습니다 civilian 1103 2004/07/13
9728         Re:Re:[질문] 그림파일 아이콘을 드래그하여 이미지콘트롤 위에 놓으면 그림이 보여지게 하고 싶습니다 곽성주 876 2004/07/13
9729             Re:Re:Re:[질문] 그림파일 아이콘을 드래그하여 이미지콘트롤 위에 놓으면 그림이 보여지게 하고 싶습 civilian 1193 2004/07/13
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.