C#

[C#/PDA]Button의 텍스트 문자열 다중 출력 예제

선영아 사랑해 2016. 1. 18. 13:25

윈폼 프로젝트에서는 버튼의 텍스트 출력은 다중으로 출력이 가능합니다.

그러나 .net compact framework을 이용한 PDA 프로그램에서는 버튼의 텍스트가 다중출력이 되지 않고 한줄로 출력이 됩니다.

그러다보니 텍스트 길이따라 짤리는 경우가 발생합니다.

아래의 소스는 coredll.dll API를 이용하여 버튼의 텍스트를 다중 출력해주는 코드이오니 업무에 참고하세요.


//WIN CE.NET/WINDOWS MOBILE 프로그램 개발 시 버튼의 텍스트를 한줄 이상으로 출력시 사용하는 API 및 예제

private const int BS_MULTILINE = 0x00002000;
private const int GWL_STYLE = -16;


[System.Runtime.InteropServices.DllImport("coredll.dll")]
private int GetWindowLong(IntPtr hWnd, int nIndex);


[System.Runtime.InteropServices.DllImport("coredll.dll")]
private int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);


public static void MakeButtonMultiline(System.Windows.Forms.Button b)
{
        IntPtr hwnd = b.Handle;

        int currentStyle = GetWindowLong(hwnd, GWL_STYLE);

        int newStyle = SetWindowLong(hwnd, GWL_STYLE, currentStyle | BS_MULTILINE);
}