Подтвердить что ты не робот

Двустрочная текстовая кнопка в Compact Framework

Я хочу создать двухстрочную текстовую кнопку в Compact Framework. Я использовал каждую идею в этом потоке, но безуспешно.

http://social.msdn.microsoft.com/forums/en-US/winforms/thread/626c21e0-369f-441e-b2f1-b51db633e38b

Если я использую \n или \r\n или Environment.NewLine, я получаю квадраты.

Я использую Compact Framework 3.5.

Любая идея о том, как сделать двухстрочное текстовое поле?

4b9b3361

Ответ 1

Вам нужно установить кнопку, чтобы разрешить несколько строк. Этого можно достичь с помощью следующего кода P/Invoke.

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)