[ 파워빌더.파일 - 목록가져오기2 ]

 

 

윈도우 하나 만듭니다.(w_dragfile)

 

Local External Functions 에 다음과 같이 선언합니다.

9버전 이하일 경우

/*───────────────────────────────────────
   탐색기에서 파일을 Drag & Drop
───────────────────────────────────────*/
FUNCTION int DragQueryFile(long hDrop, int iFile, REF string szFileName,int cb) LIBRARY "shell32.dll" alias for "DragQueryFile"
SUBROUTINE DragAcceptFiles(long l_hWnd,boolean fAccept) LIBRARY "shell32.dll"
SUBROUTINE DragFinish(long hDrop) LIBRARY "shell32.dll"

 

10버전 이상일 경우에는

/*───────────────────────────────────────
   탐색기에서 파일을 Drag & Drop
───────────────────────────────────────*/
FUNCTION int DragQueryFile(long hDrop, int iFile, REF string szFileName,int cb) LIBRARY "shell32.dll" alias for "DragQueryFile;Ansi"
SUBROUTINE DragAcceptFiles(long l_hWnd,boolean fAccept) LIBRARY "shell32.dll"
SUBROUTINE DragFinish(long hDrop) LIBRARY "shell32.dll"

 

open 이벤트)

DragAcceptFiles(handle(this), true)

 

ue_dropfiles 이벤트 생성)

pbm_dropfiles 를 선택합니다.

아래와 같이 스크립트를 작성하세요.

//파일 드래그 앤 드롭
//파일을 가져온다.
Ulong   hDrop
Integer   li_file, li_files, li_FNlen = 255
String   ls_filename = Space(li_FNlen)
string      ls_Files[], ls_file_nm
long   ll_cnt, ll_row

// 파일의 핸들리스트과 리스트 갯수
hDrop   = Message.WordParm
li_files  = DragQueryFile(hDrop, -1, ls_filename, li_FNlen) - 1

FOR li_file = 0 TO li_files 
 DragQueryFile(hDrop, li_file, ls_filename, li_FNlen)
 ls_Files[upperbound(ls_Files) + 1] = ls_filename 
