.net compact framework을 이용한 PDA 프로그램 개발에서 메시지 박스를 특정한 시간이 지나면 자동으로 종료되는 샘플 코드입니다.
public class AutoClosingMessageBox
{
System.Threading.Timer _timeoutTimer;
string _caption;
AutoClosingMessageBox(string text, string caption, int timeout)
{
_caption = caption;
_timeoutTimer = new System.Threading.Timer(OnTimerElapsed, null, timeout, System.Threading.Timeout.Infinite);
System.Windows.Forms.MessageBox.Show(text, caption);
}
public static void Show(string text, string caption, int timeout)
{
new AutoClosingMessageBox(text, caption, timeout);
}
void onTimerElapsed(object state)
{
IntPtr mbWnd = FindWindow(null, _caption);
if (mbWnd != IntPtr.Zero)
SendMessage(mbWnd, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
_timeoutTimer.Dispose();
}
const int WM_CLOSE = 0x0010;
[System.Runtime.InteropServices.DllImport("coredll.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[System.Runtime.InteropServices.DllImport("coredll.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
}
private void button_Click(object sender, EventArgs e)
{
AutoClosingMessageBox.Show("정상처리되었습니다.", "성공", 1000);//1초뒤에 자동 종료
}
'C#' 카테고리의 다른 글
[C#]바코드 생성 프로그램(Barcode Generator) (0) | 2016.01.18 |
---|---|
PDA 화면 캡쳐 유틸프로그램 (0) | 2016.01.18 |
[C#/PDA]Button의 텍스트 문자열 다중 출력 예제 (0) | 2016.01.18 |
[C#]동호회 회원관리 프로그램 소개 (0) | 2016.01.15 |
[C#/PDA]PDA에서 실행 파일 경로 얻어오기 (0) | 2016.01.15 |