• <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>

            我住包子山

            this->blog.MoveTo("blog.baozishan.in")

            SubclassWindow 一個函數(shù),其實是個宏

            #define     SubclassWindow(hwnd, lpfn)       \
                          ((WNDPROC)SetWindowLongPtr((hwnd), GWLP_WNDPROC, (LPARAM)(WNDPROC)(lpfn)))

            這個宏是我看第七章winshellprograming看到的,很強(qiáng)大的功能,例子是用FindWindowEx找到windows開始按鈕的窗口句柄,之后用該宏加入開始按鈕的消息處理函數(shù).總之還不錯,winshell還真不是一般..
            MSDN上查SubclassWindow都不是我要的這個,雖然功能大體相同吧.
            下面這個就是SetWindowLongPtr函數(shù):
            SetWindowLongPtr Function

            The SetWindowLongPtr function changes an attribute of the specified window. The function also sets a value at the specified offset in the extra window memory.

            這個函數(shù)改變一個指定窗口的一個屬性.它也可設(shè)定窗口儲存區(qū)指定偏移位置的值。

            This function supersedes the SetWindowLong function. To write code that is compatible with both 32-bit and 64-bit versions of Microsoft Windows, use SetWindowLongPtr.
            這個函數(shù)取代了SetWindowLong函數(shù),為了兼容32位64位windows os,就用這個函數(shù)吧 .

            Syntax

            LONG_PTR SetWindowLongPtr(      
                HWND hWnd,
                int nIndex,
                LONG_PTR dwNewLong
            );

            Parameters

            hWnd
            [in] Handle to the window and, indirectly, the class to which the window belongs. The SetWindowLongPtr function fails if the process that owns the window specified by the hWnd parameter is at a higher process privilege in the User Interface Privilege Isolation (UIPI) hierarchy than the process the calling thread resides in.
            返回fail當(dāng)擁有指定窗口的京城比用戶UI權(quán)限隔絕(??)高的時候..不知道翻譯對不

            Microsoft Windows XP and earlier: The SetWindowLongPtr function fails if the window specified by the hWnd parameter does not belong to the same process as the calling thread.

            這個意思大概是函數(shù)失敗如果調(diào)用進(jìn)程傳入的hWnd句柄不屬于調(diào)用包含這個函數(shù)的線程的進(jìn)程(應(yīng)用程序).

            nIndex
            [in] Specifies the zero-based offset to the value to be set. Valid values are in the range zero through the number of bytes of extra window memory, minus the size of an integer. To set any other value, specify one of the following values.
            這個不用翻譯了,很明了哈哈
            GWL_EXSTYLE
            Sets a new extended window style. For more information, see CreateWindowEx.
            GWL_STYLE
            Sets a new window style.
            GWLP_WNDPROC
            Sets a new address for the window procedure.
            GWLP_HINSTANCE
            Sets a new application instance handle.
            GWLP_ID
            Sets a new identifier of the window.
            GWLP_USERDATA
            Sets the user data associated with the window. This data is intended for use by the application that created the window. Its value is initially zero.
            The following values are also available when the hWnd parameter identifies a dialog box.
            DWLP_DLGPROC
            Sets the new pointer to the dialog box procedure.
            DWLP_MSGRESULT
            Sets the return value of a message processed in the dialog box procedure.
            DWLP_USER
            Sets new extra information that is private to the application, such as handles or pointers.
            dwNewLong
            [in] Specifies the replacement value.

            Return Value

            If the function succeeds, the return value is the previous value of the specified offset.
            成功返回的是設(shè)置前的值LONG_PTR這個類型

            If the function fails, the return value is zero. To get extended error information, call GetLastError.

            If the previous value is zero and the function succeeds, the return value is zero, but the function does not clear the last error information. To determine success or failure, clear the last error information by calling SetLastError(0), then call SetWindowLongPtr. Function failure will be indicated by a return value of zero and a GetLastError result that is nonzero.


            Remarks

            Certain window data is cached, so changes you make using SetWindowLongPtr will not take effect until you call the SetWindowPos function.

            If you use SetWindowLongPtr with the GWLP_WNDPROC index to replace the window procedure, the window procedure must conform to the guidelines specified in the description of the WindowProc callback function.

            If you use SetWindowLongPtr with the DWLP_MSGRESULT index to set the return value for a message processed by a dialog box procedure, the dialog box procedure should return TRUE directly afterward. Otherwise, if you call any function that results in your dialog box procedure receiving a window message, the nested window message could overwrite the return value you set by using DWLP_MSGRESULT.

            Calling SetWindowLongPtr with the GWLP_WNDPROC index creates a subclass of the window class used to create the window. An application can subclass a system class, but should not subclass a window class created by another process. The SetWindowLongPtr function creates the window subclass by changing the window procedure associated with a particular window class, causing the system to call the new window procedure instead of the previous one. An application must pass any messages not processed by the new window procedure to the previous window procedure by calling CallWindowProc. This allows the application to create a chain of window procedures.

            Reserve extra window memory by specifying a nonzero value in the cbWndExtra member of the WNDCLASSEX structure used with the RegisterClassEx function.

            Do not call SetWindowLongPtr with the GWLP_HWNDPARENT index to change the parent of a child window. Instead, use the SetParent function.

            If the window has a class style of CS_CLASSDC or CS_PARENTDC, do not set the extended window styles WS_EX_COMPOSITED or WS_EX_LAYERED.

            Windows XP/Vista: Calling SetWindowLongPtr to set the style on a progressbar will reset its position.

            Function Information



            先到這里,以后會寫更多Win32的基礎(chǔ)知識,當(dāng)我學(xué)到的時候..

            btw,有本叫the old new thing 似乎很強(qiáng),不知道什么時候能有一本...

            posted on 2007-06-03 00:26 Gohan 閱讀(4180) 評論(2)  編輯 收藏 引用 所屬分類: MFC/SDK

            Feedback

            # re: SubclassWindow 一個函數(shù),其實是個宏 2008-06-27 18:39 hoodlum1980

            你怎么翻譯的啊!
            Extra Window Memory,是窗口類里面的一個成員,表示給每個窗口保留分配的一塊內(nèi)存的地址。換句話說,它是一個具體窗口自己獨占的一個存儲區(qū)。

            再有:
            Extra Class Memory:是屬于窗口類的內(nèi)存,所有屬于該類窗口的共享數(shù)據(jù)。

            另外你的hwnd參數(shù)的解釋,我用的vs.net2003的文檔,和你的不一樣,我看到的msdn上說的是,如果這個窗口不屬于調(diào)用該函數(shù)的線程,則該函數(shù)會失敗。  回復(fù)  更多評論   

            # re: SubclassWindow 一個函數(shù),其實是個宏 2008-06-27 23:23 Gohan

            @hoodlum1980
            謝謝大哥你的指點,已經(jīng)根據(jù)你的回復(fù)改正了翻譯,有任何問題歡迎指出。小弟還是初學(xué),向大哥學(xué)習(xí)了。  回復(fù)  更多評論   

            91超碰碰碰碰久久久久久综合| 中文精品久久久久人妻| 97精品国产91久久久久久| 亚洲国产精品婷婷久久| 久久性生大片免费观看性| 久久午夜无码鲁丝片秋霞| 国产精品一区二区久久国产| 99久久精品免费看国产| 久久久久久久久波多野高潮| 欧美一区二区三区久久综合| 国产成人99久久亚洲综合精品 | 香蕉久久永久视频| 亚洲国产另类久久久精品黑人| 日产精品99久久久久久| 国产免费久久久久久无码| 久久乐国产综合亚洲精品| 7国产欧美日韩综合天堂中文久久久久| 久久婷婷五月综合色99啪ak| 久久精品亚洲一区二区三区浴池 | 国产成人无码精品久久久久免费| 久久久久亚洲国产| 久久99精品久久久久久野外| 久久精品a亚洲国产v高清不卡| 久久久精品国产| 久久人妻少妇嫩草AV无码蜜桃| 狠狠色婷婷久久一区二区三区| 午夜精品久久久久久久无码| 国产免费久久久久久无码| 久久久久久狠狠丁香| 久久综合亚洲欧美成人| 人人妻久久人人澡人人爽人人精品| 亚洲国产精品人久久| 色噜噜狠狠先锋影音久久| 国产V综合V亚洲欧美久久| 国内精品久久久久久99蜜桃| 99久久做夜夜爱天天做精品| 亚洲精品美女久久久久99小说| 午夜精品久久久久久影视777| 久久93精品国产91久久综合| 精品久久久久久无码国产| 韩国三级中文字幕hd久久精品|