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

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

常用鏈接

留言簿(4)

隨筆分類(22)

隨筆檔案(25)

文章分類(2)

文章檔案(2)

相冊

最新隨筆

搜索

  •  

積分與排名

  • 積分 - 57331
  • 排名 - 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,都會(huì)返回temporary 和 pemanent? c++ wrapper object
?注意:
???? 零時(shí)的 對象 會(huì)被在空閑時(shí)(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 析構(gòu)時(shí)會(huì)調(diào)用 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 黃大仙 閱讀(1753) 評論(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>
              免费视频最近日韩| 久久久久久一区| 国产精品高精视频免费| 欧美精品91| 国产精品www.| 国产精品毛片a∨一区二区三区|国| 欧美日韩国产成人高清视频| 国产精品高潮呻吟久久av黑人| 国产免费亚洲高清| 在线观看亚洲视频| 99视频日韩| 欧美亚洲综合久久| 欧美18av| 这里是久久伊人| 久久久久国产精品人| 欧美连裤袜在线视频| 国产精品中文字幕欧美| 亚洲国产精品一区制服丝袜 | 久久国产精品色婷婷| 免费观看在线综合色| 亚洲精品一区二区三区99| 亚洲欧美在线x视频| 免费观看成人网| 国产精自产拍久久久久久蜜| 亚洲精品中文字幕在线| 久久九九国产精品怡红院| 亚洲国产精品久久久久秋霞影院| 夜久久久久久| 久久亚洲综合| 国产欧美一区二区视频| 国内精品久久久久久久97牛牛| 在线成人av| 亚洲精品免费一区二区三区| 亚洲欧美精品一区| 亚洲国产一区二区三区a毛片 | 久久精品人人做人人综合| 亚洲韩日在线| 久久久久久电影| 国产精品亚洲成人| 一本色道婷婷久久欧美| 欧美福利一区二区三区| 欧美一区二区三区喷汁尤物| 欧美三级资源在线| 99re6热只有精品免费观看| 久久亚洲图片| 久久av老司机精品网站导航| 国产精品麻豆成人av电影艾秋| 日韩视频在线免费| 免费在线观看成人av| 先锋影院在线亚洲| 国产精品日韩电影| 欧美亚洲视频一区二区| 在线亚洲电影| 国产精品欧美日韩久久| 亚洲欧美在线免费观看| 亚洲一级二级| 国产精品乱码一区二区三区| 亚洲视频在线看| 99天天综合性| 国产精品久久久久久超碰 | 在线免费观看视频一区| 久久精品二区亚洲w码| 午夜免费在线观看精品视频| 国产日韩av高清| 久久精品72免费观看| 欧美一区二区三区视频在线| 国产真实久久| 欧美高清在线视频观看不卡| 欧美v亚洲v综合ⅴ国产v| 亚洲精品视频在线| 一区二区三区高清不卡| 国产精品入口尤物| 久久麻豆一区二区| 欧美成人官网二区| 亚洲一级片在线观看| 亚洲欧美日韩成人高清在线一区| 国产麻豆午夜三级精品| 老司机久久99久久精品播放免费| 理论片一区二区在线| aa级大片欧美| 午夜免费在线观看精品视频| 黄色日韩网站| 亚洲激情国产精品| 国产精品美女午夜av| 两个人的视频www国产精品| 欧美成人亚洲| 欧美一区二区成人6969| 久久久久久九九九九| 欧美+日本+国产+在线a∨观看| 免费一级欧美片在线观看| 亚洲日本中文字幕| 一区电影在线观看| 激情六月婷婷久久| 亚洲激情自拍| 国产亚洲一区二区三区在线播放| 欧美激情1区2区| 国产精品国产三级国产aⅴ9色| 久久久久久电影| 欧美精品一区二区久久婷婷| 欧美一区二区三区四区视频| 噜噜爱69成人精品| 亚洲欧美综合v| 美女主播精品视频一二三四| 西瓜成人精品人成网站| 欧美国产精品劲爆| 久久美女性网| 国产精品都在这里| 亚洲国产一区二区精品专区| 国产亚洲一二三区| 亚洲视频在线看| 日韩视频免费| 久久综合久色欧美综合狠狠| 午夜视频精品| 欧美涩涩网站| 亚洲人成网在线播放| 亚洲高清成人| 久久久精彩视频| 欧美专区在线观看| 欧美日韩在线播放三区| 欧美激情一区二区三区全黄| 国产欧美精品一区| 亚洲性感激情| 亚洲一区制服诱惑| 欧美日韩视频在线一区二区 | 国产精品户外野外| 亚洲国产日韩在线一区模特| 在线播放国产一区中文字幕剧情欧美| 亚洲影院在线观看| 亚洲一区视频在线| 欧美日韩一区国产| 99精品免费网| 亚洲一区二区三区欧美 | 欧美三级乱人伦电影| 亚洲激情欧美| 日韩一区二区精品葵司在线| 欧美sm视频| 亚洲国产精品久久久久秋霞蜜臀| 在线成人小视频| 久久一二三四| 欧美大片国产精品| 亚洲精品欧洲| 欧美国产日产韩国视频| 亚洲精品一区二区三| 亚洲天堂av综合网| 国产免费观看久久黄| 欧美淫片网站| 免费在线看成人av| 欧美91精品| 欧美国产精品v| 日韩视频在线免费观看| 亚洲一区二区欧美| 国产精品久久一区主播| 亚洲欧美大片| 久久免费视频网站| 亚洲欧洲日产国码二区| 欧美日韩精品欧美日韩精品| 日韩亚洲欧美一区| 久久国产日韩| 在线观看成人av| 欧美精品成人一区二区在线观看| 亚洲麻豆av| 久久久国产精品一区二区中文| **欧美日韩vr在线| 欧美日韩国产亚洲一区| 欧美一区二区福利在线| 亚洲国产高清aⅴ视频| 亚洲制服少妇| 亚洲二区视频在线| 国产精品乱子乱xxxx| 久久免费黄色| 在线视频精品一区| 欧美mv日韩mv国产网站| 中日韩视频在线观看| 狠狠色狠狠色综合日日tαg| 欧美精品一区二区视频 | 欧美 亚欧 日韩视频在线| 亚洲天堂av图片| 亚洲大胆美女视频| 国产精品免费一区二区三区在线观看 | 久久久www成人免费毛片麻豆| 亚洲人体影院| 国产一区二区三区自拍| 欧美日韩另类字幕中文| 久久亚洲综合网| 欧美一区二区三区的| 一区二区久久| 亚洲黑丝在线| 欧美成年人网站| 久久成人免费电影| 亚洲午夜精品久久| 亚洲日本电影在线| 激情久久综艺| 国产一区三区三区| 国产伦精品一区| 欧美视频国产精品| 欧美激情第三页| 欧美成人三级在线| 美女诱惑黄网站一区| 久久久久久久一区二区三区| 亚洲欧美中日韩|