• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
    • 軟件測試技術
    • 軟件測試博客
    • 軟件測試視頻
    • 開源軟件測試技術
    • 軟件測試論壇
    • 軟件測試沙龍
    • 軟件測試資料下載
    • 軟件測試雜志
    • 軟件測試人才招聘
      暫時沒有公告

    字號: | 推薦給好友 上一篇 | 下一篇

    如何創建一個不規則形狀的窗口

    發布: 2007-7-14 21:11 | 作者: 佚名    | 來源: 網絡轉載     | 查看: 10次 | 進入軟件測試論壇討論

    領測軟件測試網 可以使用新的SDK函數SetWindowRgn。該函數將繪畫和鼠標消息限定在窗口的一個指定的區域,實際上使窗口成為指定的不規則形狀。

    使用AppWizard創建一個基于對話框的應用程序并使用資源編輯器從主對話資源中刪除有的缺省控件、標題以及邊界。

    給對話類增加一個CRgn數據成員,以后要使用該數據成員建立窗口區域。
    Class CRoundDlg : public CDialog
    { …
    private :
    Crgn m_rgn : // window region
    …}
    修改OnInitDialog函數建立一個橢圓區域并調用SetWindowRgn將該區域分配給窗口:
    BOOL CRoundDlg : : OnInitDialog ( )
    {

    CDialog : : OnInitDialog ( )

    //Get size of dialog .

    CRect rcDialog ;

    GetClientRect (rcDialog )

    // Create region and assign to window .

    m_rgn . CreateEllipticRgn (0 , 0 , rcDialog.Width( ),

    rcDialog.Height ( ) )

    SetWindowRgn (GetSafeHwnd ( ) , (HRGN) m_ rgn ,TRUE );

    return TRUE
    }
    通過建立區域和調用SetWindowRgn,已經建立一個不規則形狀的窗口,下面的例子程序是修改OnPaint函數使窗口形狀看起來象一個球形體。
    voik CRoundDlg : : OnPaint ( )
    {
    CPaintDC de (this) // device context for painting.
    //draw ellipse with out any border
    dc. SelecStockObject (NULL_PEN)
    //get the RGB colour components of the sphere color
    COLORREF color= RGB( 0 , 0 , 255)
    BYTE byRed =GetRValue (color)
    BYTE byGreen = GetGValue (color)
    BYTE byBlue = GetBValue (color)
    // get the size of the view window Crect
    rect GetClientRect (rect)
    // get minimun number of units
    int nUnits =min (rect.right , rect.bottom )
    //calculate he horiaontal and vertical step size
    float fltStepHorz = (float) rect.right /nUnits
    float fltStepVert = (float) rect.bottom /nUnits
    int nEllipse = nUnits/3 // calculate how many todraw int nIndex
    // current ellipse that is being draw
    CBrush brush
    // bursh used for ellipse fill color
    CBrush *pBrushOld // previous brush that was selected into dc
    //draw ellipse , gradually moving towards upper-rightcorner
    for (nIndex = 0 nIndes < + nEllipse nIndes++)
    { //creat solid brush brush .
    CreatSolidBrush (RGB ( ( (nIndex*byRed ) /nEllipse ).

    ( ( nIndex * byGreen ) /nEllipse ), ( (nIndex*byBlue)/nEllipse ) ) )
    //select brush into dc
    pBrushOld= dc .SelectObject (&brhsh)
    //draw ellipse
    dc .Ellipse ( (int) fltStepHorz * 2, (int)fltStepVert * nIndex ,
    rect. right -( (int)fltStepHorz * nIndex )+ 1, rect . bottom -( (int)
    fltStepVert * (nIndex *2) ) +1)
    //delete the brush
    brush.DelecteObject ( )
    } }
    最后,處理WM_NCHITTEST消息,使當擊打窗口的任何位置時能移動窗口。
    UINT CRoundDlg : : OnNchitTest (Cpoint point )
    {
    //Let user move window by clickign anywhere on thewindow .
    UINT nHitTest = CDialog : : OnNcHitTest (point)
    rerurn (nHitTest = = HTCLIENT)? HTCAPTION: nHitTest

    延伸閱讀

    文章來源于領測軟件測試網 http://www.kjueaiud.com/


    關于領測軟件測試網 | 領測軟件測試網合作伙伴 | 廣告服務 | 投稿指南 | 聯系我們 | 網站地圖 | 友情鏈接
    版權所有(C) 2003-2010 TestAge(領測軟件測試網)|領測國際科技(北京)有限公司|軟件測試工程師培訓網 All Rights Reserved
    北京市海淀區中關村南大街9號北京理工科技大廈1402室 京ICP備2023014753號-2
    技術支持和業務聯系:info@testage.com.cn 電話:010-51297073

    軟件測試 | 領測國際ISTQBISTQB官網TMMiTMMi認證國際軟件測試工程師認證領測軟件測試網

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>