亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
91色婷婷久久久久合中文| 亚洲人xxxx| 亚洲国产精华液网站w | 激情综合色综合久久综合| 精品在线你懂的| av资源网一区| 亚洲欧美在线另类| 91精品国产一区二区| 国产成人在线观看| 久久久99免费| 国产一区二区三区黄视频 | 国产婷婷一区二区| 成人免费在线视频| 视频一区二区欧美| 国产精品一区二区久久不卡 | 亚洲综合成人在线视频| 日本免费在线视频不卡一不卡二| 韩国三级在线一区| 91丝袜美女网| wwwwxxxxx欧美| 亚洲精品视频一区| 青青草国产精品97视觉盛宴| 成人高清免费在线播放| 欧美日韩久久不卡| 国产清纯白嫩初高生在线观看91| 亚洲成人av福利| 成人激情电影免费在线观看| 9191国产精品| 亚洲婷婷国产精品电影人久久| 日本最新不卡在线| 91网站视频在线观看| 久久中文字幕电影| 亚洲国产综合视频在线观看| 国产精品乡下勾搭老头1| 欧美日韩一区二区三区免费看| 久久久久久久免费视频了| 午夜精品久久久久久久99樱桃 | 亚洲天堂2014| 久久精品国产一区二区三| 在线观看日韩高清av| 国产欧美一区在线| 看电影不卡的网站| 在线成人av影院| 亚洲乱码精品一二三四区日韩在线| 精品一区二区三区在线观看| 欧美日韩一区高清| 亚洲人成在线观看一区二区| 国产精品影视在线观看| 欧美一区二区免费观在线| 亚洲一区二区三区视频在线 | 一区二区三区国产精品| 国产成人精品www牛牛影视| 日韩美女一区二区三区| 亚洲电影一区二区| 91国在线观看| 综合中文字幕亚洲| 成人综合婷婷国产精品久久| 久久天天做天天爱综合色| 秋霞av亚洲一区二区三| 欧美日韩成人高清| 亚洲第一主播视频| 欧美日韩久久久一区| 亚洲成人一区二区在线观看| 在线亚洲高清视频| 亚洲黄一区二区三区| 91视频国产观看| 亚洲视频在线一区观看| 成人精品亚洲人成在线| 久久亚洲精品国产精品紫薇| 日韩成人一级大片| 欧美区一区二区三区| 午夜日韩在线电影| 欧美欧美欧美欧美| 五月婷婷激情综合网| 欧美精品久久天天躁| 日韩黄色片在线观看| 欧美另类高清zo欧美| 午夜a成v人精品| 4438x成人网最大色成网站| 日韩国产在线观看| 欧美mv日韩mv国产网站app| 蜜桃av噜噜一区| 精品少妇一区二区三区| 美女网站一区二区| 精品久久久久久久久久久久包黑料| 美女网站在线免费欧美精品| 精品久久久久久久久久久院品网| 精品一区二区三区蜜桃| 久久精品亚洲精品国产欧美kt∨ | 国产精品色眯眯| 成人福利视频在线看| 亚洲精品网站在线观看| 精品视频免费看| 日韩不卡一区二区三区| www久久精品| 不卡视频一二三四| 中文字幕一区二| 欧美在线看片a免费观看| 亚洲国产综合视频在线观看| 日韩午夜av电影| 精品一区二区在线看| 欧美激情一区二区三区四区| 91蝌蚪porny成人天涯| 午夜精品久久久久| 久久综合久久鬼色| 91丝袜呻吟高潮美腿白嫩在线观看| 亚洲va中文字幕| 欧美精品一区二区久久婷婷 | 日韩伦理电影网| 欧美三级日韩在线| 美女视频一区在线观看| 国产亚洲制服色| 91最新地址在线播放| 亚洲超丰满肉感bbw| 欧美成人精品1314www| 成人免费毛片a| 视频一区在线视频| 久久视频一区二区| 色菇凉天天综合网| 久久疯狂做爰流白浆xx| 成人免费视频在线观看| 欧美放荡的少妇| 成人av一区二区三区| 亚洲香肠在线观看| 国产日韩视频一区二区三区| 欧美日韩国产电影| 成人网男人的天堂| 人人狠狠综合久久亚洲| 中文字幕一区二| 精品国产一区二区三区av性色| jlzzjlzz国产精品久久| 麻豆一区二区99久久久久| 亚洲欧美区自拍先锋| 欧美mv和日韩mv的网站| 欧美三级中文字幕| 国产成人精品一区二| 视频一区视频二区中文字幕| 日韩一区欧美一区| 精品国产污污免费网站入口| 欧美午夜精品一区二区蜜桃| 高清国产午夜精品久久久久久| 性久久久久久久久| 国产精品第五页| 久久久一区二区| 5858s免费视频成人| 99精品久久免费看蜜臀剧情介绍| 麻豆精品一区二区av白丝在线| 亚洲精品乱码久久久久久久久| 精品处破学生在线二十三| 欧美日韩在线精品一区二区三区激情 | 99久久国产综合精品色伊| 久久精品国产网站| 午夜成人免费视频| 亚洲色图在线视频| 日本一区二区三区高清不卡| 91精品国产一区二区三区香蕉| 91啦中文在线观看| 成人美女视频在线看| 国产一区二区剧情av在线| 男人的天堂亚洲一区| 亚洲亚洲人成综合网络| 亚洲色图20p| 国产精品全国免费观看高清| 精品国产乱码久久久久久蜜臀| 3d成人动漫网站| 欧美日韩国产高清一区二区三区 | 亚洲一级二级三级在线免费观看| 亚洲欧洲精品一区二区三区| 国产日韩欧美不卡在线| 2023国产精华国产精品| 欧美一区二区三区色| 在线成人小视频| 欧美一区二区三区在线观看| 欧美日韩精品一区视频| 欧美日韩在线电影| 欧美巨大另类极品videosbest | 丝袜美腿亚洲综合| 一区二区三区视频在线观看 | 欧美福利视频一区| 欧美日韩亚洲综合在线 欧美亚洲特黄一级 | 国产性做久久久久久| 久久品道一品道久久精品| 26uuu国产一区二区三区| 日韩视频在线一区二区| 91精品午夜视频| 欧美一二三区在线观看| 日韩欧美一二三四区| 日韩精品一区二区三区视频播放 | 不卡视频在线看| 色综合天天狠狠| 在线国产亚洲欧美| 欧美亚洲高清一区二区三区不卡| 欧美在线免费播放| 欧美一区二区免费视频| 精品国产乱子伦一区| 久久天堂av综合合色蜜桃网| 国产日本欧美一区二区| 亚洲色图在线视频| 亚洲高清一区二区三区| 日韩国产欧美视频|