title: How to cast an array to pointer and back in Delphi?
body: <p>I have an owner drawn combo box that displays the strings in columns. The drawing routine can be shared across combos if I can somehow pass the column specifications to the OnDrawItem event. A natural way to do so, would be to pass the array of column widths in the ComboBox.Tag property and then cast it back to an array.</p>
  
  <p>When I define the column array as:</p>
  
  <pre><code>const arrWidth :array[1..4] of integer = (100,100,100,70);
  </code></pre>
  
  <p>and set the Tag property to:</p>
  
  <pre><code>ComboBox.Tag := integer(@arrWidth);
  </code></pre>
  
  <p>and then in the OnDrawItem event, cast it back to an array:</p>
  
  <pre><code>Widths :array of integer;
  Widths := pointer(ComboBox.Tag);
  </code></pre>
  
  <p>I can see the array elements fine, but the array does not know it's length. It appears to be much longer with all sorts of random values.  </p>
  
  <p>I have tried using a dynamic array, but then I don't even get the proper column values.</p>