组合框怎么风格怎转变?只读,和可写的相互变化。
int CDdddddDlg::SetStyle(int Style)
{
//IDC_COMBO_BRANCHCODE 组合框ID
DWORD theStyle;
HWND theChild;
theChild = ::GetWindow( GetDlgItem(IDC_COMBO_BRANCHCODE)->m_hWnd ,GW_CHILD);
theStyle = GetWindowLong(GetDlgItem(IDC_COMBO_BRANCHCODE)->m_hWnd, GWL_STYLE);
if (Style == 0 )//可写
{
::SetWindowLong(GetDlgItem(IDC_COMBO_BRANCHCODE)->m_hWnd, CBS_DROPDOWN , theStyle);
::SetWindowPos(GetDlgItem(IDC_COMBO_BRANCHCODE)->m_hWnd,//使SetWindowLong生效
0,
0,
0,
0,
0,
SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE);
theStyle &= ~CBS_DROPDOWNLIST;// 去掉DROPDOWNLIST
theStyle |= CBS_DROPDOWN ; //添加DROPDOWN
::DestroyWindow(theChild);
// SetWindowLong(GetDlgItem(IDC_COMBO_BRANCHCODE)->m_hWnd, GWL_STYLE , theStyle);
SetWindowLong(GetDlgItem(IDC_COMBO_BRANCHCODE)->m_hWnd, GWL_STYLE , theStyle);
::SetWindowPos(GetDlgItem(IDC_COMBO_BRANCHCODE)->m_hWnd,
NULL,
0,
0,
0,
0,
SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE);
return 0;
}
if (Style == 1)//只读
{
::SetWindowLong(GetDlgItem(IDC_COMBO_BRANCHCODE)->m_hWnd, CBS_DROPDOWNLIST , theStyle);
::SetWindowPos(GetDlgItem(IDC_COMBO_BRANCHCODE)->m_hWnd,//使SetWindowLong生效
NULL,
0,
0,
0,
0,
SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE);
theStyle &= ~CBS_DROPDOWN ;//去掉DROPDOWN
theStyle |= CBS_DROPDOWNLIST ; //添加DROPDOWNLIST
::DestroyWindow(theChild);
SetWindowLong(GetDlgItem(IDC_COMBO_BRANCHCODE)->m_hWnd, GWL_STYLE , theStyle);
::SetWindowPos(GetDlgItem(IDC_COMBO_BRANCHCODE)->m_hWnd,//使SetWindowLong生效
NULL,
0,
0,
0,
0,
SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE);
return 1;
}
return -1;
}