https://www.cnblogs.com/gaodu2003/archive/2009/08/10/1543115.html
方法一:
SendMessage(DateTimePicker1.Handle, WM_LBUTTONDOWN, MK_LBUTTON, 7);后面的"7",是DateTimePicker1右侧按钮位置[注: 此时DateTimePicker1的宽度为12],也可以将上面的值改为
DateTimePicker1.Width-5,即
SendMessage(DateTimePicker1.Handle, WM_LBUTTONDOWN, MK_LBUTTON, DateTimePicker1.Width-5);
[注: "5"处的取值范围为5~20,DateTimePick1的宽度为20以上时]
方法二:
在上面的方法中,会出现一个无法避免的问题,即窗口弹出后,按键状态会保持按下状态[即使你的鼠标按键没有处于按下状态],当鼠标处于窗口的按钮位置时,会使窗口内容自动滚动,使用此方法,则不会出现上面的问题
DateTimePicker1.SetFocus;
keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), 0 , 0 );
keybd_event(VK_DOWN, MapVirtualKey(VK_DOWN, 0), 0 , 0 );
keybd_event(VK_DOWN, MapVirtualKey(VK_DOWN, 0), KEYEVENTF_KEYUP , 0 );
keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), KEYEVENTF_KEYUP , 0 );
即使DateTimePicker1获得焦点后,按ALT+↓组合键,实现窗口弹出功能