
CWnd * pWnd是指向控件的指针. LPCTSTR lpszClassName是您的控件的类名称. 例如,编辑框为“编辑”,按钮为“按钮”. 有关详细信息,可以使用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(dwNewStyleExmodifystyle设置填充,lpszClassName,strText,dwNewStyle,rcWindow,pParentWnd,nID);
pWnd-> SetFont(pFont);
返回bResult;

}
测试代码:
void CAboutDlg :: OnButton()
{
CWnd * pWnd = GetDlgItem(IDC_EDIT1);
if(pWnd-> GetStyle()&ES_PASSWORD)
{

ModifyControlStyle(pWnd,“编辑”,ES_PASSWORDmodifystyle设置填充,0、0、0);
}
其他
{
ModifyControlStyle(pWnd,“编辑”,0,ES_PASSWORD,0,0);
}
}
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/jisuanjixue/article-146808-1.html
你Y的
你马云说得有错吗
为应对美国的军事威胁