[Gambas-user] Selecting a window

John Rose john.aaron.rose at ...626...
Thu Dec 5 17:20:26 CET 2013


Fabien,

I've looked at your "quick & dirty way". I don't think that it's what I 
want. I want the user to be able to select a window on the desktop (i.e. 
not just Gambas forms in a Gambas app) by clicking on any point in that 
window, not selecting it by dragging on the corners of a rectangle to 
its corners before clicking. Below is shown the method that I identified 
but is it the best/only way? Also, I don't see how to allow for the 
situation where the user has clicked a point which is within 2 or more 
windows i.e. is there a property of dWindow which shows if that window 
is the 'top' one (i.e. covering the other one(s) at that point)? This 
means that the user has to first ensure that the required window in on 
'top'.

As I previously said, the code below shows how to access properties of 
all windows (i.e. not just Gambas forms in a Gambas app):
Dim dWindow As DesktopWindow = Null
Desktop.Windows.Refresh()
For Each dWindow In Desktop.Windows
   If dWindow.Minimized = False Then
      Print "Window: Name=" & dWindow.Name & ", " & "X=" & dWindow.X & 
", Y=" & dWindow.Y & ", " & "Width=" & dWindow.Width & ", Height=" & 
dWindow.Height
   Endif
Next

The only way I've thought of is to define a transparent form covering 
the whole desktop with an associated mouse click event, which supplies 
the co-ordinates of the point clicked. Then by examination of the 
properties (i.e. X, Y, Width, Height) of each dWindow, one can determine 
which window has been clicked by the user.

-- 
Regards, John




More information about the User mailing list