亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ch15.htm

?? 24小時學會vc++
?? HTM
?? 第 1 頁 / 共 3 頁
字號:
<TT>    pPal-&gt;palNumEntries = cPaletteEntries;</TT><TT>    // Roll through the color table, and add each color to</TT><TT>    // the logical palette.</TT><TT>    for( int ndx = 0; ndx &lt; cPaletteEntries; ndx++ )</TT><TT>    {</TT><TT>        pPal-&gt;palPalEntry[ndx].peRed   = pColorTab[ndx].rgbRed;</TT><TT>        pPal-&gt;palPalEntry[ndx].peGreen = pColorTab[ndx].rgbGreen;</TT><TT>        pPal-&gt;palPalEntry[ndx].peBlue  = pColorTab[ndx].rgbBlue;</TT><TT>        pPal-&gt;palPalEntry[ndx].peFlags = NULL;</TT><TT>    }</TT><TT>    VERIFY( CreatePalette( pPal ) );</TT><TT>    delete [] (BYTE*)pPal;</TT><TT>}</TT></FONT></PRE><H3><FONT COLOR="#000077"><TT><B>CDibDoc</B></TT><B> Class Changes</B></FONT></H3><P>In the Dib example, the <TT>CDibDoc</TT> class will be responsible for the bitmapobjects and will have two new member functions:<UL>	<LI><TT>GetBitmap</TT> will return a pointer to a <TT>CDIBitmap</TT> object.	<LI><TT>GetPalette</TT> will return a pointer to a <TT>CBmpPalette</TT> object.</UL><P>The <TT>CDibDoc</TT> class will contain a <TT>CDIBitmap</TT> object and a pointerto a <TT>CBmpPalette</TT> object. The <TT>CDibDoc</TT> class header is shown in Listing15.6. Add the source code in Listing 15.6 to the <TT>DibDoc.h</TT> source file, justafter the <TT>//Operations</TT> comments in the <TT>CDibDoc</TT> class declaration.<H4><FONT COLOR="#000077">TYPE: Listing 15.6. Changes to CDibDoc class declaration.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>// Operations</TT><TT>public:</TT><TT>    CDIBitmap* GetBitmap();</TT><TT>    CPalette*  GetPalette();</TT><TT>protected:</TT><TT>   CDIBitmap    m_dib;</TT><TT>   CBmpPalette* m_pPal;</TT></FONT></PRE><P>Add the following two <TT>#include</TT> directives just before the <TT>CDibDoc</TT>class declaration:</P><PRE><FONT COLOR="#0066FF"><TT>#include &quot;dib256.h&quot;</TT><TT>#include &quot;dibpal.h&quot;</TT></FONT></PRE><P>The <TT>CDIBitmap</TT> object will be loaded during serialization. After it hasbeen loaded, the <TT>CBmpPalette</TT> object will be created dynamically. <TT>m_pPal</TT>,the pointer to <TT>CBmpPalette</TT>, will be initialized in the constructor and deletedin the destructor. The changes for the constructor, destructor, <TT>OnNewDocument</TT>,and <TT>Serialize</TT> member functions for the <TT>CDibDoc</TT> class are shownin Listing 15.7.<H4><FONT COLOR="#000077">TYPE: Listing 15.7. Changes to CDibDoc member functions.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>CDibDoc::CDibDoc()</TT><TT>{</TT><TT>    m_pPal = 0;</TT><TT>}</TT><TT>CDibDoc::&quot;CDibDoc()</TT><TT>{</TT><TT>    delete m_pPal;</TT><TT>}</TT><TT>BOOL CDibDoc::OnNewDocument()</TT><TT>{</TT><TT>    if (!CDocument::OnNewDocument())</TT><TT>        return FALSE;</TT><TT>    delete m_pPal;</TT><TT>    m_pPal = 0;</TT><TT>    return TRUE;</TT><TT>}</TT><TT>void CDibDoc::Serialize(CArchive&amp; ar)</TT><TT>{</TT><TT>    if (ar.IsStoring())</TT><TT>    {</TT><TT>        TRACE( TEXT(&quot;Storing a bitmap is not supported&quot;) );</TT><TT>        ASSERT(FALSE);</TT><TT>    }</TT><TT>    else</TT><TT>    {</TT><TT>        CFile* pFile = ar.GetFile();</TT><TT>        ASSERT( pFile );</TT><TT>        ar.Flush();</TT><TT>        BOOL fLoaded = m_dib.Load( pFile );</TT><TT>        if( fLoaded != FALSE )</TT><TT>        {</TT><TT>            delete m_pPal;</TT><TT>            m_pPal = new CBmpPalette( &amp;m_dib );</TT><TT>            UpdateAllViews( NULL );</TT><TT>        }</TT><TT>        else</TT><TT>            AfxMessageBox( TEXT(&quot;Error Loading Bitmap&quot;) );</TT><TT>    }</TT><TT>}</TT></FONT></PRE><P>As discussed earlier, the <TT>CDibDoc</TT> class has two new member functionsto return pointers to the bitmap and palette data members. Add the source code providedin Listing 15.8 to the <TT>dibdoc.cpp</TT> file.<H4><FONT COLOR="#000077">TYPE: Listing 15.8. New CDibDoc member functions to returnthe bitmap and palette pointers.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>CDIBitmap* CDibDoc::GetBitmap()</TT><TT>{</TT><TT>    return &amp;m_dib;</TT><TT>}</TT><TT>CPalette* CDibDoc::GetPalette()</TT><TT>{</TT><TT>    return m_pPal;</TT><TT>}</TT></FONT></PRE><H3><FONT COLOR="#000077"><B>Main Frame Class Changes</B></FONT></H3><P>When the Dib application receives a palette message, Windows sends the messageto the application, where it will be routed to the <TT>CMainFrame</TT> class. Becausethe <TT>CMainFrame</TT> class has no knowledge about how the bitmap or palette isorganized, it must determine the active view and send it the message.</P><P>Using ClassWizard, add message-handling functions for <TT>WM_PALETTECHANGED</TT>and <TT>WM_QUERYNEWPALETTE</TT>. Edit the functions using the source code providedin Listing 15.9.<H4><FONT COLOR="#000077">TYPE: Listing 15.9. The new CMainFrame message-handlingfunctions.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>void CMainFrame::OnPaletteChanged(CWnd* pFocusWnd)</TT><TT>{</TT><TT>    CView* pView = GetActiveView();</TT><TT>    if( pView )</TT><TT>    {</TT><TT>        HWND hWndFocus = pView-&gt;GetSafeHwnd();</TT><TT>        pView-&gt;SendMessage( WM_PALETTECHANGED,</TT><TT>                            (WPARAM)hWndFocus,</TT><TT>                            (LPARAM)0 );</TT><TT>    }</TT><TT>}</TT><TT>BOOL CMainFrame::OnQueryNewPalette()</TT><TT>{</TT><TT>    CView* pView = GetActiveView();</TT><TT>    if( pView )</TT><TT>    {</TT><TT>        HWND hWndFocus = pView-&gt;GetSafeHwnd();</TT><TT>        pView-&gt;SendMessage( WM_QUERYNEWPALETTE,</TT><TT>                            (WPARAM)hWndFocus,</TT><TT>                            (LPARAM)0 );</TT><TT>    }</TT><TT>    return TRUE;</TT><TT>}</TT></FONT></PRE><H3><FONT COLOR="#000077"><TT><B>CDibView</B></TT><B> Class Changes</B></FONT></H3><P>The <TT>CDibView</TT> class has two main functions: drawing the 256-color bitmapand responding to palette messages. The <TT>CDibView::OnDraw</TT> function must bemodified to draw the bitmap, as shown in Listing 15.10.<H4><FONT COLOR="#000077">TYPE: Listing 15.10. A new version of CDibView::OnDraw.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>void CDibView::OnDraw(CDC* pDC)</TT><TT>{</TT><TT>    CDibDoc* pDoc = GetDocument();</TT><TT>    ASSERT_VALID(pDoc);</TT><TT>    CPalette* pPal = pDoc-&gt;GetPalette();</TT><TT>    CPalette* pOldPal = pDC-&gt;SelectPalette( pPal, FALSE );</TT><TT>    pDC-&gt;RealizePalette();</TT><TT>    CDIBitmap* pBmp = pDoc-&gt;GetBitmap();</TT><TT>    pBmp-&gt;DrawDIB( pDC, 0, 0 );</TT><TT>    pDC-&gt;SelectPalette( pOldPal, FALSE );</TT><TT>}</TT></FONT></PRE><P><TT>OnDraw</TT> fetches pointers to the bitmap and palette from <TT>CDibDoc</TT>,using the new member functions added to the document class earlier. The palette isselected and realized, and then the bitmap is drawn. After drawing the bitmap, theprevious palette is selected back into the DC.</P><P>The <TT>CMainFrame</TT> class forwards <TT>WM_PALETTECHANGED</TT> and <TT>WM_QUERYNEWPALETTE</TT>messages to the view class. However, there is one small problem: ClassWizard doesn'toffer direct support for palette messages sent to child window classes such as <TT>CDibView</TT>.Therefore, some trickery is required. To add the palette-handling functions, followthese steps:<DL>	<DD>1. Open ClassWizard.<BR>	<BR>	2. Select the <TT>CDibView</TT> class.<BR>	<BR>	3. Select the Class Info tab.<BR>	<BR>	4. In the Advanced Options group, click the Message Filter combo box, and select	Topmost Frame instead of Child Window.<BR>	<BR>	5. Select the Message Maps tab and add the message-handling functions for <TT>WM_PALETTECHANGED</TT>	and add <TT>WM_QUERYNEWPALETTE</TT> to the <TT>CDibView</TT> class.<BR>	<BR>	6. Select the Class Info tab.<BR>	<BR>	7. In the Advanced Options group, click the Message Filter combo box and select Child	Window instead of Topmost Frame.<BR>	<BR>	8. Close ClassWizard.</DL><P>The source code for the palette message-handling function is provided in Listing15.11.<H4><FONT COLOR="#000077">TYPE: Listing 15.11. New functions added to the CDibViewclass.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>// OnPaletteChanged - Handles WM_PALETTECHANGED, which is a</TT><TT>// notification that a window has changed the current palette. If</TT><TT>// this view did not change the palette, forward this message to</TT><TT>// OnQueryNewPalette so the palette can be updated, and redrawn</TT><TT>// if possible.</TT><TT>void CDibView::OnPaletteChanged(CWnd* pFocusWnd)</TT><TT>{</TT><TT>    if( pFocusWnd != this )</TT><TT>        OnQueryNewPalette();</TT><TT>}</TT><TT>// Notification that the view is about to become active,</TT><TT>// and the view should realize its palette.</TT><TT>BOOL CDibView::OnQueryNewPalette()</TT><TT>{</TT><TT>    CDibDoc* pDoc = GetDocument();</TT><TT>    ASSERT_VALID(pDoc);</TT><TT>    CBmpPalette* pPal = (CBmpPalette*)pDoc-&gt;GetPalette();</TT><TT>    if( pPal )</TT><TT>    {</TT><TT>        CDC*    pDC = GetDC();</TT><TT>        CPalette* pOldPal = pDC-&gt;SelectPalette( pPal, FALSE );</TT><TT>        UINT uChanges = pDC-&gt;RealizePalette();</TT><TT>        pDC-&gt;SelectPalette( pOldPal, FALSE );</TT><TT>        ReleaseDC( pDC );</TT><TT>        if( uChanges != 0 )</TT><TT>            InvalidateRect( NULL );</TT><TT>    }</TT><TT>    return TRUE;</TT><TT>}</TT></FONT></PRE><P>In most cases, <TT>OnPaletteChanged</TT> calls the <TT>OnQueryNewPalette</TT>function directly. The only exception is when the <TT>WM_PALETTECHANGED</TT> messagewas sent because this view had updated the system palette. If this view is the foregroundwindow, the Windows NT Palette Manager gives you first crack at setting the system'spalette. If you are in the background, you have access to the unused entries only.If there's no more room in the palette, your palette is mapped to the closest possiblematch.</P><P>Remember to include the declarations for the <TT>CDIBitmap</TT> class at the topof the <TT>DibView.cpp</TT> source file, after the existing <TT>#include</TT> directives:</P><PRE><FONT COLOR="#0066FF"><TT>#include &quot;dib256.h&quot;</TT></FONT></PRE><P>Compile and run the Dib example. If you have a 256-color display, load a 256-colorbitmap and notice that you receive all the colors. If you run several instances ofthe program using different 256-color bitmaps, you might notice the palette changeif you switch between windows. Figure 15.7 shows the Dib example displaying the 256-colorWindows NT logo.</P><P><A NAME="07"></A><A HREF="07.htm"><B>Figure 15.7.</B></A> <BR><I>The Dib sample program displaying a 256-color bitmap.</I><H2><FONT COLOR="#000077"><B>Summary</B></FONT></H2><P>In this chapter you learned about bitmaps, a method used to display images ina Windows program. You learned the structures used by Windows bitmaps, how to simplifybitmap handling, and how to use color palettes.<H2><FONT COLOR="#000077"><B>Q&amp;A</B></FONT></H2><DL>	<DD><B>Q Must I manage the palette when displaying 256-color bitmaps if my display	uses more than 256 colors?</B><BR>	<BR>	<B>A</B> No, your display will properly manage the colors used by the bitmap. However,	if your application is used on a system with a 256-color display, the application	will not display the bitmap properly.<BR>	<BR>	<B>Q Can my application use more than one color palette?</B><BR>	<BR>	<B>A</B> Yes, if you were to build an MDI version of the Dib sample program, each	view would need to manage its own color palette.</DL><H2><FONT COLOR="#000077"><B>Workshop</B></FONT></H2><P>The Workshop is designed to help you anticipate possible questions, review whatyou've learned, and begin thinking ahead to putting your knowledge into practice.The answers to the quiz are in Appendix B, &quot;Quiz Answers.&quot;<H3><FONT COLOR="#000077"><B>Quiz</B></FONT></H3><DL>	<DD>1. What MFC class is used to manage bitmaps stored in your resource file?<BR>	<BR>	2. What MFC base class is used to manage color palettes?<BR>	<BR>	3. What type of device context is used to draw into a bitmap off-screen?<BR>	<BR>	4. What function is used to transfer bitmaps to an output device?<BR>	<BR>	5. How many colors are kept by Windows in the system color palette?<BR>	<BR>	6. How many entries in the system color palette are reserved by Windows?<BR>	<BR>	7. What two messages must be handled in order to manage the color palette?<BR>	<BR>	8. What are the differences between the two palette messages?</DL><H3><FONT COLOR="#000077"><B>Exercises</B></FONT></H3><DL>	<DD>1. Modify the Bitmap project so that the bitmap image is displayed three times	in a row across the view instead of once.<BR>	<BR>	2. Modify the <TT>CBmpPalette</TT> class used in the Dib example so that it is monochromatic,	with only various shades of one color selected for the palette instead of colors	from the bitmap.</DL><CENTER><P><HR><A HREF="../ch14/ch14.htm"><IMG SRC="../button/previous.gif" WIDTH="128" HEIGHT="28"ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../ch16/ch16.htm"><IMGSRC="../button/next.gif" WIDTH="128" HEIGHT="28" ALIGN="BOTTOM" ALT="Next chapter"BORDER="0"></A><A HREF="../index.htm"><IMG SRC="../button/contents.gif" WIDTH="128"HEIGHT="28" ALIGN="BOTTOM" ALT="Contents" BORDER="0"></A> <BR><BR><BR><IMG SRC="../button/corp.gif" WIDTH="284" HEIGHT="45" ALIGN="BOTTOM" ALT="Macmillan Computer Publishing USA"BORDER="0"></P><P>&copy; <A HREF="../copy.htm">Copyright</A>, Macmillan Computer Publishing. Allrights reserved.</CENTER></BODY></HTML>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本不卡一二三| 日韩免费在线观看| 亚洲国产高清aⅴ视频| 另类的小说在线视频另类成人小视频在线 | 成人黄色国产精品网站大全在线免费观看 | 亚洲国产精品自拍| 欧美三级中文字幕| 亚洲va欧美va人人爽| 欧美精品18+| 天堂一区二区在线| 欧美一级免费观看| 激情综合网天天干| 欧美激情综合五月色丁香小说| 从欧美一区二区三区| 中文无字幕一区二区三区| 色综合久久九月婷婷色综合| 亚洲不卡av一区二区三区| 精品国产露脸精彩对白| 成人高清av在线| 亚洲资源在线观看| 26uuu欧美| 在线观看亚洲一区| 久久99精品国产91久久来源| 国产精品传媒在线| 制服.丝袜.亚洲.另类.中文 | 欧美激情在线免费观看| 99麻豆久久久国产精品免费| www.欧美亚洲| 秋霞成人午夜伦在线观看| 中文一区二区在线观看| 91精品国产综合久久精品| 国产制服丝袜一区| 亚洲电影一级黄| 国产色爱av资源综合区| 91精品国产综合久久小美女| 99riav久久精品riav| 激情图片小说一区| 午夜精品久久久久久久久久 | 亚洲777理论| 国产视频一区不卡| 欧美精品一区二区三区在线| 欧洲一区在线观看| 色综合久久中文综合久久97| 国产乱人伦偷精品视频免下载| 亚洲福利视频三区| 亚洲六月丁香色婷婷综合久久| 国产亲近乱来精品视频| 精品国产网站在线观看| 日韩区在线观看| 91精品国产91综合久久蜜臀| 欧美唯美清纯偷拍| 欧美日本一区二区三区| 欧美精品 国产精品| 欧美疯狂性受xxxxx喷水图片| 日本高清成人免费播放| 欧美三级蜜桃2在线观看| 欧美高清一级片在线| 欧美变态tickling挠脚心| 久久蜜臀中文字幕| 综合在线观看色| 久久66热re国产| 亚洲乱码国产乱码精品精可以看 | 国产精品人妖ts系列视频| 成人欧美一区二区三区小说| 一区二区三区色| 久久99精品久久久久婷婷| av午夜一区麻豆| 日韩久久久精品| 亚洲人成网站色在线观看| 免费欧美在线视频| 96av麻豆蜜桃一区二区| 日本高清不卡一区| 国产人成一区二区三区影院| 国产精品久久久久婷婷| 蜜臀av性久久久久蜜臀aⅴ| 成人小视频免费在线观看| 欧美日韩一区二区在线观看| 欧美一级久久久久久久大片| 亚洲免费看黄网站| 国产成人av电影在线观看| 色婷婷精品大在线视频| 26uuu精品一区二区在线观看| 成人免费在线播放视频| 麻豆国产欧美日韩综合精品二区| 一本色道亚洲精品aⅴ| 精品日韩成人av| 亚洲国产一区二区在线播放| 福利电影一区二区三区| 欧美电影免费提供在线观看| 亚洲成人综合在线| 在线免费观看日本欧美| 综合亚洲深深色噜噜狠狠网站| 日韩国产精品久久久| 91麻豆精品国产91久久久久 | 久久亚洲综合色一区二区三区| 亚洲国产cao| 欧美日本国产视频| 亚洲成a人在线观看| 欧美精品久久一区| 精品一区二区三区香蕉蜜桃| 精品国产乱码久久久久久久久| 麻豆高清免费国产一区| 久久综合五月天婷婷伊人| 精品一区二区三区的国产在线播放| 日韩一区二区在线免费观看| 久草精品在线观看| 欧美韩日一区二区三区| 日本伦理一区二区| 另类成人小视频在线| 国产日本亚洲高清| 色妹子一区二区| 麻豆成人av在线| 亚洲一卡二卡三卡四卡无卡久久| www.欧美.com| 免费成人av资源网| 最近中文字幕一区二区三区| 欧美日韩激情一区二区三区| 国产中文一区二区三区| 亚洲色图都市小说| 精品国产青草久久久久福利| 色婷婷精品大在线视频 | 国产69精品一区二区亚洲孕妇| 亚洲蜜臀av乱码久久精品蜜桃| 日韩色在线观看| 在线视频一区二区三区| 婷婷综合五月天| 91精品国产全国免费观看| 成人av网站在线| 首页国产欧美久久| 亚洲精品免费一二三区| 久久综合久久综合久久综合| 色婷婷一区二区| 成人性生交大合| 国产伦精品一区二区三区在线观看| 亚洲午夜国产一区99re久久| 亚洲免费资源在线播放| 国产精品美女久久久久av爽李琼| 欧美精品一区二区高清在线观看| 精品视频在线看| 在线观看一区日韩| 欧美性生活久久| 欧美天天综合网| 色综合色综合色综合| 成人福利在线看| 色哟哟在线观看一区二区三区| 成人黄色免费短视频| av毛片久久久久**hd| 91麻豆成人久久精品二区三区| 成人免费视频caoporn| 色综合中文字幕国产| 成人av免费在线观看| 91免费视频网| 91看片淫黄大片一级| 欧美日韩免费不卡视频一区二区三区| 日本电影亚洲天堂一区| 欧美日韩在线直播| 欧美刺激脚交jootjob| 国产欧美一区二区精品秋霞影院| 国产亚洲精品7777| 亚洲成人免费视| 精品综合久久久久久8888| 成人在线视频一区二区| 91国产视频在线观看| 欧美一区二区福利在线| 国产精品拍天天在线| 亚洲成人免费观看| 国产91精品露脸国语对白| 91久久久免费一区二区| 欧美精品一区二区三| 亚洲精品ww久久久久久p站| 久久99久久久欧美国产| 成人a区在线观看| 欧美成人a在线| 亚洲成在人线免费| 99riav久久精品riav| 日韩精品在线一区二区| 香蕉成人伊视频在线观看| 成人一级视频在线观看| 日韩视频一区二区三区| 一区二区久久久| 99久久综合国产精品| 久久精品一区二区三区av| 日韩在线a电影| 欧美老年两性高潮| 亚洲午夜羞羞片| 欧美在线观看18| 亚洲香蕉伊在人在线观| 色综合天天综合狠狠| 国产精品毛片久久久久久| 成人永久免费视频| 中文字幕 久热精品 视频在线| 久草中文综合在线| 久久天堂av综合合色蜜桃网| 国产一区视频导航| 久久久久国产精品麻豆ai换脸| 国内精品视频一区二区三区八戒 | 99久久伊人久久99| 综合中文字幕亚洲| 欧美四级电影网| 午夜激情综合网|