1. Olan Knight
  2. PowerBuilder
  3. Wednesday, 4 March 2020 20:01 PM UTC

Update:

   Reading one of the other questions from today from Ivan Aase led me to try the following....
        this.Print (ll_job, 0, 0)

   ....where "this" is the current window. That successfully printed the window, which is what I was going for with the Alt+Printscreen printing code below.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


PowerBuilder v12.1, build 7055
Windows 7m 64 bit platform
Oracle 12C


The goal is to print the Clipboard. Here's what I have so far. The issue is that I cannot seem to get the contents of the Clipboard into the blob variable.

Any ideas?

 

// Local external function
SUBROUTINE keybd_event (int bVk, int bScan, int dwFlags, int dwExtraInfo) LIBRARY "user32.dll"

// Code in the pfc_print event
// Start the print job
ll_job = PrintOpen()

// Put the current window into the Clipboard as a bitmap = [Alt + PrintScreen]
keybd_event ( 44,1,0,0 )
 
// Convert the Clipboard image to a blob
ll_rc = BlobEdit ( lblob, 1, Clipboard() )     <=== ERROR, this returns NULL

// Set the blob into a Picture object
ll_rc = lpic.Setpicture(lblob)

// Print the pictureobject
ll_rc = lpic.Print ( ll_job, 1, 1)

// Close the print job
PrintClose (ll_job)


Thanks,

Olan

Roland Smith Accepted Answer Pending Moderation
  1. Wednesday, 4 March 2020 20:37 PM UTC
  2. PowerBuilder
  3. # 1

My Bitmap example can:

Capture a control

Capture a window

Capture the entire screen

The capture returns a blob which you can then write to disk as a .bmp or save to the database. You can also have it sent to the clipboard if you want to be able to paste it into Word or Outlook.

 

Comment
  1. Olan Knight
  2. Wednesday, 4 March 2020 21:12 PM UTC
I read the explanation, and this looks like a wonderful tool!

Thank you for sharing it!



Olan
  1. Helpful
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Wednesday, 4 March 2020 20:17 PM UTC
  2. PowerBuilder
  3. # 2

PB's clipboard() function does not return a bitmap.  it only returns a string 

Comment
  1. Olan Knight
  2. Wednesday, 4 March 2020 20:39 PM UTC
When reading the HELP , that was a bit unclear. Testing, however, clarified that quickly. :)

Thanks for your response!



Olan
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Wednesday, 4 March 2020 20:15 PM UTC
  2. PowerBuilder
  3. # 3

Hi, Olan - 

From the PB Help, Clipboard (PowerScript function):

Returns the current contents of the clipboard if the clipboard contains text. If string is specified, Clipboard returns the current contents and replaces it with string.

Returns the empty string ("") if the clipboard is empty or it contains nontext data, such as a bitmap. If string is specified, the nontext data is replaced with string. If string is null, Clipboard returns null.

I think you're going to have to use Windows API calls to obtain the bitmap out of the Windows Clipboard. Look at Roland's TopWizProgramming site. He has a free code example that captures an image of a window.

Regards, John

Comment
  1. John Fauss
  2. Wednesday, 4 March 2020 20:17 PM UTC
It is the free code example named "Bitmap".
  1. Helpful
  1. Chris Pollach @Appeon
  2. Wednesday, 4 March 2020 20:20 PM UTC
  1. Helpful
  1. Olan Knight
  2. Wednesday, 4 March 2020 20:40 PM UTC
I did see that, John, and I thank you for pointing it out.



Olan
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.