• <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>
            面對(duì)現(xiàn)實(shí),超越自己
            逆水行舟,不進(jìn)則退
            posts - 269,comments - 32,trackbacks - 0

            以上是源碼及演示程序下載地址

            (文章原地址 http://www.codeproject.com/Articles/24969/An-MFC-picture-control-to-dynamically-show-picture

            Introduction 介紹

            這篇文章描述的是一個(gè)可以用于在對(duì)話(huà)框上顯示各種主流類(lèi)型圖片 (如 BMP, GIF, JPEG...) MFC控件

            Background 背景

            我花了一些時(shí)間去搜索可以用于顯示圖片的MFC控件, 但卻沒(méi)有發(fā)現(xiàn)合適的。 所以我決定自己做一個(gè)輕量級(jí),靈活度高的圖片控件(Picture control)去顯示各種類(lèi)型的圖片。

            Using the code 如何使用

            這個(gè)控件內(nèi)部使用的是GDI+庫(kù),所以請(qǐng)?jiān)谑褂脮r(shí)把GdiPlus.lib加入到你的工程中(include libraries)。

            使用這個(gè)控件時(shí),先用VC++對(duì)話(huà)框設(shè)計(jì)器創(chuàng)建一個(gè)靜態(tài)文字控件(static text control 。之后用MFC向?qū)檫@個(gè)控件分配一個(gè)控件變量,類(lèi)型定義為CPictureCtrl。

            現(xiàn)在你可以用你的控件裝載顯示圖片了,你只需要在這幾個(gè)CPictureCtrl::LoadFrom... 函數(shù), 選擇合適你需要的的進(jìn)行調(diào)用。裝載后控件會(huì)自動(dòng)更新并顯示圖片。

            要清除掉控件中顯示的圖片,調(diào)用CPictureCtrl::FreeImage即可。

            你的圖片會(huì)被自動(dòng)調(diào)整到控件的大小,這可能會(huì)改變圖片原先的長(zhǎng)寬比例。

             Collapse | Copy Code
            class CPictureCtrl :     
            public CStatic
            {
            public:
               //Constructor
               CPictureCtrl(void);
               //Destructor
               ~CPictureCtrl(void);

            public:
               //Loads an image from a file
               BOOL LoadFromFile(CString &szFilePath);
               //Loads an image from an IStream interface
               BOOL LoadFromStream(IStream* piStream);
               //Loads an image from a byte stream;
               BOOL LoadFromStream(BYTE* pData, size_t nSize);
               //Loads an image from a Resource
               // BOOL LoadFromResource(HMODULE hModule, LPCTSTR lpName, LPCTSTR lpType);
               //Overload - Single load function
               BOOL Load(CString &szFilePath);
               BOOL Load(IStream* piStream);
               BOOL Load(BYTE* pData, size_t nSize);
               // BOOL Load(HMODULE hModule, LPCTSTR lpName, LPCTSTR lpType);
               //Frees the image data
               void FreeData();

            protected:
               virtual void PreSubclassWindow();
               //Draws the Control
               virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
               virtual BOOL OnEraseBkgnd(CDC* pDC);

            private:
               //Internal image stream buffer
               IStream* m_pStream;
               //Control flag if a pic is loaded
               BOOL m_bIsPicLoaded;
               //GDI Plus Token
               ULONG_PTR m_gdiplusToken; };

            Points of interest

            這個(gè)控件是基于 CStatic control 設(shè)計(jì)的(基類(lèi)使用的是CStatic)。所以你可以使用CStatic control的各種功能,但它并不會(huì)顯示任何文字。對(duì)GDI+庫(kù)的使用使其可以支持各種主流類(lèi)型的圖片。

            History 歷史

            • 1.0 - Initial release.
            • 1.1 - A bug when drawing the control without a loaded image was corrected.
            • 1.2 - A bug when drawing the control was corrected.

              Loading an image from a resource is disabled due to problems recognizing it correctly as an image.

            License

            This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

            About the Author

            TEiseler

            Tester / Quality Assurance

            Germany Germany

            Member
             

            本文轉(zhuǎn)自:http://blog.csdn.net/cashey1991/article/details/7516996
            posted on 2013-07-22 18:09 王海光 閱讀(2203) 評(píng)論(0)  編輯 收藏 引用 所屬分類(lèi): MFC
            伊人久久大香线蕉精品| 国产精品无码久久四虎| 久久婷婷五月综合国产尤物app| 久久久午夜精品| 一级做a爰片久久毛片16| 国产视频久久| 伊人久久大香线蕉综合网站| 久久国产精品99精品国产987| 综合久久给合久久狠狠狠97色| 亚洲国产精品无码久久久蜜芽| 综合久久一区二区三区| 丰满少妇人妻久久久久久| 一本久久综合亚洲鲁鲁五月天| 热re99久久精品国99热| 久久综合香蕉国产蜜臀AV| 欧美伊香蕉久久综合类网站| 国产精品久久久久久久久免费| 日本久久久久亚洲中字幕| 26uuu久久五月天| 久久精品欧美日韩精品| 亚洲国产美女精品久久久久∴| 久久久中文字幕| 久久久久99精品成人片欧美 | 国产精品成人精品久久久| 久久久久波多野结衣高潮| 久久精品视屏| 四虎影视久久久免费| 亚洲精品国产自在久久| 国产精品久久久久乳精品爆| 久久精品www| 亚洲国产精品热久久| 99久久精品影院老鸭窝| 久久人人爽人人爽人人AV东京热| 国产成人综合久久精品红| 亚洲人成精品久久久久| 无码人妻精品一区二区三区久久 | 久久夜色撩人精品国产| 国产成人综合久久精品红| 精品久久久久久国产牛牛app| 亚洲?V乱码久久精品蜜桃 | 三级片免费观看久久|