Select Window 2
Quote from Gowtham on April 14, 2022, 12:18 pmIf 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 IfIfIf 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.
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)._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, 609The first Mouse Position of 505,1007 is actually the place where I clicked (a point where there is no DesktopWindow except the available desktop & full screen ones, which are ignored by my coding). The second Mouse Position of 1130, 609 is actually in the Ok button of the Message Box. When I click the Ok button, I get a popup saying that the a window is already created (in fact it refers to the Message Box) and is generated by this coding in the Mouse_Up event's coding for the SelectWindow class.
Catch
Message.Warning(ERROR.Text & " at " & ERROR.Where)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.
Dim hDesktopWindow as DesktopWindow
For Each i In Desktop.FindWindow(Null, Null, Null)
hDesktopWindow = New DesktopWindow(i)DesktopWindow(i)I've attached the current state of the app in compressed source. Please decompress it and run the app.
Click here to download: SelectWindow.tar.gz
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 IfIf
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.
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).
_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
The first Mouse Position of 505,1007 is actually the place where I clicked (a point where there is no DesktopWindow except the available desktop & full screen ones, which are ignored by my coding). The second Mouse Position of 1130, 609 is actually in the Ok button of the Message Box. When I click the Ok button, I get a popup saying that the a window is already created (in fact it refers to the Message Box) and is generated by this coding in the Mouse_Up event's coding for the SelectWindow class.
Catch
Message.Warning(ERROR.Text & " at " & ERROR.Where)
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.
Dim hDesktopWindow as DesktopWindow
For Each i In Desktop.FindWindow(Null, Null, Null)
hDesktopWindow = New DesktopWindow(i)DesktopWindow(i)
I've attached the current state of the app in compressed source. Please decompress it and run the app.
Click here to download: SelectWindow.tar.gz