메뉴 건너뛰기

OBG

Programming

MoA
조회 수 4718 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
http://lafirr.tistory.com/56

추가 : http://greenfishblog.tistory.com/29

콘솔 프로그램이면 모르겠지만

MFC 에서 Sleep() 을 걸면, (물론 거는 위치에 따라서 다르겠지만)

모든 메세지가 먹통이 되기 때문에

원하지 않는 결과를 초래할 수도 있습니다.

예를 들어서 10초 정지 후 메세지 출력 후 500ms 정지... 같은 경우

프로그램이 갑자기 (응답없음)으로 바뀌더니 메세지가 출력되는것도 보이지 않고 바로

ㄱㄱㄱ 해버리는... ㄷㄷㄷ

따라서 MFC 에서는 Sleep() 을 가급적 (..제발) 쓰지 말고

다음과 같은 함수를 추가해서 사용하는 것이 바람직하다고 합니다.

void CNumberGameDlg::Wait(DWORD dwMillisecond)
{
 MSG msg;
 DWORD dwStart;
 dwStart = GetTickCount();

 while(GetTickCount() - dwStart < dwMillisecond)
 {
  while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
  {
   TranslateMessage(&msg);
   DispatchMessage(&msg);
  }
 }
}


?

  1. Programming 게시판 관련

    Date2014.11.01 CategoryTool/etc ByMoA Views1709
    read more
  2. C, C++ 에서의 불(bool, boolean) 타입의 동작

    Date2013.07.28 CategoryC/C++ ByMoA Views311
    Read More
  3. Sleep() 함수 대신 프로그램 딜레이 시키기 (Wait)

    Date2013.07.28 CategoryAPI/MFC ByMoA Views4718
    Read More
  4. MFC기반의 CSocket 사용 방법과 예제

    Date2013.07.28 CategoryAPI/MFC ByMoA Views1265
    Read More
  5. ofstream ifstream

    Date2013.07.28 CategoryC/C++ ByMoA Views519
    Read More
  6. VC++6.0 에서 VC++ 2005로 변환할 경우 형변환 경고 대응방법

    Date2013.07.28 CategoryAPI/MFC ByMoA Views626
    Read More
  7. 비베의 MSCOMM.OCX VC++에서 불러쓰기

    Date2013.07.28 CategoryAPI/MFC ByMoA Views748
    Read More
  8. VC의 소스 파일, sln파일 관리

    Date2013.07.28 CategoryAPI/MFC ByMoA Views334
    Read More
  9. 비주얼 스튜디오 2005 단축키

    Date2013.07.28 CategoryAPI/MFC ByMoA Views355
    Read More
  10. 스레드 강좌 + CreateThread() 와 _beginthreadex() 함수의 차이

    Date2013.07.28 CategoryAPI/MFC ByMoA Views416
    Read More
  11. 스레드(CreateThread), EVENT 동기화

    Date2013.07.28 CategoryAPI/MFC ByMoA Views614
    Read More
  12. WaitForSingleObject와의 삽질..

    Date2013.07.28 CategoryAPI/MFC ByMoA Views429
    Read More
  13. 작업자 스레드(Worker Thread) 와 사용자 인터페이스 스레드(User Interface Thread)

    Date2013.07.28 CategoryAPI/MFC ByMoA Views447
    Read More
  14. Thread와 SendMessage를 통해 DeadLock을 만드는 방법

    Date2013.07.28 CategoryAPI/MFC ByMoA Views2625
    Read More
  15. CreateThread, ExitThread, GetExitCodeThread ...

    Date2013.07.28 CategoryAPI/MFC ByMoA Views373
    Read More
  16. char*, String, CString

    Date2013.07.28 CategoryAPI/MFC ByMoA Views367
    Read More
  17. 파일 입출력

    Date2013.07.28 CategoryC/C++ ByMoA Views487
    Read More
  18. 다른 스레드에서 메인다이얼로그 포인터 받아오기 AfxGetMainWnd()

    Date2013.07.28 CategoryAPI/MFC ByMoA Views1616
    Read More
  19. Data Conversions

    Date2013.07.28 CategoryC/C++ ByMoA Views613
    Read More
  20. Direct3D 9 compile

    Date2013.07.28 CategoryGraphic ByMoA Views267
    Read More
  21. MFC 클래스 멤버함수 설명서

    Date2013.07.28 CategoryAPI/MFC ByMoA Views1513
    Read More
Board Pagination Prev 1 ... 2 3 4 5 6 7 8 9 10 ... 15 Next
/ 15
위로