• <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>
            穩(wěn)定盈利的期貨交易方法-量化趨勢(shì)交易

            alantop -專業(yè)量化投資者

            愛好:量化投資,逆向工程,滲透
            隨筆 - 595, 文章 - 0, 評(píng)論 - 921, 引用 - 0
            數(shù)據(jù)加載中……

            修改控件style的方法

            簡(jiǎn)單的說(shuō):

            After the control has been created, these styles cannot be modified, except as noted.


            修改控件風(fēng)格
            ( )

            CWnd* pWnd 為你控件的指針 ,LPCTSTR lpszClassName 是你控件的類名 , 比如編輯框是 "Edit", 按鈕是 "Button", 詳情可以使用 SPY++ 查看 .

            ?

            BOOL ModifyControlStyle(CWnd* pWnd,LPCTSTR lpszClassName,DWORD dwRemove,DWORD dwAdd,DWORD dwRemoveEx,DWORD dwAddEx)

            {

            ?CWnd* pParentWnd = pWnd->GetParent();

            ?

            ?CFont* pFont = pWnd->GetFont();

            ?

            ?CString strText;

            ?pWnd->GetWindowText(strText);

            ?

            ?{

            ? // 在此添加保存控件其他屬性的代碼 , 我只保存了字體和文字

            ?}

            ?

            ?CRect rcWindow;

            ?pWnd->GetWindowRect(&rcWindow);

            ?pParentWnd->ScreenToClient(rcWindow);

            ?

            ?DWORD dwNewStyle = (pWnd->GetStyle() & ~dwRemove) | dwAdd;

            ?DWORD dwNewStyleEx = (pWnd->GetExStyle() & ~dwRemoveEx) | dwAddEx;

            ?

            ?UINT nID = pWnd->GetDlgCtrlID();

            ?

            ?pWnd->ShowWindow(SW_HIDE);

            ?pWnd->DestroyWindow();

            ?

            ?BOOL bResult = pWnd->CreateEx(dwNewStyleEx,lpszClassName,strText,dwNewStyle,rcWindow,pParentWnd,nID);

            ?

            ?pWnd->SetFont(pFont);

            ?

            ?return bResult;

            }

            ?

            測(cè)試代碼 :

            ?

            void CAboutDlg::OnButton()

            {

            ?CWnd* pWnd = GetDlgItem(IDC_EDIT1);

            ?

            ?if(pWnd->GetStyle() & ES_PASSWORD)

            ?{

            ? ModifyControlStyle(pWnd,"Edit",ES_PASSWORD,0,0,0);

            ?}

            ?else

            ?{

            ? ModifyControlStyle(pWnd,"Edit",0,ES_PASSWORD,0,0);

            ?}

            }

            ?

            修改控件風(fēng)格的第二種方法:

            Changing Edit Control Styles at Runtime

            It is not possible to change all the styles of an Edit Control at runtime using ModifyStyle() or ModifyStyleEx(). If you have the need to change the text alignment at runtime, for example, it is best to construct the Edit Control by calling new and CreateEx, then deleting it and creating a new one when the style is to be changed. Alternatively, you can have 2 Edit Controls superimposed and hide the one with the incorrect style.

            ?

            In the demo, I use CreateEx to create the Edit Control, because then the extended style WS_EX_CLIENTEDGE can be used to give the 3D border for the control.

            ?

            ??? m_pFlyEdit->CreateEx(WS_EX_CLIENTEDGE, _T("EDIT"),

            ??????? "", dwStyle, rc, this, IDC_EDIT6);

            You will note the two lines that are commented out. If you enable those and comment out the above line, you will get a flat Edit Control (without border, unless you also uncomment the WS_BORDER style). The control remains flat because WS_EX_CLIENTEDGE is one of the styles that cannot be changed after creation.

            ?

            //??? m_pFlyEdit->Create( dwStyle, rc, this, IDC_EDIT6 );

            //??? m_pFlyEdit->ModifyStyleEx( 0, WS_EX_CLIENTEDGE );

            In the demo, the Edit Controls headed 'Text Alignment test' change the alignment style. The code deletes the old Edit Control and creates a new one each time the radio buttons are clicked. ModifyStyle() is called for m_Edit3 but as you will note, it has no effect.

            ?

            void CEditCtrlTutorialDlg::OnAlignmentChange(UINT nID)

            {

            ??? UpdateData();

            ??? TRACE("CEditCtrlTutorialDlg::OnAlignmentChange( %d )\n",

            ???????????????????????????????????????????????? m_nAlignment);

            ??? DWORD dwStyle =

            ????? WS_CHILD|WS_VISIBLE|WS_TABSTOP/*|WS_BORDER*/|ES_AUTOHSCROLL;

            ?

            ??? switch( m_nAlignment )

            ??? {

            ??? case 1:

            ??????? dwStyle |= ES_CENTER;

            ??????? m_Edit3.ModifyStyle(ES_RIGHT|ES_LEFT,ES_CENTER);

            ??????? break;

            ??? case 2:

            ??????? dwStyle |= ES_RIGHT;

            ??????? m_Edit3.ModifyStyle(ES_CENTER|ES_LEFT,ES_RIGHT);

            ??????? break;

            ??? default:

            ??????? dwStyle |= ES_LEFT;

            ??????? m_Edit3.ModifyStyle(ES_CENTER|ES_RIGHT,ES_LEFT);

            ??????? break;

            ??? }

            ??? m_Edit3.Invalidate();

            ?

            ??? CString str = _T("");

            ??? if( m_pFlyEdit )

            ??? {

            ??????? m_pFlyEdit->GetWindowText( str );

            ??????? delete m_pFlyEdit;

            ??? }

            ?

            ??? CRect rc;

            ??? m_Template.GetWindowRect( &rc );

            ??? ScreenToClient( &rc );

            ??? m_pFlyEdit = new CEdit;

            //??? m_pFlyEdit->Create( dwStyle, rc, this, IDC_EDIT6 );

            //??? m_pFlyEdit->ModifyStyleEx( 0, WS_EX_CLIENTEDGE );

            ??? m_pFlyEdit->CreateEx(WS_EX_CLIENTEDGE, _T("EDIT"),

            ?????????????????????????? "", dwStyle, rc, this, IDC_EDIT6);

            ??? // set font same as dialog to be sure they are the same

            ??? m_pFlyEdit->SetFont( GetFont() );

            ??? m_pFlyEdit->SetWindowText( str );

            ?

            ??? UpdateData(FALSE);

            }

            ES_UPPERCASE and ES_LOWERCASE styles need to be treated in the same way. ES_READONLY style can be changed by calling the SetReadOnly() member function as shown in the demo.

            ?

            void CEditCtrlTutorialDlg::OnReadOnly()

            {

            ??? UpdateData();

            ??? m_Edit2.SetReadOnly( m_bReadOnly );

            }

            The ES_NUMBER style can also be changed at runtime using ModifyStyle(). It is handy where an Edit Control is used for multiple purposes and also to turn the style in case it was forgotten in the RC script. The code below will actually toggle the style:

            ?

            void CEditCtrlTutorialDlg::OnNumbersOnly()

            {

            ??? UpdateData();

            ??? m_Edit7.SetSel(0,-1);??????? // select all the text

            ??? m_Edit7.Clear();??????????? // delete selection

            ??? m_Edit7.ModifyStyle(ES_NUMBER*(m_bNumbersOnly==FALSE),

            ?????????????????????????? ??ES_NUMBER*(m_bNumbersOnly==TRUE));

            }

            In this example, the Edit Control is also cleared while the style is changed. A number-only Edit Control can have non-numeric characters in it. It just won't permit them to be entered from the keyboard.

            ?

            posted on 2006-05-24 20:16 AlanTop 閱讀(1139) 評(píng)論(0)  編輯 收藏 引用 所屬分類: C++

            久久久久久九九99精品| 伊人久久精品影院| 18禁黄久久久AAA片| 久久中文字幕一区二区| 国产色综合久久无码有码| 国产福利电影一区二区三区久久老子无码午夜伦不 | 亚洲精品美女久久777777| 亚洲国产精品久久久久| 亚洲日本va中文字幕久久| 久久久精品波多野结衣| a级成人毛片久久| 7777精品久久久大香线蕉| 久久国产精品免费一区二区三区| 久久久久亚洲AV成人片| 久久人人爽人人爽人人片AV高清| 久久se精品一区精品二区国产| 1000部精品久久久久久久久| 免费久久人人爽人人爽av| 久久九九免费高清视频 | 亚洲国产精品无码久久久秋霞2 | 91精品国产高清久久久久久io| 人妻无码αv中文字幕久久琪琪布| 激情五月综合综合久久69| 精品国产福利久久久| 波多野结衣中文字幕久久| 99久久无色码中文字幕人妻| 无码国内精品久久综合88| 久久激情五月丁香伊人| 国产综合成人久久大片91| 久久精品国产精品国产精品污| 久久久久人妻一区精品性色av| 亚洲国产精品高清久久久| 久久精品国产清自在天天线| 精品伊人久久久| 99久久精品国产一区二区| 一本一本久久aa综合精品| 人妻丰满AV无码久久不卡| 久久久久久久久无码精品亚洲日韩 | 欧美一区二区三区久久综合| 亚洲精品午夜国产VA久久成人| 亚洲中文精品久久久久久不卡|