文本框有事件
GetDlgItemInt//得到文本框数值
SetDlgItemInt
GetDlgItemText//得到文本框文本
SetDlgItemText
滑块:
SendMessage( GetDlgItem( hDlg, IDC_SLIDER1 ), TBM_GETPOS, 0, 0 )//返回滑块值
SendMessage( GetDlgItem( hDlg, IDC_SLIDER1 ), TBM_SETRANGE, 0, MAKELONG(2, 6) );//滑块范围 2-6
Message( GetDlgItem( hDlg, IDC_SLIDER1 ), TBM_SETPOS, 1, k);//滑块初始值
上下按钮
LOWORD( SendMessage( GetDlgItem( hDlg, IDC_SPIN2 ), UDM_GETPOS, 0, 0 ) )返回上下按钮的值
SendMessage( GetDlgItem( hDlg, IDC_SPIN2 ), UDM_SETRANGE, 0, (LPARAM) MAKELONG( 30000, 8 ) )//设置上下按钮范围
SendMessage( GetDlgItem( hDlg, IDC_SPIN2 ), UDM_SETPOS, 0, (LPARAM) MAKELONG( k, 0) ); //设置上下按钮初始值
复选框有事件
CheckDlgButton(hDlg,IDC_CHECK1,k);//设置复选框
IsDlgButtonChecked(hDlg,IDC_CHECK1)//复选框是否被选中
下拉选项有事件
int nIndex = (int) SendMessage( GetDlgItem( hDlg, IDC_COMBO2 ), CB_ADDSTRING, 0, (LPARAM) str );添加选项
SendMessage( GetDlgItem( hDlg, IDC_COMBO2 ), CB_SETITEMDATA, nIndex, (LPARAM) str );//设置选项索引值
(DWORD) SendMessage( GetDlgItem( hDlg, IDC_PREDEF_COMBO ), CB_GETCURSEL, 0, 0 );//返回选项索引
SendMessage( GetDlgItem( hDlg, IDC_PREDEF_COMBO ), CB_RESETCONTENT, 0, 0 );//清除所有
SendMessage( hPreDefCombo, CB_SETCURSEL, k, 0 );//默认选项
EnableWindow( GetDlgItem( hDlg, IDC_EDIT2 ), b );//控件是否生效