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

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

?? ch15.htm

?? 一天之內學會VC#. 主要介紹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一区二区三区免费野_久草精品视频
一区二区三区**美女毛片| 不卡av在线网| 成人午夜av电影| 欧美色国产精品| 久久综合久久久久88| 亚洲小说春色综合另类电影| 韩国成人福利片在线播放| 在线观看www91| 国产清纯在线一区二区www| 视频一区欧美精品| 色综合久久久久久久久| 国产丝袜在线精品| 久久99国产精品免费网站| 在线观看www91| 亚洲男人天堂av网| 成人h版在线观看| 中文字幕高清一区| 精品一区二区在线观看| 欧美绝品在线观看成人午夜影视| 日韩美女视频一区| av一本久道久久综合久久鬼色| 欧美成人aa大片| 日本中文字幕一区二区有限公司| 91久久人澡人人添人人爽欧美| 中文字幕一区二区三区色视频| 国产主播一区二区三区| 精品国产99国产精品| 日本午夜一区二区| 91精品欧美福利在线观看| 亚洲一区二区在线免费观看视频| 91日韩精品一区| 亚洲日本电影在线| 91在线视频播放地址| 日韩理论片中文av| 色噜噜狠狠一区二区三区果冻| 亚洲私人影院在线观看| 在线观看一区日韩| 亚洲高清三级视频| 欧美精品在线视频| 蜜臀国产一区二区三区在线播放| 欧美精品xxxxbbbb| 美女视频黄免费的久久| 日韩一区二区精品在线观看| 老司机精品视频在线| 欧美成人精品二区三区99精品| 麻豆视频一区二区| 国产日产欧美一区二区三区| 97国产一区二区| 亚洲永久精品大片| 日韩精品一区二区三区中文精品| 免费观看久久久4p| 欧美韩国一区二区| 在线视频一区二区三区| 美女视频网站久久| 国产午夜精品一区二区三区四区| 99国内精品久久| 首页综合国产亚洲丝袜| 久久久国产精品午夜一区ai换脸| 成人黄页在线观看| 亚洲电影在线播放| 欧美电影免费观看高清完整版 | 中文字幕在线一区免费| 欧洲另类一二三四区| 精品在线一区二区三区| 亚洲欧洲日韩在线| 日韩欧美久久久| 91在线视频播放| 精品一区二区免费看| 亚洲免费观看高清完整| 精品人在线二区三区| 成人av网站免费| 日韩电影免费一区| 亚洲三级在线看| 精品国产一区二区三区忘忧草 | 国产呦精品一区二区三区网站| 久久精品欧美一区二区三区不卡| 色999日韩国产欧美一区二区| 日本欧美在线观看| 亚洲日韩欧美一区二区在线| 欧美刺激脚交jootjob| 91精品福利视频| 国产精品亚洲成人| 日韩成人精品视频| 自拍av一区二区三区| 久久久久久久久伊人| 欧美日韩三级一区| 91猫先生在线| 国产在线视频一区二区| 一区二区三区国产| 日韩一区在线播放| 久久精品一二三| 日韩一级成人av| 日本久久一区二区| 成人蜜臀av电影| 国产一区二区三区日韩| 裸体一区二区三区| 首页国产丝袜综合| 亚洲国产精品一区二区久久| 国产精品网曝门| 国产午夜精品在线观看| 欧美成人三级电影在线| 91.麻豆视频| 欧美色欧美亚洲另类二区| 波多野结衣精品在线| 国产精品1024| 久久精品99久久久| 男人操女人的视频在线观看欧美| 亚洲精品国产精华液| 亚洲欧美另类综合偷拍| 亚洲色图在线视频| 亚洲色图一区二区三区| 亚洲日穴在线视频| 亚洲欧美成人一区二区三区| 亚洲丝袜精品丝袜在线| 亚洲另类在线视频| 一区二区三区成人| 夜夜操天天操亚洲| 亚洲资源中文字幕| 午夜激情久久久| 日本色综合中文字幕| 伦理电影国产精品| 国产在线播放一区| 国产成人在线看| 91香蕉视频污| 99精品一区二区| 91福利精品第一导航| 欧美艳星brazzers| 欧美疯狂性受xxxxx喷水图片| 欧美人xxxx| 久久亚洲一级片| 国产精品国模大尺度视频| 亚洲精品福利视频网站| 亚洲成人免费视频| 精品一区二区免费看| www.成人网.com| 欧美日韩免费电影| 精品国产人成亚洲区| 国产精品国产a| 亚洲电影你懂得| 国产精品一线二线三线| 一本大道综合伊人精品热热| 欧美图区在线视频| 日韩一卡二卡三卡四卡| 日本一区二区三区高清不卡 | 欧美性大战久久久久久久| 欧美乱熟臀69xxxxxx| 精品国产免费人成在线观看| 国产精品美女久久久久aⅴ国产馆| 一卡二卡欧美日韩| 毛片不卡一区二区| 91在线精品秘密一区二区| 欧美日韩精品电影| 国产视频一区二区在线观看| 亚洲另类在线一区| 国产一区二区福利视频| 一本久久a久久免费精品不卡| 日韩欧美中文字幕精品| 中文字幕在线一区免费| 免费av成人在线| 色综合久久久久久久久久久| 日韩欧美在线影院| 亚洲精品一二三| 国产精品资源在线观看| 欧美伊人精品成人久久综合97| 久久蜜桃一区二区| 亚洲国产精品久久久男人的天堂| 国产成人av一区二区三区在线观看| 91官网在线观看| 国产精品国产三级国产三级人妇| 免费欧美日韩国产三级电影| 91色.com| 国产精品色哟哟网站| 久久超碰97中文字幕| 欧美优质美女网站| 专区另类欧美日韩| 国产mv日韩mv欧美| 日韩精品资源二区在线| 无码av免费一区二区三区试看| 北条麻妃一区二区三区| www激情久久| 蜜桃在线一区二区三区| 在线观看三级视频欧美| 国产精品国产三级国产三级人妇| 久久国产精品露脸对白| 欧美日韩国产一级二级| 一区二区三区毛片| 一本色道久久综合精品竹菊| 国产精品人成在线观看免费| 国产成人综合自拍| 久久久久97国产精华液好用吗| 石原莉奈一区二区三区在线观看 | 成人性色生活片免费看爆迷你毛片| 欧美一区国产二区| 三级欧美在线一区| 欧美午夜不卡视频| 午夜视频在线观看一区二区| 欧美裸体bbwbbwbbw| 日本女人一区二区三区| 欧美日本乱大交xxxxx| 亚洲r级在线视频|