青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

隨筆 - 25  文章 - 29  trackbacks - 0
<2006年7月>
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

常用鏈接

留言簿(4)

隨筆分類(22)

隨筆檔案(25)

文章分類(2)

文章檔案(2)

相冊

最新隨筆

搜索

  •  

積分與排名

  • 積分 - 57388
  • 排名 - 405

最新評論

閱讀排行榜

評論排行榜

The Problem

Windows objects are normally represented by HANDLEs. The MFC classes wrap Windows object handles with C++ objects. The handle wrapping functions of the MFC class library provide a way to find the C++ object that is wrapping the Windows object with a particular handle. There are times when a Windows object does not have a C++ wrapper object, however, and at these times a temporary object is created to act as the C++ wrapper.

mfc 映射的 windows object ---->c++ wrapper
以下使用 mfc 的函數(shù) 如:fromhandle, getdlgitem,都會返回temporary 和 pemanent? c++ wrapper object
?注意:
???? 零時的 對象 會被在空閑時(OnIdle()函數(shù))被刪除,不能存下在下次消息處理中 使用
The default OnIdle processing in CWinThread automatically calls DeleteTempMap for each class that supports temporary handle maps
////////////////////////////////////////////////////////////
The Windows objects that use handle maps are:

  • HWND (CWnd and CWnd-derived classes)
  • HDC (CDC and CDC-derived classes)
  • HMENU (CMenu)
  • HPEN (CGdiObject)
  • HBRUSH (CGdiObject)
  • HFONT (CGdiObject)
  • HBITMAP (CGdiObject)
  • HPALETTE (CGdiObject)
  • HRGN (CGdiObject)
  • HIMAGELIST (CImageList)
  • SOCKET (CSocket)

///////////////////////////////////////////////

Given a handle to any of these objects, you can find the MFC object that wraps the handle by calling the static member function FromHandle. For example, given an HWND called hWnd:

CWnd::FromHandle(hWnd)

will return a pointer to the CWnd that wraps the hWnd. If that hWnd does not have a specific wrapper object, then a temporary CWnd is created to wrap the hWnd. This makes it possible to get a valid C++ object from any handle.

Once you have a wrapper object, you can get to its handle through a public member variable. In the case of a CWnd, m_hWnd contains the HWND for that object.

Attaching Handles to MFC Objects

Given a newly created handle-wrapper object and a handle to a Windows object, you can associate the two by calling Attach. For example:

CWnd myWnd;
myWnd.Attach(hWnd);
////mywnd 析構時會調用 destroywindow ,連同 hwnd 一起銷毀




This makes an entry in the permanent map associating myWnd and hWnd.
Calling CWnd::FromHandle(hWnd) will now return a pointer to myWnd.
When myWnd is deleted, the destructor will automatically destroy the hWnd by calling the Windows DestroyWindow function. If this is not desired, the hWnd must be detached from myWnd before the myWnd object is destroyed (normally when leaving the scope at which myWnd was defined). The Detach member function does this.

myWnd.Detach();

More About Temporary Objects

Temporary objects are created whenever FromHandle is given a handle that does not already have a wrapper object. These temporary objects are detached from their handle and deleted by the DeleteTempMap functions. The default OnIdle processing in CWinThread automatically calls DeleteTempMap for each class that supports temporary handle maps. This means that you cannot assume a pointer to a temporary object will be valid past the point of exit from the function where the pointer was obtained, as the temporary object will be deleted during the Windows message-loop idle time.

很重要:
在多線程中傳遞 c++ wrapper object 是無效的(無論是 temporary 還是 permanent)
只能傳遞 windows handle, 換句話就是說, 線程 只能 訪問 自己創(chuàng)建的c++ wrapper object

Wrapper Objects and Multiple Threads

Both temporary and permanent objects are maintained on a per-thread basis. That is, one thread cannot access another threads C++ wrapper objects, regardless of whether it is temporary or permanent. As stated above, temporary objects are deleted when the thread which that temporary object belongs enters OnIdle.

To pass these objects from one thread to another, always send them as their native HANDLE type. Passing a C++ wrapper object from one thread to another will often result in unexpected results.

????

posted on 2006-06-30 11:33 黃大仙 閱讀(1754) 評論(1)  編輯 收藏 引用 所屬分類: c++

