[Gambas-user] Select Area using mouse

John Rose john.aaron.rose at gmail.com
Sat May 16 13:26:02 CEST 2020


I posted to the Gambas User List yesterday. I sent, with the email, an 
attachment of my 'stripped down' project as a compressed source 
(Test.tar.gz). When I look at the Archive, specifically my post, it says:

A non-text attachment was scrubbed...
Name: Test.tar.gz
Type: application/gzip
Size: 67367 bytes
Desc: not available
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20200515/e997d432/attachment-0001.gz>

I haven't posted for years. People when replying to posts asking for 
help with a project generally ask me for the project in a 'stripped 
down' form. Perhaps I should attach a project in a different way. If so, 
what? So here's the code: ' Gambas class file Private iAreaLeft As 
Integer Private iAreaTop As Integer Private iAreaWidth As Integer 
Private iAreaHeight As Integer Public Sub _new() FSelectArea.Left = 
Screen.AvailableX FSelectArea.Top = Screen.AvailableY FSelectArea.Width 
= Screen.AvailableWidth FSelectArea.Height = Screen.AvailableHeight 
DrawingAreaDesktop.Left = Screen.AvailableX DrawingAreaDesktop.Top = 
Screen.AvailableY DrawingAreaDesktop.Width = Screen.AvailableWidth 
DrawingAreaDesktop.Height = Screen.AvailableHeight End Public Sub 
Form_Open() Message.Title = "To Specify Area to be Recorded:" 
Message.Info("Mouse button down & hold down on top left corner, drag to 
bottom right corner, and mouse button up.") Inc Application.Busy 
iAreaLeft = Screen.Width iAreaTop = Screen.Height iAreaWidth = 0 
iAreaHeight = 0 Finally Application.Busy = 0 Catch 
Message.Warning(ERROR.Text) End Public Sub 
DrawingAreaDesktop_MouseDown() Inc Application.Busy ' Print "Area 1st 
corner: X=" & Mouse.X & ", Y=" & Mouse.Y iAreaLeft = Mouse.X iAreaTop = 
Mouse.Y Paint.Begin(Last) Finally Application.Busy = 0 Catch 
Message.Warning(ERROR.Text) End Public Sub 
DrawingAreaDesktop_MouseMove() If iAreaLeft >= Mouse.X Or iAreaTop >= 
Mouse.Y Then Return Endif Inc Application.Busy iAreaWidth = Mouse.X - 
iAreaLeft iAreaHeight = Mouse.Y - iAreaTop Paint.Rectangle(iAreaLeft, 
iAreaTop, iAreaWidth, iAreaHeight) Finally Application.Busy = 0 Catch 
Message.Warning(ERROR.Text) End Public Sub DrawingAreaDesktop_MouseUp() 
If iAreaLeft >= Mouse.X Or iAreaTop >= Mouse.Y Then Message.Title = "Try 
again:" Message.Info("You have not selected an area") Return Endif Inc 
Application.Busy ' Print "Area 2nd corner: X=" & Mouse.X & ", Y=" & 
Mouse.Y iAreaWidth = Mouse.X - iAreaLeft iAreaHeight = Mouse.Y - 
iAreaTop Paint.End Print "You have selected this area: " & iAreaLeft & 
", " & iAreaTop & ", " & iAreaWidth & " ," & iAreaHeight 
FMain.iRegionLeft = iAreaLeft FMain.iRegionTop = iAreaTop 
FMain.iRegionWidth = iAreaWidth FMain.iRegionHeight = iAreaHeight 
Last.Close Finally Application.Busy = 0 Catch 
Message.Warning(ERROR.Text) End


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20200516/4dd8942f/attachment.html>


More information about the User mailing list