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

隨筆 - 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>
              久久亚洲精品一区二区| 国内精品久久久久久影视8| 久久疯狂做爰流白浆xx| 欧美精品尤物在线| 久久亚洲综合| 国产精品久久福利| 亚洲精品欧洲精品| 亚洲福利视频三区| 久久午夜羞羞影院免费观看| 久久成人国产| 国产美女一区| 亚洲网站在线播放| 亚洲尤物视频在线| 欧美日韩在线播放一区| 亚洲精品一区二区三区四区高清| 亚洲国产视频一区二区| 久久久久久精| 免费精品99久久国产综合精品| 国产视频精品网| 亚洲欧美日韩区| 久久精品国产999大香线蕉| 国产精品都在这里| 亚洲性视频网站| 午夜亚洲一区| 国产精品日韩欧美一区| 亚洲午夜电影在线观看| 亚洲欧美中文日韩v在线观看| 欧美另类一区二区三区| av不卡在线| 欧美一级理论性理论a| 国产欧美va欧美va香蕉在| 亚洲一区免费| 久久亚洲综合网| 在线看一区二区| 欧美激情视频给我| 99精品久久| 欧美一区二区三区在线| 狠狠操狠狠色综合网| 免费在线看一区| 99视频热这里只有精品免费| 亚洲欧美一区二区三区久久| 国产欧美一区二区白浆黑人| 久久国产精品久久w女人spa| 欧美sm极限捆绑bd| 在线视频你懂得一区二区三区| 国产精品白丝黑袜喷水久久久| 午夜久久久久久| 免费不卡在线视频| 中日韩美女免费视频网址在线观看 | 欧美中文在线视频| 亚洲一级黄色片| 国产欧美一区二区精品忘忧草| 久久国产精品一区二区三区四区| 欧美91精品| 亚洲自拍偷拍一区| 有坂深雪在线一区| 欧美日韩在线不卡一区| 久久精品国产一区二区三区| 亚洲破处大片| 久久精品国产成人| 99视频热这里只有精品免费| 国产婷婷成人久久av免费高清| 欧美aⅴ一区二区三区视频| 中日韩午夜理伦电影免费| 久久久av毛片精品| 日韩视频中文字幕| 国产一区美女| 欧美天天影院| 男女视频一区二区| 亚洲自拍电影| 亚洲日本成人女熟在线观看| 欧美一区二区视频网站| 亚洲精品美女91| 激情视频一区二区| 国产精品久久一级| 欧美日本乱大交xxxxx| 久久久久久日产精品| 亚洲综合国产激情另类一区| 亚洲高清一区二| 久久九九免费视频| 午夜精品影院| 亚洲天堂网在线观看| 亚洲高清不卡在线观看| 国产视频综合在线| 国产精品乱子久久久久| 欧美欧美全黄| 欧美精品电影在线| 久久一区视频| 久久偷看各类wc女厕嘘嘘偷窃| 亚洲一区二区黄色| 99热免费精品| 日韩午夜精品视频| 亚洲激情成人网| 欧美成人第一页| 老鸭窝91久久精品色噜噜导演| 欧美在线一级视频| 欧美一区二区黄| 亚洲欧美三级在线| 亚洲欧美日韩国产一区二区三区| 亚洲视频在线观看| 99精品欧美一区二区三区| 亚洲激情午夜| 亚洲国产二区| 亚洲黄色成人久久久| 精品动漫av| 亚洲国产视频直播| 亚洲精品老司机| 一区二区高清在线| 国产精品jvid在线观看蜜臀 | 日韩一区二区电影网| 亚洲高清影视| 亚洲欧洲三级电影| 亚洲精品精选| 亚洲色在线视频| 亚洲永久精品大片| 亚洲女同精品视频| 久久国产精品亚洲va麻豆| 久久成人在线| 免费不卡在线观看| 亚洲二区精品| 亚洲精品国产精品乱码不99| 亚洲免费av电影| 亚洲性感激情| 久久久噜噜噜久噜久久| 母乳一区在线观看| 欧美三级欧美一级| 国产美女扒开尿口久久久| 国内精品一区二区| 亚洲人成人77777线观看| 亚洲精品日日夜夜| 亚洲欧美日韩区| 美女91精品| 亚洲欧洲精品成人久久奇米网| 欧美日韩精品一区二区| 欧美日韩国产二区| 国产精品嫩草影院av蜜臀| 国内精品亚洲| 99re6这里只有精品| 欧美亚洲免费| 欧美激情在线观看| 亚洲视频999| 久久先锋影音| 国产精品人人做人人爽| 狠狠色狠狠色综合系列| 日韩亚洲在线| 久久亚洲不卡| 一本色道久久综合亚洲精品高清 | 日韩亚洲欧美中文三级| 欧美一区二区视频观看视频| 免费观看久久久4p| 亚洲视频二区| 欧美成人精品影院| 国产一区 二区 三区一级| 亚洲美女淫视频| 久热精品视频在线免费观看| 一区二区三区日韩精品视频| 一本色道久久加勒比88综合| 欧美一区二区精品久久911| 久久视频这里只有精品| 亚洲精品麻豆| 久久夜色精品国产| 国产情人综合久久777777| 夜夜夜精品看看| 免费观看成人| 香蕉成人伊视频在线观看| 欧美日韩免费观看一区三区| 亚洲二区视频| 久热re这里精品视频在线6| 亚洲视频每日更新| 欧美噜噜久久久xxx| 亚洲国产婷婷| 欧美成人tv| 久久久午夜电影| 国产自产女人91一区在线观看| 亚洲综合久久久久| 99精品欧美一区| 欧美—级在线免费片| 亚洲第一天堂av| 另类成人小视频在线| 久久www成人_看片免费不卡| 国产精品视频精品视频| 亚洲欧美精品suv| 亚洲视频在线观看视频| 欧美日韩国产在线| 日韩午夜激情电影| 欧美二区在线| 欧美成人中文| 久久精品成人一区二区三区 | 欧美三级网页| 日韩亚洲一区在线播放| 亚洲国产婷婷香蕉久久久久久99 | 国产精品嫩草影院一区二区| 亚洲伊人久久综合| 一区二区欧美日韩| 欧美亚洲成人精品| 亚洲图片欧洲图片av| 亚洲一区bb| 国产精品中文在线| 久久国内精品自在自线400部| 午夜欧美不卡精品aaaaa|