FeedBack:
# re: MFC中 windows object 和 C++ object 2006-07-08 00:49 flyingxu
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
      <noscript id="pjuwb"></noscript>
            <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
              <dd id="pjuwb"></dd>
              <abbr id="pjuwb"></abbr>
              欧美一级精品大片| 亚洲综合色在线| 久久亚洲精品欧美| 一区在线视频观看| 久久亚洲影音av资源网| 久久国产一区二区| 亚洲电影免费观看高清完整版在线 | 午夜亚洲性色福利视频| 亚洲九九精品| 国产中文一区二区| 一本色道久久99精品综合| 一区二区三区国产盗摄| 欧美日韩在线视频首页| 亚洲伊人伊色伊影伊综合网| 亚洲欧美激情四射在线日 | 一本色道久久综合亚洲精品高清| 欧美日韩国产色站一区二区三区| 亚洲色诱最新| 亚洲欧美日韩视频二区| 在线欧美电影| 亚洲肉体裸体xxxx137| 欧美视频第二页| 欧美在线视频免费观看| 噜噜爱69成人精品| 亚洲欧美国产精品专区久久| 久久综合九色欧美综合狠狠| 亚洲人在线视频| 米奇777在线欧美播放| 欧美1级日本1级| 午夜在线一区| 免费在线一区二区| 欧美一二三视频| 欧美成人精品一区二区| 亚洲欧美日韩成人| 蜜桃久久精品乱码一区二区| 亚洲图色在线| 久久综合久久综合这里只有精品 | 亚洲第一免费播放区| 亚洲免费观看视频| 一区二区三区我不卡| 一区二区三区精品视频| 在线精品福利| 亚洲欧美高清| 9人人澡人人爽人人精品| 欧美一区二区视频在线观看2020| 日韩视频久久| 久久综合九色99| 久久精品一区四区| 国产精品免费网站| 日韩午夜免费视频| 亚洲国产人成综合网站| 午夜日韩在线观看| 亚洲欧美自拍偷拍| 欧美日韩天天操| 亚洲国产成人一区| 亚洲大黄网站| 久久精品视频在线| 久久久91精品国产| 国产精品一区二区你懂得| 亚洲免费观看在线视频| 亚洲国产一区二区三区高清| 久久精品30| 久久久另类综合| 国产亚洲欧美另类中文| 亚洲欧美另类久久久精品2019| 一本一本久久a久久精品综合妖精| 麻豆久久婷婷| 欧美大片免费久久精品三p| 狠狠色伊人亚洲综合成人| 午夜精品久久99蜜桃的功能介绍| 亚洲欧美国产制服动漫| 国产精品美女久久| 亚洲综合色网站| 久久av免费一区| 国产亚洲欧美日韩精品| 欧美亚洲三级| 美女图片一区二区| 91久久国产综合久久蜜月精品 | 99精品欧美一区二区三区| 日韩视频在线观看| 欧美日韩亚洲一区三区 | 在线亚洲免费| 亚洲影院在线| 国产日韩综合一区二区性色av| 在线亚洲一区观看| 欧美一区二区黄色| 激情校园亚洲| 欧美精品 国产精品| 亚洲裸体视频| 欧美在线亚洲在线| 在线日韩欧美视频| 欧美日韩一区二区视频在线| 亚洲网站视频福利| 久久中文在线| 一区二区av在线| 国产精品日韩欧美综合 | 亚洲精品国产精品乱码不99| 亚洲午夜久久久| 国产模特精品视频久久久久| 久久深夜福利| 亚洲无毛电影| 欧美成人午夜激情在线| 亚洲图片欧美日产| 激情综合激情| 欧美日韩在线另类| 久久久久国产免费免费| 亚洲美女毛片| 美女日韩在线中文字幕| 亚洲午夜电影| 在线欧美影院| 国产精品久久久久久久午夜片| 久久久久久久一区二区| 99综合视频| 欧美激情一区在线| 欧美一区二区三区成人| 亚洲精品国产精品国自产观看浪潮 | 久久久久久久成人| 99视频精品免费观看| 美脚丝袜一区二区三区在线观看 | 欧美在线视频一区二区三区| 亚洲激情网站免费观看| 国产日韩欧美二区| 欧美日韩一二三四五区| 浪潮色综合久久天堂| 亚洲综合导航| 一本色道88久久加勒比精品| 欧美激情 亚洲a∨综合| 久久夜色精品亚洲噜噜国产mv| 中文一区二区在线观看| 亚洲精品乱码久久久久久黑人| 国产亚洲欧美日韩在线一区| 国产精品成人一区| 欧美激情在线狂野欧美精品| 久久午夜av| 久久精品国产91精品亚洲| 亚洲男人av电影| 亚洲天堂成人在线视频| 亚洲精品中文字幕有码专区| 亚洲国产成人av好男人在线观看| 久久偷窥视频| 久久夜色精品国产欧美乱| 久久精品国产一区二区三区免费看 | 欧美午夜激情在线| 欧美午夜不卡影院在线观看完整版免费| 开心色5月久久精品| 久久精品一本| 久久精品一区二区| 久久精品日韩欧美| 久久久久看片| 老司机免费视频一区二区| 久久久91精品| 鲁大师影院一区二区三区| 麻豆国产va免费精品高清在线| 久久久久国产精品一区三寸| 久久久亚洲精品一区二区三区| 久久人人爽人人爽爽久久| 久久久999精品| 免费成人黄色| 欧美日韩成人在线观看| 欧美少妇一区二区| 国产精品日韩欧美大师| 国产日本欧美一区二区| 黄色影院成人| 亚洲精品在线观| 亚洲午夜三级在线| 久久精品官网| 欧美va日韩va| 亚洲美女av网站| 亚洲欧美日韩国产综合| 久久久久成人精品| 欧美成人综合在线| 国产精品久久久| 国际精品欧美精品| 亚洲精品少妇网址| 亚洲一区二区三区在线观看视频| 欧美一区二区在线播放| 欧美1区免费| 中日韩视频在线观看| 欧美综合国产| 欧美日韩一区二区三区四区在线观看| 国产精品免费久久久久久| 1024成人| 亚洲欧美另类中文字幕| 欧美www视频在线观看| 日韩视频在线永久播放| 久久精品理论片| 欧美日韩综合一区| 在线观看久久av| 亚洲中字黄色| 亚洲成人在线视频播放 | 久久久www成人免费毛片麻豆| 欧美成人免费在线观看| 亚洲天堂第二页| 美女成人午夜| 国产日韩欧美综合在线| 一区二区三区久久精品| 免费欧美视频| 亚欧美中日韩视频| 欧美午夜电影一区| 亚洲精品偷拍|