AfxLockTempMaps和AfxUnlockTempMaps

來源:互聯網
上載者:User
CWnd::FromHandle靜態函數返回指定控制代碼的視窗的指標,但該視窗指標所指向的CWnd類對象是MFC臨時建立的對象,該對象與視窗 Attach。這種C++類對象與Windows視窗對象之間的映射關係儲存在一個映射表中,且該映射表也是臨時性的。由於該映射表是臨時性的,隨時可能 被Windows刪除,所以FromHandle的注釋中特別指出:

“The pointer may be temporary and should not be stored for later use.”(該指標是臨時性的,不能被儲存作他用。)

為了防止Windows自動刪除臨時映射表(因為我們需要FromHandle返回的指標),調用AfxLockTempMaps將臨時映射表鎖定,而在使用結束後調用AfxUnlockTempMaps解鎖,允許Windows在OnIdle中刪除此類臨時對象。

 

參考http://blog.csdn.net/mood8125/archive/2006/08/24/1113341.aspx

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.