Compact Framework中的两行文字按钮 [英] Two-line text button in Compact Framework
问题描述
我想在Compact Framework中创建一个两行的文本按钮。我已在此线程中使用了所有想法,但没有成功。
I want to create a two-line text button in Compact Framework. I have used every idea in this thread but without success.
http://social.msdn.microsoft.com/forums/en-US/winforms/thread/626c21e0-369f-441e-b2f1- b51db633e38b
如果我使用 \n
或 \r\ \n
或 Environment.NewLine
我得到正方形。
If I use \n
or \r\n
or Environment.NewLine
I get squares.
我正在使用Compact Framework 3.5。
I am using Compact Framework 3.5.
关于如何制作两行文本框的任何想法吗?
Any idea on how to make a two-line text box?
推荐答案
您需要将按钮设置为允许多行。
You need to set the button to allow multiple lines. This can be achieved with following P/Invoke code.
private const int BS_MULTILINE = 0x00002000;
private const int GWL_STYLE = -16;
[System.Runtime.InteropServices.DllImport("coredll")]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[System.Runtime.InteropServices.DllImport("coredll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
public static void MakeButtonMultiline(Button b)
{
IntPtr hwnd = b.Handle;
int currentStyle = GetWindowLong(hwnd, GWL_STYLE);
int newStyle = SetWindowLong(hwnd, GWL_STYLE, currentStyle | BS_MULTILINE);
}
像这样使用:
MakeButtonMultiline(button1);
(源,验证它可以在CE设备上运行)
(source, verified it works on a CE device)
这篇关于Compact Framework中的两行文字按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!