111,094
社区成员




userdefineTextBox.hwnd
UserControl.Parent
Screen.TwipsPerPixelY
userdefineTextBox.Alignment = vbCenter;
UserControl.Height
UserControl.Width;
struct LVITEM
{
private Int32 mask;
private Int32 iItem;
private Int32 iSubItem;
private Int32 state;
private Int32 stateMask;
private string pszText;
private Int32 cchTextMax;
private Int32 iImage;
private Int32 lParam;
private Int32 iIndent;
}
[DllImport("user32.dll", EntryPoint = "SendMessageA")]
static extern Int32 SendMessage (Int32 hwnd, Int32 wMsg, Int32 wParam, LVITEM pitem);
private const string EM_GETRECT = "&HB2";
private const string EM_SETRECTNP = "&HB4";
private struct RECT
{
public long Left;
public long Top;
public long Right;
public long Bottom;
}
private void SetVCenterText(TextBox userdefineTextBox)
{
RECT rc;
long UserControlTop;
long UserControlBottom;
if(userdefineTextBox.Multiline == false)
{
SendMessage(userdefineTextBox.hwnd, EM_GETRECT, 0, rc);
UserControlTop = ((rc.Bottom - rc.Top) - (UserControl.Parent.TextHeight("H")/Screen.TwipsPerPixelY))/2;
UserControlBottom = ((rc.Bottom - rc.Top) + (UserControl.Parent.TextHeight("H") / Screen.TwipsPerPixelY))/2;
rc.Top = UserControlTop;
rc.Bottom = UserControlBottom;
userdefineTextBox.Alignment = vbCenter;
SendMessage(userdefineTextBox.hwnd, EM_SETRECTNP, 0, rc);
userdefineTextBox.Refresh();
}
}
private void UserControl_Resize()
{
textBox1.Top = 0;
textBox1.Left = 0;
textBox1.Height = UserControl.Height;
textBox1.Width = UserControl.Width;
SetVCenterText(textBox1);
}
using System.Runtime.InteropServices;
[DllImport("user32.dll", EntryPoint="SendMessageA")]
public static extern int SendMessage (IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", EntryPoint="SendMessageA")]
private static extern int SendMessage (IntPtr hwnd, int wMsg, IntPtr wParam, string lParam);
[DllImport("user32.dll", EntryPoint="SendMessageA")]
private static extern int SendMessage (IntPtr hwnd, int wMsg, IntPtr wParam, ref Rectangle lParam);
struct LVITEM
{
private Int32 mask;
private Int32 iItem;
private Int32 iSubItem;
private Int32 state;
private Int32 stateMask;
private string pszText;
private Int32 cchTextMax;
private Int32 iImage;
private Int32 lParam;
private Int32 iIndent;
}
[DllImport("user32.dll", EntryPoint="SendMessageA")]
static extern Int32 SendMessageA (Int32 hwnd, Int32 wMsg, Int32 wParam, LVITEM pitem);