문제

작업 표시 줄에 나타나는 MessageBox.Show를 호출하는 방법이 있습니까?

사용자 정의 양식을 작성하고 물론 표시하는 것이 가장 좋을 것입니다. 그러나 게으른 프로그래머이기 때문에 기본 오류를 다시 만들고 구식 MessageBox.show 호출을 통해 얻는 알림 아이콘을 피하고 싶습니다.

도움이 되었습니까?

해결책

사용해보십시오 MessageBoxOptions 열거 :

MessageBox.Show("Test", "Test", MessageBoxButtons.OK, MessageBoxIcon.Information,
    MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);

메모: 이것의 사용에 대한 다중 스레딩 부작용이 있습니다. 기사를 참조하십시오. 데몬에서 사용자 인터페이스를 표시하는 방법.

다른 팁

IWIN32window를 구현하고 핸들을 intptr.zero (데스크탑)로 반환 한 다음 해당 창으로 메시지 상자를 부모로 표시합니다.

private static Image GetImage(MessageBoxIcon icon)
{
    switch (icon)
    {
        case MessageBoxIcon.Error:
            return System.Drawing.SystemIcons.Error.ToBitmap();
        case MessageBoxIcon.Exclamation:
            return System.Drawing.SystemIcons.Exclamation.ToBitmap();
        case MessageBoxIcon.Information:
            return System.Drawing.SystemIcons.Information.ToBitmap();
        case MessageBoxIcon.Question:
            return System.Drawing.SystemIcons.Question.ToBitmap();
    }
    return null;
} 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top