By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,050 Members | 1,564 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,050 IT Pros & Developers. It's quick & easy.

DateTimePicker Programatically Displaying Calendar

P: n/a
I'm trying to display the dropdown calendar on my DateTimePicker control
from another button on the form.
I've managed to do this using SendMessages as follows:

const Int32 WM_LBUTTONDOWN = 0x0201;
static extern IntPtr SendMessage(IntPtr hWnd, uint uMsg, Int32 wParam, Int32

Then in the OnClick event of my button:

Int32 x = this.dteExpiryDate.Width - 11;
Int32 y = this.dteExpiryDate.Height / 2;
Int32 lParam = x + y * 0x00010000;
SendMessage(dteExpiryDate.Handle,WM_LBUTTONDOWN,1, lParam);

This seems to work, but the problem is it gives the effect of the user
holding the mouse button down, so if they inadvertantly move the mouse
pointer over the arrow buttons of the Calendar, it changes the month
possibly without their intending to, not to mention it is non standard

I've tried to simulate the user releasing the button by adding:
const Int32 WM_LBUTTONDOWN = 0x0202;

at the top


SendMessage(dteExpiryDate.Handle,WM_LBUTTONUP,1,lP aram);

at the end of OnClick code.

But it doesn't work... The behaviour is still exactly the same.

Can anyone show me the error of my ways. Main problem is I have 'borrowed'
the code from somewhere else, and don't really understand the finer points
of SendMessage. Especially this lParam stuff above...

Any assistance greatly appreciated.


Oct 3 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.