If you run my app, you will see that after the Message Box is clicked the Mouse_Up event is entered again: this is shown by the console output (i.e. it comes up with the Message Box when I click in a point not in a Desktop Window, excluding all of Desktop) when I comment out the Lock & Unlock lines. That's why I put in the Lock & Unlock lines.:
If bWindowSelected Then
Print "Window Selected"
Else
' Last.Lock
Application.Busy = 0
Message.Title = "Try again:"
Message.Info("Did not click on window.")
' Last.Unlock
Return
End If
I've already looked at the Help for Lock & Unlock, but they didn't help me! I don't get why I shouldn't use Lock in order to prevent entry to the Mouse_Up coding when the user clicks the Message Box Ok button. Please explain.Regarding the 'Lock' situation I think you have the wrong idea about this. Have a look here.
If you run my app, you will see that after the Message Box is clicked the Mouse_Up event (for the DrawingArea object's DrawingAreaDesktop instance) is entered again: this is shown by the console output below (using the </> button as it's not Gambas coding but, questionably, Coding) to prevent entry to the Mouse_Up coding when the user clicks the Message Box Ok button. The only reason that I can think of this happening is re-entry to the Mouse_Up coding when the user clicks the Message Box Ok button.After some experimentation we found that the 'Last' is not changed by the 'Message Box' so you don't need the 'Lock' anyway, try the code below. If you did need to store the 'Last' just create a variable to store it in.
(As mentioned before the window below is created with the 'gb' button not the '</>' code button)
Public Sub Button1_Click()
Message.Info("Did not click on window.")
Print Last.name
End
The 'DrawingArea1_MouseUp' routine will not get called again as the MessageBox is not the 'DrawingArea'.
I've finally remembered to use the 'gb' button when quoting Gambas Coding: reason I forgot to click the gb button on previous posts is that I'm so used to clicking the '</>' button when quoting code (on other forums).
Code: Select all
_NET_CLIENT_LIST_STACKING(WINDOW): window id # 0x1e0000a, 0x3c00006, 0x3200007, 0x32743bb, 0x32703e2, 0x3600010, 0x2c00001, 0x400000e
0x1e0000a, 0x3c00006, 0x3200007, 0x32743bb, 0x32703e2, 0x3600010, 0x2c00001, 0x400000e
Split
1e0000a
3c00006
3200007
32743bb
32703e2
3600010
2c00001
400000e
Reverse
400000e
2c00001
3600010
32703e2
32743bb
3200007
3c00006
1e0000a
DesktopWindow: Name=Downloads VisibleName=Downloads
i=52888546 Hex(i)=32703E2
Id=52888546 Hex(Id)=32703E2
Left=905 Top=151 Width=881 Height=594
DesktopWindow: Name=Dropbox VisibleName=Dropbox
i=52904891 Hex(i)=32743BB
Id=52904891 Hex(Id)=32743BB
Left=98 Top=176 Width=1231 Height=874
DesktopWindow: Name=john@JohnPC: ~ VisibleName=john@JohnPC: ~
i=62914566 Hex(i)=3C00006
Id=62914566 Hex(Id)=3C00006
Left=665 Top=431 Width=734 Height=458
DesktopWindow: Name=FSelectWindow.class - SelectWindow 0.0.50 - Gambas 3 VisibleName=FSelectWindow.class - SelectWindow 0.0.50 - Gambas
3
i=67108878 Hex(i)=400000E
Id=67108878 Hex(Id)=400000E
Left=662 Top=86 Width=1204 Height=952
Mouse Position = 505, 1007
Mouse Position = 1130, 609
Catch
Message.Warning(ERROR.Text & " at " & ERROR.Where)
You're correct about the Break in the above code: it shouldn't have been there. I actually removed it in the above code.There is a 'Break' in your code that is not inside a loop. This generates an error.
I've never really understood the New keyword usage in Dim or actual code such as 'hDesktopWindow = New DesktopWindow(i)' in this coding (in Form_Open event of SelectWindow class). I used the New keyword in that class's coding because there was a runtime error without it.I noticed this 'aWindow = []' code. You don't need this, if you set up your Array with Dim aWindow as New Window it will be set up as a Dynamic array.
Dim hDesktopWindow as DesktopWindow
For Each i In Desktop.FindWindow(Null, Null, Null)
hDesktopWindow = New DesktopWindow(i)
I've attached the current state of the app in compressed source. Please decompress it and run the app.