[Gambas-user] Gambas2 Grab in Gambas3

Fabien Bodard gambas.fr at ...626...
Tue Nov 8 18:31:01 CET 2016


Well... there is two answers.

First :

Use the Desktop.ScreenShot Function
(http://gambaswiki.org/wiki/comp/gb.qt4/desktop/screenshot).
But your widget must be visible on the screen... This is why it is a
SCREEN shot.


Second :

When you are drawing something in a drawingarea you use a generic
drawing function.

Exemple :


Public sub DrawingArea_Draw()

DrawARect()

End


Private Sub DrawARect()

  Paint.Brush = Brush.Color(Color.Yellow)
  Paint.Rectangle(10,10,Paint.Width - 20, Paint.Height - 20)
  Paint.Fill

End


Public Function MakeImage(iWidth as integer, iHeight as integer) as Image

  Dim hImage a new Image(iWidth, iHeight, Color.White)

  Paint.Begin(hImage)
     DrawARect()
  Paint.End

End


With that you have only one drawing function (DrawARect) able to draw
every where ... even on a printer. This is the way used in most of the
components too

2016-11-08 12:52 GMT+01:00 Richard Welch <richardpa608 at ...626...>:
> I need a simple way to copy the current image in a visible DrawingArea
> to a hidden PictureBox.
>
> The project was written in Gambas2, where a simple Grab method did the
> trick, but in G3 this does something different so the converted code
> does not function fully.
>
> FMain.pbxPicture.W = FMain.drwRep.W
> FMain.pbxPicture.H = FMain.drwRep.H
> FMain.pbxPicture.Background = FMain.drwRep.Background
> FMain.pbxPicture.Picture = FMain.drwRep.Grab()
>
> With what do I replace the Grab method?
>
> (The DrawingArea is painted in many different pieces of code, depending
> on context, so I want to make the change which will have the smallest
> impact possible on the source code)
>
> There is a gambas-user thread started around 19 April 2012.
> Is this fully relevant?
> Is this the /simplest/ answer?
> It would need some very tedious testing in my context.....
>
> ------------------------------------------------------------------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user



-- 
Fabien Bodard




More information about the User mailing list