PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: AfxGetWindowLocation  (Read 386 times)

Paul Squires

  • Administrator
  • Master Member
  • *****
  • Posts: 8635
  • Windows 10
    • PlanetSquires Software
AfxGetWindowLocation
« on: June 20, 2018, 11:09:36 AM »

Hi Jose, curious as to why you decided to use pointers for the incoming nLeft and nTop parameters rather than using ByRef which would be more "BASIC-like"?

Code: [Select]
' ========================================================================================
' Gets the location of the top left corner of the window, in pixels.
' The location is relative to the upper-left corner of the client area in the parent window.
' ========================================================================================
PRIVATE SUB AfxGetWindowLocation (BYVAL hwnd AS HWND, BYVAL nLeft AS LONG PTR, BYVAL nTop AS LONG PTR)
   DIM rc AS RECT
   ' // Get the dimensions of the window
   GetWindowRect(hwnd, @rc)
   ' // Convert the coordinates to be relative to the parent
   MapWindowPoints(HWND_DESKTOP, GetParent(hwnd), CAST(POINT PTR, @rc), 2)
   ' // Return the left and top values
   *nLeft = rc.Left
   *nTop = rc.Top
END SUB
' ========================================================================================
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Josť Roca

  • Moderator
  • Master Member
  • *****
  • Posts: 3109
    • Jos
Re: AfxGetWindowLocation
« Reply #1 on: June 20, 2018, 12:04:57 PM »

Probably it was one of the first that I wrote and I was still trying to follow the syntax used by the FB includes. I can change it if you want.

Paul Squires

  • Administrator
  • Master Member
  • *****
  • Posts: 8635
  • Windows 10
    • PlanetSquires Software
Re: AfxGetWindowLocation
« Reply #2 on: June 20, 2018, 05:07:31 PM »

I'd vote for changing it because it seems out of place with the rest of your wrappers.
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Josť Roca

  • Moderator
  • Master Member
  • *****
  • Posts: 3109
    • Jos
Re: AfxGetWindowLocation
« Reply #3 on: June 20, 2018, 06:17:29 PM »

Changed to:

Code: [Select]
' ========================================================================================
' Gets the location of the top left corner of the window, in pixels.
' The location is relative to the upper-left corner of the client area in the parent window.
' ========================================================================================
PRIVATE SUB AfxGetWindowLocation (BYVAL hwnd AS HWND, BYREF nLeft AS LONG, BYREF nTop AS LONG)
   DIM rc AS RECT
   ' // Get the dimensions of the window
   GetWindowRect(hwnd, @rc)
   ' // Convert the coordinates to be relative to the parent
   MapWindowPoints(HWND_DESKTOP, GetParent(hwnd), CAST(POINT PTR, @rc), 2)
   ' // Return the left and top values
   nLeft = rc.Left
   nTop = rc.Top
END SUB
' ========================================================================================