• <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>
            隨筆-145  評(píng)論-173  文章-70  trackbacks-0
            修改窗口的圖標(biāo)---------默認(rèn)的MFC程序是一個(gè)MFC的圖標(biāo),現(xiàn)在修改為帶有感嘆號(hào)的Warning!
            修改窗口的背景---------默認(rèn)的是一個(gè)白色背景,修改為黑色。
            修改光標(biāo)------------------默認(rèn)的是箭頭的光標(biāo),這里修改為十字光標(biāo),即叉叉。。

            設(shè)計(jì)過(guò)程:
                        新建一個(gè)單文檔的程序,然后在CMainFrame和CView文檔中的PreCreateWindow函數(shù)中添加響應(yīng)的修改代碼。

            代碼如下:

            BOOL CMainFrame::PreCreateWindow(CREATESTRUCT
            & cs)
            {
                
            if!CFrameWnd::PreCreateWindow(cs) )
                    
            return FALSE;
                
            // TODO: Modify the Window class or styles here by modifying
                
            //  the CREATESTRUCT cs
                cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW,0,0,LoadIcon(NULL,IDI_WARNING));

                
            return TRUE;
            }





            BOOL CTest12View::PreCreateWindow(CREATESTRUCT
            & cs)
            {
                
            // TODO: Modify the Window class or styles here by modifying
                
            //  the CREATESTRUCT cs
                cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW,LoadCursor(NULL,IDC_CROSS),(HBRUSH)GetStockObject((BLACK_BRUSH)),0);
                
            return CView::PreCreateWindow(cs);
            }

            只要使用的函數(shù)是AfxRegiseterWndClass修改窗口參數(shù)。具體的資料見(jiàn)API函數(shù)。

            引申:CMainFrame類包含文件的框架,因此修改圖標(biāo)的代碼放在該類中。
            CXXView類表征了框架之上的視圖,因此,應(yīng)用程序畫(huà)刷和光標(biāo)的風(fēng)格設(shè)置必須在該類的函數(shù)中。

            AfxRegisterWndClass  
            LPCTSTR AFXAPI AfxRegisterWndClass( UINT nClassStyle, HCURSOR hCursor 
            = 0, HBRUSH hbrBackground = 0, HICON hIcon = 0 ); 

            Return Value

            null-terminated string containing the class name. You can pass this class name to the Create member function in CWnd or other CWnd-derived classes to create a window. The name is generated by the Microsoft Foundation Class Library.

            Note   The 
            return value is a pointer to a static buffer. To save this string, assign it to a CString variable. 

            Parameters

            nClassStyle

            Specifies the Windows 
            class style or combination of styles, created by using the bitwise-OR (|operatorfor the window class. For a list of class styles, see theWNDCLASS structure in the Win32 SDK documentation. If NULL, the defaults will be set as follows: 

            Sets the mouse style to CS_DBLCLKS, which sends 
            double-click messages to the window procedure when the user double-clicks the mouse.


            Sets the arrow cursor style to the Windows standard IDC_ARROW.


            Sets the background brush to NULL, so the window will not erase its background.


            Sets the icon to the standard, waving
            -flag Windows logo icon. 
            hCursor

            Specifies a handle to the cursor resource to be installed 
            in each window created from the window class. If you use the default of 0, you will get the standard IDC_ARROW cursor.

            hbrBackground

            Specifies a handle to the brush resource to be installed 
            in each window created from the window class. If you use the default of 0, you will have a NULL background brush, and your window will, by default, not erase its background while processingWM_ERASEBKGND.

            hIcon

            Specifies a handle to the icon resource to be installed 
            in each window created from the window class. If you use the default of 0, you will get the standard, waving-flag Windows logo icon.

            Remarks

            The Microsoft Foundation Class Library automatically registers several standard window classes 
            for you. Call this function if you want to register your own window classes.

            The name registered 
            for a class by AfxRegisterWndClass depends solely on the parameters. If you call AfxRegisterWndClass multiple times with identical parameters, it only registers a class on the first call. Subsequent calls to AfxRegisterWndClass with identical parameters simply return the already-registered classname.

            If you call AfxRegisterWndClass 
            for multiple CWnd-derived classes with identical parameters, instead of getting a separate window class for each class, each class shares the same window class. This can cause problems if the CS_CLASSDC class style is used. Instead of multiple CS_CLASSDC window classes, you end up with one CS_CLASSDC window class, and all C++ windows that use that class share the same DC. To avoid this problem, call AfxRegisterClass to register the class.

            Example

            CString strMyClass;

            // load stock cursor, brush, and icon for
            // my own window class

            try
            {
               strMyClass 
            = AfxRegisterWndClass(
                  CS_VREDRAW 
            | CS_HREDRAW,
                  ::LoadCursor(NULL, IDC_ARROW),
                  (HBRUSH) ::GetStockObject(WHITE_BRUSH),
                  ::LoadIcon(NULL, IDI_APPLICATION));
            }

            catch (CResourceException* pEx)
            {
                  AfxMessageBox(
                     _T(
            "Couldn't register class! (Already registered?)"));
                  pEx
            ->Delete();
            }


            posted on 2010-02-16 16:38 deercoder 閱讀(845) 評(píng)論(0)  編輯 收藏 引用

            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


            免费无码国产欧美久久18| 久久最新精品国产| 久久国产精品99精品国产| 久久精品成人国产午夜| 久久精品无码一区二区app| 久久久久久伊人高潮影院| 91精品国产高清91久久久久久| 久久久精品视频免费观看| 亚洲色大成网站WWW久久九九| 日本精品久久久久中文字幕8| 亚洲欧美国产日韩综合久久| 99久久久精品免费观看国产 | 无码乱码观看精品久久| 久久久久亚洲AV无码麻豆| 尹人香蕉久久99天天拍| 国产精品久久久久久久久久免费| 日本人妻丰满熟妇久久久久久| 91精品国产色综久久| 久久精品中文闷骚内射| 性做久久久久久久久浪潮| 久久国产成人午夜aⅴ影院| 国产精品国色综合久久| 一本色综合网久久| 久久国产亚洲精品| 人妻中文久久久久| 久久久精品久久久久久| 久久精品国产黑森林| 天天综合久久久网| 久久久久久久99精品免费观看| 色8久久人人97超碰香蕉987| 久久综合九色综合网站| 久久亚洲日韩看片无码| 久久久久亚洲国产| 国内精品久久久久影院老司| 久久青青草视频| 久久久久久久久久久| 伊人久久大香线蕉综合Av| 久久天天躁夜夜躁狠狠躁2022| 精品国产乱码久久久久软件| 亚洲va久久久噜噜噜久久狠狠| 久久精品麻豆日日躁夜夜躁|