Grid Images

Started by Jeffrey Ferreira, May 01, 2025, 02:01:26 PM

Previous topic - Next topic

Jeffrey Ferreira

Hi All,

a client asked there was a way when we are displaying our images in a grid for product options if there was a way they could right click on the option and copy it so that they could paste in an email to send to customers.

is this possible?

jeff

Mike King

Jeff

Do you want to copy the image or the text of product option?

Mike King
President - BBSysco Consulting - http://www.bbsysco.com
eMail: mike.king@bbsysco.com

Jeffrey Ferreira

Hi Mike,

the image if possible.

jeff

Jeffrey Ferreira

Hi Mike, so is there no way to copy the image that you know of

Mike King

Not directly but you should be able to detect/process the right click yourself and use a utility such as nircmd to copy the image file to the clipboard.  You can also use a powershell script to copy the image.
Mike King
President - BBSysco Consulting - http://www.bbsysco.com
eMail: mike.king@bbsysco.com

Jeffrey Ferreira

#5
Hi Mike,
i found a three line powershell script.
it worked great. Exactly what we needed.
thanks again.
jeff

HendersonS

Hi Jeffrey, can you post the solution you found?

Mike King

Here is a simple program you can use to copy an image to the clipboard.  Simply set this program as the 'popup' processor for the grid cells for which you have the bitmap$ attribute set.

! Utility to copy image from Grid cell to clipboard
! Set the "popup" attribute of the image cell to perform this program
  local file$
  file$=pth(id'bitmap$,err=*next)
  if file$="" \
   then msgbox "Cannot copy";
        exit
  popup_menu "[Copy image=1001]",x
  if x<>1001 \
   then exit
  open (hfn)"|powershell.exe"
  x$="Add-Type -AssemblyName System.Windows.Forms;"
  x$+="Add-Type -AssemblyName System.Drawing;"
  x$+="[Windows.Forms.Clipboard]::SetImage($([System.Drawing.Image]::Fromfile("+quo+file$+quo+")));exit;"
  open (hfn)">powershell.exe"
  print (lfo)x$
  close (lfo)

NOTE: You would need to tweak the code a bit to work under WindX.  Basically you would need to copy the file from the server to a scratch file on the workstation and pass that workfile name to powershell.
Mike King
President - BBSysco Consulting - http://www.bbsysco.com
eMail: mike.king@bbsysco.com

Jeffrey Ferreira

Hi HendersonS,

I used to get notified when i was on a thread and someone replied to it. I'm not sure what i changed in my settings.  I know Mike already replied but here was my call program where you pass in the Image Path

27000 ! ^1000
27010 COPY_IMAGE_TO_CLIPBOARD:
27020 ! This was originally Needed so Internal/External Users could right click and copy pictures to send to their customers.
27030 ! The Powershell Script was found on line.
27040 ! Mike King (5/8/2025) said that there was not a way to copy an image in Pxplus at this time.
27050 enter (IMAGE_PATH$)
27060 if nul(IMAGE_PATH$) then goto *end
27070 call "CAIREPOS;CREATE_TEMP_FILE",POWERSHELL_SCRIPT$,".ps1" ! This just creates a blank text file with a Unique Name
27080 let POWERSHELL_SCRIPT=unt; open lock (POWERSHELL_SCRIPT)POWERSHELL_SCRIPT$
27090 print (POWERSHELL_SCRIPT)"Add-Type -AssemblyName System.Drawing, System.Windows.Forms"
27100 print (POWERSHELL_SCRIPT)"$bitmap = New-Object System.Drawing.Bitmap("+quo+IMAGE_PATH$+quo+")"
27110 print (POWERSHELL_SCRIPT)"[System.Windows.Forms.Clipboard]::SetImage($bitmap)"
27120 close (POWERSHELL_SCRIPT)
27130 let CMD$="^powershell.exe -ExecutionPolicy Bypass -File "+quo+POWERSHELL_SCRIPT$+quo
27140 call "MCSYSC",CMD$ ! This internal program executes the powershell script
27990 exit