• <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  評論-173  文章-70  trackbacks-0
            修改窗口的圖標---------默認的MFC程序是一個MFC的圖標,現在修改為帶有感嘆號的Warning!
            修改窗口的背景---------默認的是一個白色背景,修改為黑色。
            修改光標------------------默認的是箭頭的光標,這里修改為十字光標,即叉叉。。

            設計過程:
                        新建一個單文檔的程序,然后在CMainFrame和CView文檔中的PreCreateWindow函數中添加響應的修改代碼。

            代碼如下:

            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);
            }

            只要使用的函數是AfxRegiseterWndClass修改窗口參數。具體的資料見API函數。

            引申:CMainFrame類包含文件的框架,因此修改圖標的代碼放在該類中。
            CXXView類表征了框架之上的視圖,因此,應用程序畫刷和光標的風格設置必須在該類的函數中。

            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 閱讀(842) 評論(0)  編輯 收藏 引用
            99久久99久久精品国产| 亚洲AV成人无码久久精品老人| 久久综合给合久久狠狠狠97色| 久久亚洲AV成人无码| 亚洲AV无一区二区三区久久| 久久久久亚洲av无码专区| 91精品国产9l久久久久| 国产精品日韩欧美久久综合| 日本WV一本一道久久香蕉| 欧美午夜精品久久久久免费视| 国内精品久久久久影院免费| 国产三级精品久久| 无遮挡粉嫩小泬久久久久久久| 久久狠狠色狠狠色综合| 伊人 久久 精品| 久久综合综合久久狠狠狠97色88| 合区精品久久久中文字幕一区| 亚洲国产精品一区二区久久hs| 国产精品99久久不卡| 一本久道久久综合狠狠爱| 久久国产视屏| 999久久久免费精品国产| 国产精品久久婷婷六月丁香| 亚洲一本综合久久| 日韩AV无码久久一区二区| 亚洲午夜精品久久久久久app| 99久久亚洲综合精品成人| 久久精品国产亚洲av麻豆小说 | 久久亚洲精品国产精品| 青青久久精品国产免费看| 久久被窝电影亚洲爽爽爽| 亚洲va久久久噜噜噜久久| 性做久久久久久久久| 久久久久国产精品麻豆AR影院| 久久线看观看精品香蕉国产| 亚洲精品无码久久一线| 久久久久亚洲av综合波多野结衣| 精品国产婷婷久久久| 狠狠综合久久综合中文88 | 亚洲中文字幕无码久久精品1 | 久久精品国产日本波多野结衣|