- Rick Domogalik
- PowerBuilder
- Wednesday, 22 July 2020 12:48 PM UTC
I am trying to copy files into the clipboard so they can be pasted to windows explorer or as an attachment into outlook from my application. I found the below referenced method for doing this. the code compiles and run with no error, but nothing is placed into the clipboard. My assumption is there is a problem with the format of the file string I am sending to the function (yellow highlight). This function should allow for multiple files to be selected and placed into the clipboard, but I am just testing with a single file. Also wondering if the Green Highlight - Preferred drop effect should be a value not a text string. The MS documentation on this argument was not easy to understand how to format this item.
This code was also very old. Not sure if something has changed with newer Windows OS.
Any help is greatly appreciated.
Rick
boolean lb_return
ulong hdf,h2
ulong df,D2
ulong drop[]
ulong closing
blob{1000} buf1
blob{4} buf2
long ll_pos, ll_len
string files
string CFSTR_PREFERREDDROPEFFECT = 'Preferred DropEffect';
ulong DROPEFFECT_COPY = 1;
uint copyformat
ll_len = len(files) + 1
drop = {ll_len,0,0,0,0 }
closing = 0
format = 15
ll_pos = blobedit(buf1,1,drop[1])
ll_pos = blobedit(buf1,5,drop[2])
ll_pos = blobedit(buf1,9,drop[3])
ll_pos = blobedit(buf1,13,drop[4])
ll_pos = blobedit(buf1,17,drop[5])
ll_pos = blobedit(buf1,ll_pos,closing)
//hdf = GlobalAlloc(66, ll_pos)
df = GlobalLock(hdf);
CopyMemory(df, buf1 , ll_pos)
GlobalUnlock(hdf)
h2 = GlobalAlloc(66,4)
d2 = GlobalLock(h2);
CopyMemory(d2, buf2 , 4)
GlobalUnlock(h2)
if lb_return then
lb_return = EmptyClipboard();
messagebox("test",lb_return);
copyformat = RegisterClipboardFormatA (CFSTR_PREFERREDDROPEFFECT);
messagebox("test",copyformat);
SetClipboardData(copyformat,d2);
SetClipboardData(format,df);
lb_return = CloseClipboard();
else
messagebox("test","Copy to clipboard failed!!!");
end if
if lb_return then
return 1
else
return -1
end if
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.