NEXT
DragFinish(hDrop)
ll_cnt = upperbound(ls_files)
For li_file = 1 To ll_cnt
 //중복된 파일이 있는지 찾는다.
 IF dw_1.find("filepath = '"+ls_files[li_file]+"'", 1, dw_1.rowcount()) > 0 then continue
 ll_row = dw_1.InsertRow(0) 
 ls_file_nm = gf_stringtokenize(ls_files[li_file], '\', -1)
 dw_1.setItem(ll_row, 'filepath', ls_files[li_file])
 dw_1.setItem(ll_row, 'filename', ls_file_nm)
 dw_1.setItem(ll_row, 'fileext', gf_stringtokenize(ls_file_nm, '.', -1))
Next

 

이걸로 윈도우 쪽은 끝입니다.

다음은... DW 양식입니다.

release 9;
datawindow(units=0 timer_interval=0 color=1073741824 processing=1 HTMLDW=no print.printername="" print.documentname="" print.orientation = 0 print.margin.left = 110 print.margin.right = 110 print.margin.top = 96 print.margin.bottom = 96 print.paper.source = 0 print.paper.size = 0 print.canusedefaultprinter=yes print.prompt=no print.buttons=no print.preview.buttons=no print.cliptext=no print.overrideprintjob=no print.collate=yes hidegrayline=no grid.lines=0 )
header(height=76 color="536870912" )
summary(height=0 color="536870912" )
footer(height=0 color="536870912" )
detail(height=80 color="536870912" )
table(column=(type=char(255) updatewhereclause=yes name=filename dbname="filename" )
 column=(type=char(3) updatewhereclause=yes name=fileext dbname="fileext" )
 column=(type=char(500) updatewhereclause=yes name=filepath dbname="filepath" )
 )
text(band=header alignment="2" text="파일명" border="0" color="33554432" x="9" y="8" height="60" width="882" html.valueishtml="0"  name=filename_t visible="1"  font.face="Arial" font.height="-9" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" )
text(band=header alignment="2" text="확장자" border="0" color="33554432" x="901" y="8" height="60" width="183" html.valueishtml="0"  name=fileext_t visible="1"  font.face="Arial" font.height="-9" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" )
text(band=header alignment="2" text="파일전체경로" border="0" color="33554432" x="1093" y="8" height="60" width="1458" html.valueishtml="0"  name=filepath_t visible="1"  font.face="Arial" font.height="-9" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" )
column(band=detail id=1 alignment="0" tabsequence=32766 border="0" color="33554432" x="9" y="8" height="88" width="882" format="[general]" html.valueishtml="0"  name=filename visible="1" edit.limit=0 edit.case=any edit.focusrectangle=no edit.autoselect=yes edit.autohscroll=yes edit.imemode=0  font.face="Arial" font.height="-9" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" )
column(band=detail id=2 alignment="2" tabsequence=32766 border="0" color="33554432" x="901" y="8" height="88" width="183" format="[general]" html.valueishtml="0"  name=fileext visible="1" edit.limit=0 edit.case=any edit.focusrectangle=no edit.autoselect=yes edit.autohscroll=yes edit.imemode=0  font.face="Arial" font.height="-9" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" )
column(band=detail id=3 alignment="0" tabsequence=32766 border="0" color="33554432" x="1093" y="8" height="88" width="1458" format="[general]" html.valueishtml="0"  name=filepath visible="1" edit.limit=0 edit.case=any edit.focusrectangle=no edit.autoselect=yes edit.autohscroll=yes edit.imemode=0  font.face="Arial" font.height="-9" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" )
htmltable(border="1" )
htmlgen(clientevents="1" clientvalidation="1" clientcomputedfields="1" clientformatting="0" clientscriptable="0" generatejavascript="1" encodeselflinkargs="1" netscapelayers="0" )
export.xml(headgroups="1" includewhitespace="0" metadatatype=0 savemetadata=0 )
import.xml()
export.pdf(method=0 distill.custompostscript="0" xslfop.print="0" )
 

다음은 gf_stringtokenize 함수입니다.

global type gf_stringtokenize from function_object
end type

forward prototypes
global function string gf_stringtokenize (string as_source, string as_separator, integer ai_position)
end prototypes

global function string gf_stringtokenize (string as_source, string as_separator, integer ai_position);/*********************************************************************/
// Function : stringtokenize
//  Return Value
//     String  Tokenize 결과물
//  Arguments
//   Pass By ReadOnly  String as_source
//   Pass By ReadOnly  String as_separator
//   Pass By ReadOnly  integer ai_position(음수일 경우는 오른쪽부터 찾는다.)
/**********************************************************************/
integer count, start_pos = 1, str_length, end_pos = 0
string  ret_value, ls_source, ls_left_source
STring  ls_temp_source
integer li_pos, li_end_pos = 0
boolean end_chk = false, null_chk = false
String ls_Null
SetNull( ls_Null )
ls_source = as_source
if isnull( as_source ) or IsNull( as_separator ) THEN Return ''
IF ai_position = 0 THEN null_chk = true
IF ai_position < 0 THEN //뒤에서 찾는다.
 For count = 1 to ABS(ai_position)
   IF count > 1 THEN ls_source  = left(ls_source, end_pos - 1) 
    //as_separator 가 있는 마지막 위치를 구한다.
    //lastPos는 한글일 경우에도 1byte로 계산하므로, do loop을 이용해서 구한다.
    ls_temp_source = ls_source
    do
     li_pos = Pos( ls_temp_source, as_separator )
      If li_pos > 0 THEN
      li_end_pos += li_pos
       ls_temp_source  = mid(ls_temp_source, li_pos + Len(as_separator))
     END IF
    loop until(li_pos = 0)
   end_pos = li_end_pos
    IF end_pos = 0 and count < ai_position then
    null_chk = true
     exit
   ELSEIF end_pos = 0  THEN
   start_pos  = 1
   ELSE
   start_pos  = end_pos + Len(as_separator)  
   END IF  
 NEXT
 if null_chk then
    ret_value = ls_Null
 else
   ret_value = mid(ls_source, start_pos)
 end IF
ELSE //앞에서 찾는다..
 for count = 1 to ai_position
   IF count > 1 THEN ls_source  = mid(ls_source, end_pos + Len(as_separator))
   end_pos = pos(ls_source, as_separator, 1)
   IF end_pos = 0 and count < ai_position THEN
  null_chk = true
  exit
   ELSEIF end_pos = 0 THEN
  ls_left_source = ls_source
   ELSE
  ls_left_source = left(ls_source, end_pos - 1)
   END IF
 next
 if null_chk then
    ret_value = ls_Null
 else
   ret_value = ls_left_source
 end if
END IF
if isnull(ret_value) then ret_value = ''
return ret_value
end function

 

이제 구성된 화면을 보겠습니다.

 

 

 

 

Posted by 농부지기
,