locked
Maximize problem RRS feed

  • Question

  • Why my Small Basic program LSW046 bugs when the window is Maximized? I think the window coordinates are not updating only when maximized, but it works well when resizing.

    Saturday, May 21, 2016 5:51 PM

Answers

  • Screen (Mouse.MouseX(Y)) and GraphicsWindow (GraphicsWindow.MouseX(Y)) pixels are not neccessaily the same scale, it depends on the display dpi.  There are conversion method in LD extension but is tricky.

    My recommendation is is to use GraphicsWindow.MouseX(Y).

    GraphicsWindow.BackgroundColor = "DarkBlue"
    TextThing = Shapes.AddText(0)
    Ball = Shapes.AddEllipse(16, 16)
    GraphicsWindow.MouseMove = OnMouseMove
    
    Sub OnMouseMove
      Shapes.SetText(TextThing, "X=" + (Mouse.MouseX - GraphicsWindow.Left - 8) + " Y=" + (Mouse.MouseY - GraphicsWindow.Top - 31))
      Shapes.Move(Ball, GraphicsWindow.MouseX , GraphicsWindow.MouseY)
    EndSub
    

    • Marked as answer by Benur21 Saturday, May 21, 2016 10:00 PM
    Saturday, May 21, 2016 8:22 PM

All replies

  • Hi !

    On window maximized it work on my computer, coordinates  follow and updating very well !

    Saturday, May 21, 2016 6:01 PM
    Answerer
  • My computer: Windows 10 Home 64 bit

    Maybe a problem with the Windows.

    Saturday, May 21, 2016 6:08 PM
  • yes, you are right, on window maximized, mouse coordinates does not follow, it seems like it take the last coordinates of the maximize window icon, ,

    and if you add this into the top of your program: it work, mouse follow, but you start in a full 1366x 768 window.

    GraphicsWindow.top= 0
    GraphicsWindow.left= 0
    GraphicsWindow.Height = 700
    GraphicsWindow.Width = 1366

    Saturday, May 21, 2016 6:21 PM
    Answerer
  • my point of view: it's not your program because it work well on a 1366 x768 window.

    so i think it is the inter-relationship between Small Basic and Windows framework, and i don't know how to explain it, but stay tune, there is experts on this forum that will soon give the right answer.

    Saturday, May 21, 2016 6:38 PM
    Answerer
  • also i find this

    the window title bar height in maximized style is smaller then in resizable style, by exactly the number of pixels that the mouse pointer is not on the center of the ellipse. !

    Saturday, May 21, 2016 6:48 PM
    Answerer
  • Screen (Mouse.MouseX(Y)) and GraphicsWindow (GraphicsWindow.MouseX(Y)) pixels are not neccessaily the same scale, it depends on the display dpi.  There are conversion method in LD extension but is tricky.

    My recommendation is is to use GraphicsWindow.MouseX(Y).

    GraphicsWindow.BackgroundColor = "DarkBlue"
    TextThing = Shapes.AddText(0)
    Ball = Shapes.AddEllipse(16, 16)
    GraphicsWindow.MouseMove = OnMouseMove
    
    Sub OnMouseMove
      Shapes.SetText(TextThing, "X=" + (Mouse.MouseX - GraphicsWindow.Left - 8) + " Y=" + (Mouse.MouseY - GraphicsWindow.Top - 31))
      Shapes.Move(Ball, GraphicsWindow.MouseX , GraphicsWindow.MouseY)
    EndSub
    

    • Marked as answer by Benur21 Saturday, May 21, 2016 10:00 PM
    Saturday, May 21, 2016 8:22 PM
  • Screen (Mouse.MouseX(Y)) and GraphicsWindow (GraphicsWindow.MouseX(Y)) pixels are not neccessaily the same scale, it depends on the display dpi.  There are conversion method in LD extension but is tricky.

    My recommendation is is to use GraphicsWindow.MouseX(Y).

    GraphicsWindow.BackgroundColor = "DarkBlue"
    TextThing = Shapes.AddText(0)
    Ball = Shapes.AddEllipse(16, 16)
    GraphicsWindow.MouseMove = OnMouseMove
    
    Sub OnMouseMove
      Shapes.SetText(TextThing, "X=" + (Mouse.MouseX - GraphicsWindow.Left - 8) + " Y=" + (Mouse.MouseY - GraphicsWindow.Top - 31))
      Shapes.Move(Ball, GraphicsWindow.MouseX , GraphicsWindow.MouseY)
    EndSub
    

     Thanks, I didn't know about the GraphicsWindow.MouseX/Y so I tried to use the Mouse.MouseX/Y.

     I changed that and now it is working even maximized: LCC411

    Saturday, May 21, 2016 10:02 PM
  • Cool !!
    Saturday, May 21, 2016 10:09 PM
    Answerer