Class: DragDropFiles

Inherits:
DragDropObject show all
Defined in:
lib/vr/dragdropformat.rb

Constant Summary collapse

FormatName =

DragDropFiles

This class deals the structure for drag-and-drop files.

Class Methods

— set(files)

Creates object and sets the file pathes in ((|files|)) to the object.

— get(handle)

Create object and sets the file pathes containing in ((|handle|)).
The ((|handle|)) is a global heap handle.

Methods

— files

Returns the file pathes.
"CF_HDROP"
FormatId =
ClipboardFormat::CF_HDROP
DragQueryFile =
Win32API.new("shell32","DragQueryFile", ["I","I","P","I"],"I")

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DragDropObject

#free_handle, #handle, #objectformat

Constructor Details

#initialize(files, handle = 0) ⇒ DragDropFiles

Returns a new instance of DragDropFiles.



114
115
116
117
118
119
# File 'lib/vr/dragdropformat.rb', line 114

def initialize(files,handle=0)
  @__files = files.dup
  @handle=handle
  @__binarydata="\0"*0x14+@__files.join("\0")+"\0"
  @__binarydata[0]=0x14
end

Class Method Details

.get(handle) ⇒ Object



125
126
127
128
129
130
131
132
133
134
# File 'lib/vr/dragdropformat.rb', line 125

def self.get(handle)
  __fnbuffer = "                "*16 #256bytes
  n=DragQueryFile.call(handle,-1,__fnbuffer,__fnbuffer.size)
  r=[]
  0.upto(n-1) do |i|
    s=DragQueryFile.call(handle,i,__fnbuffer,__fnbuffer.size)
    r.push __fnbuffer[0,s]
  end
  self.new(r,handle)
end

.set(files) ⇒ Object



121
122
123
# File 'lib/vr/dragdropformat.rb', line 121

def self.set(files)
  self.new(files)
end

Instance Method Details

#filesObject



136
137
138
# File 'lib/vr/dragdropformat.rb', line 136

def files
  @__files.dup
end