| C#だとこれであってますか?
[StructLayout(LayoutKind.Sequential)]
private class comboBoxInfo
{
public int Size;
public Rectangle RectItem;
public Rectangle RectButton;
public int ButtonState;
public IntPtr ComboBoxHandle;
public IntPtr EditBoxHandle;
public IntPtr ListBoxHandle;
public void New()
{
this.Size = Marshal.SizeOf(this);
}
}
[DllImport("user32.dll")]
private extern static bool GetComboBoxInfo(IntPtr hwindCombo, comboBoxInfo cbi);
[DllImport("user32.dll")]
private extern static int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
[DllImport("user32.dll")]
private extern static int GetWindowLong(IntPtr hWnd, int nIndex);
private const int GWL_STYLE = -16;
private const int ES_RIGHT = -8;
private void SetRightAlign(ComboBox combo)
{
comboBoxInfo ci = new comboBoxInfo();
if(!GetComboBoxInfo(combo.Handle, ci))
{
return;
}
if (ci.EditBoxHandle == IntPtr.Zero)
{
return;
}
int style = GetWindowLong(ci.EditBoxHandle, GWL_STYLE);
SetWindowLong(ci.EditBoxHandle, GWL_STYLE, style);
}
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
SetRightAlign(comboBox1);
} |