ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • CBitmap::FromHandle() 사용하기
    개발/지름 2008. 1. 17. 12:47
    반응형

    MSDN의 설명이다.

    Remarks

    If a CBitmap object is not already attached to the handle, a temporary CBitmap object is created and attached. This temporary CBitmap object is valid only until the next time the application has idle time in its event loop, at which time all temporary graphic objects are deleted. Another way of saying this is that the temporary object is only valid during the processing of one window message.

    WinCE프로그램을 코딩할 때, 외부 비트맵을 로드하기 위해 SHLoadDIBitmap 함수를 사용했다.
    이 함수는 핸들을 리턴하기 때문에, 핸들에서 CBitmap을 받기 위해 사용했는데....

    이 함수를 사용하기 위해 주의할 점이 있다.
    만약 OnPaint에서 CBitmap::FromHandle() 함수를 사용하지 않고, 한번만 로드했을 시에는, 다른창(예를 들어 팝업창)이 비트맵을 가렸다가 다시 비트맵이 떠 있는 부모윈도우로 돌아왔을 때, 비트맵을 Delete한다. 아마도 WinCE에서 리소스를 아끼기 위해서인듯도 하고....설명도 돼 있는걸 보니 버그는 아닌 듯 하다.

    이것때문에 한 1시간은 삽질한 것 같다. -_-

    반응형

    댓글

Designed by Tistory.