Driven thanks, I'll look it looks interesting, I wonder if there will be a gem that allows some things like making Win32API so that they can perform on Mac
Anton would perform similar to yours definitions, but using Win32API
this is your original definition
def client_rect(hwnd, mode = 1)
return nil unless valid?(hwnd)
mode = mode.to_i
mode = 1 unless mode.between?(1,3)
lpRect = 0.chr*16
wins;;GetClientRect.call(hwnd, lpRect)
crect = lpRect.unpack('l*')
return crect if mode == 3
style = wins;;GetWindowLong.call(hwnd, -16)
exstyle = wins;;GetWindowLong.call(hwnd, -20)
wins;;AdjustWindowRectEx.call(lpRect, style, false, exstyle)
arect = lpRect.unpack('l*')
r = []
if mode == 1
wins;;GetWindowRect.call(hwnd, lpRect)
rect = lpRect.unpack('l*')
r[0] = rect[0] - arect[0]
r[1] = rect[1] - arect[1]
r[2] = r[0] + crect[2]
r[3] = r[1] + crect[3]
else
r[0] = -arect[0]
r[1] = -arect[1]
r[2] = r[0] + crect[2]
r[3] = r[1] + crect[3]
end
r
end
and this is what I try to do, I do not know if it is correct
require "Win32API"
GetClientRect = Win32API.new( 'user32.dll','GetClientRect', 'LP', 'B')
GetWindowLong = Win32API.new("user32.dll" , "GetWindowLong", "LI" , "L")
AdjustWindowRectEx = Win32API.new('user32.dll','AdjustWindowRectEx', 'PLBL', 'B')
GetWindowRect = Win32API.new('user32.dll','GetWindowRect', 'LP', 'B')
def client_rect(hwnd, mode = 1)
mode = mode.to_i
mode = 1 unless mode.between?(1,3)
lpRect = 0.chr*16
GetClientRect.call(hwnd, lpRect)
crect = lpRect.unpack('l*')
return crect if mode == 3
style = GetWindowLong.call(hwnd, -16)
exstyle = GetWindowLong.call(hwnd, -20)
AdjustWindowRectEx.call(lpRect, style, exstyle)
arect = lpRect.unpack('l*')
r = []
if mode == 1
GetWindowRect.call(hwnd, lpRect)
rect = lpRect.unpack('l*')
r[0] = rect[0] - arect[0]
r[1] = rect[1] - arect[1]
r[2] = r[0] + crect[2]
r[3] = r[1] + crect[3]
else
r[0] = -arect[0]
r[1] = -arect[1]
r[2] = r[0] + crect[2]
r[3] = r[1] + crect[3]
end
r
end
at this time I do not know how to get "hwnd" for sketchup window
(google translator)