From: Su Zhang Date: 2011-02-02T07:12:49+09:00 Subject: Re: Call SendMessage WinAPI to get item_rect for tree control You need to pass a buffer to SendMessage to store the rectangle's information. You can pass the API a Ruby string, and Win32API will pass the actual address of the string to the API. The API then mutate the string content so that it stores the rectangle information. The string itself is like a primitive structure containing different fields, and later on you can use String#unpack to retrieve every single field. Suppose you already have the handle to the controls and the message's internal integer representation defined: buf = [handle_tree_item, 0, 0, 0].pack('l*') send_message = Win32API.new('user32', 'SendMessage' , ['L' , 'L' , 'L' , 'P' ], 'L') sned_message.call(handle_tree_view, TVM_GETITEMRECT, 0, buf) rect = buf.unpack('l*') rect[0] # left rect[1] # top rect[2] # right rect[3] # bottom > And I don't know what is *(HTREEITEM *)prc = (hitem) and how to do this > on Ruby. This is basically a dereference operation on the pointer prc, which cannot be done in Ruby in the language level. You can use RtlMoveMemory supplied by kernel32.dll to achieve the same thing in an ugly manner. -- Posted via http://www.ruby-forum.com/.