Page 1 of 1

Client win- position in MDI gadget?

Posted: Thu May 19, 2005 4:42 pm
by Hurga
I have a question a concerning the MDI-gadget.
Is there a way to return the position of the client-Windows?

Or better: is there a way the return the mouse-position relative to the active client window?

If found a piece of code, the returns me the mouse position relative to the main window...

Any Ideas?

Posted: Fri May 20, 2005 2:43 pm
by Sparkie
Here's a way using Win32API.

Code: Select all

Procedure GetMdiMouse(hWin)
  mouseXY.POINT
  tLen = GetWindowTextLength_(hWin) + 1
  winText$ = Space(tLen)
  GetWindowText_(hWin, @winText$, tLen)
  If winText$ = ""
    winText$ = "MDI Gadget"
  EndIf
  mouseXY\x = DesktopMouseX()
  mouseXY\y = DesktopMouseY()
  ScreenToClient_(hWin, mouseXY)
  StatusBarText(0, 0, "Mouse   x: " + Str(mouseXY\x) + "   y: " + Str(mouseXY\y))
  StatusBarText(0, 1, "In " + winText$)
EndProcedure
If OpenWindow(0, 0, 0, 600, 400, #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget, "MDIGadget") And CreateGadgetList(WindowID())
  CreateStatusBar(0, WindowID())
  AddStatusBarField(300)
  AddStatusBarField(300)
  CreateMenu(0, WindowID(0))
  MenuTitle("Menu index 0")
  MenuTitle("MDI windows menu")
  MenuItem(0, "self created item")
  MenuItem(1, "self created item")
  MDIGadget(0, 0, 0, 0, 0, 1, 2, #PB_MDI_AutoSize)
  AddGadgetItem(0, -1, "MDI Window 1")
  AddGadgetItem(0, -1, "MDI Window 2")
  CloseGadgetList()
  Repeat
    event = WaitWindowEvent()
    GetMdiMouse(WindowFromPoint_(DesktopMouseX(), DesktopMouseY()))
  Until event = #PB_Event_CloseWindow
EndIf