win-user32-ruby 0.1.4.1 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README CHANGED
@@ -1,7 +1,9 @@
1
1
  = WinUser32Ruby
2
2
 
3
- ==0.1.4.1
3
+ ==0.1.5
4
+ * Added get_client_rect
5
+ * Added client_to_screen
4
6
 
5
- ==0.1.3.0
7
+ ==0.1.3
6
8
  * Fix Window#get_window_rect to prevent it from out of range values when a window's position is negative
7
9
  * Reorganized source to avoid namespace conflicts
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ require 'spec/rake/spectask'
13
13
 
14
14
  spec = Gem::Specification.new do |s|
15
15
  s.name = 'win-user32-ruby'
16
- s.version = '0.1.4.1'
16
+ s.version = '0.1.5'
17
17
  s.has_rdoc = true
18
18
  s.extra_rdoc_files = ['README', 'LICENSE']
19
19
  s.summary = 'Ruby wrapper for the user32.dll on Windows.'
@@ -54,6 +54,17 @@ module WinUser32Ruby
54
54
  pm.call hwnd, message, w_param, l_param
55
55
  end
56
56
 
57
+ def client_to_screen(hwnd, x, y)
58
+ cts = user32 'ClientToScreen', 'LP', 'I'
59
+ pout = [x, y].pack('L*')
60
+
61
+ cts.call hwnd, pout
62
+
63
+ x, y = pout.unpack("L*")
64
+ pout = [x, y].map { |p| [p].pack('L').unpack('l').first }
65
+
66
+ pout
67
+ end
57
68
  # Wrapper for +SetCursorPos+.
58
69
  # +x+:: x position
59
70
  # +y+:: y position
@@ -113,6 +113,21 @@ module WinUser32Ruby
113
113
  [left, top, right, bottom].map{|e| [e].pack('L').unpack('l').first}
114
114
  end
115
115
 
116
+ # Wrapper for +GetClientRect+.
117
+ # *Return*:: [left, top, right, bottom], coordinates are in screen coordinates and *not* relative to the client window as in the equivalent user32.dll
118
+ def get_client_rect
119
+ hwnd = @handle
120
+ crect = [0, 0, 0, 0].pack("L*")
121
+ gr = user32 'GetClientRect', 'LP', 'I'
122
+ gr.call hwnd, crect
123
+
124
+ left, top, right, bottom = crect.unpack("L*")
125
+ crect = [left, top, right, bottom].map { |e| [e].pack('L').unpack('l').first }
126
+
127
+ pout = client_to_screen(hwnd, crect[0], crect[1])
128
+ [pout[0], pout[1], pout[0] + crect[2], pout[1] + crect[3]]
129
+ end
130
+
116
131
  # Gets the coordinates to the center of this window
117
132
  # *Returns*:: <tt>[x, y]</tt>
118
133
  def get_center
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: win-user32-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4.1
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jerry Fernholz