Two-line text button in Compact Framework

前端 未结 1 1624
礼貌的吻别
礼貌的吻别 2021-02-08 04:12

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/wi

相关标签:
1条回答
  • 2021-02-08 04:31

    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);
    }
    

    Use it like this:

    MakeButtonMultiline(button1);
    

    (source, verified it works on a CE device)

    0 讨论(0)
提交回复
热议问题