I have a modal dialog displaying a calendar. I want the dialog to cancel if the user clicks out side of the dialog. I have tried using SetCapture() in the dialogs OnInitDialog() but it mucks things up with the controls on the dialog no longer working. Has any one got any ideas how to achieve this. thanks
I'm not 100% clear on your arrangement but the ideal approach seems to be for the dialog to cancel when it loses focus. One problem with implementing this is that the dialog itself won't have focus, a child control will. So you'd need to see how well this approach could be adapted to your particular situation. -- Jonathan Wood SoftCircuits http://www.softcircuits.com Available for consulting: http://www.softcircuits.com/jwood/resume.htm "David Price" <davidp@start-global.com> wrote in message news:OfSqh6V$EHA.3988@TK2MSFTNGP11.phx.gbl... > I have a modal dialog displaying a calendar. I want the dialog to cancel if > the user clicks out side of the dialog. > > I have tried using SetCapture() in the dialogs OnInitDialog() but it mucks > things up with the controls on the dialog no longer working. > > Has any one got any ideas how to achieve this. > > thanks > > >
This sounds odd but you can achieve this by have process wide mouse hook (SetWindowsHookEx). -- Ajay Kalra [MVP - VC++] ajaykalra@yahoo.com "David Price" <davidp@start-global.com> wrote in message news:OfSqh6V$EHA.3988@TK2MSFTNGP11.phx.gbl... > I have a modal dialog displaying a calendar. I want the dialog to cancel if > the user clicks out side of the dialog. > > I have tried using SetCapture() in the dialogs OnInitDialog() but it mucks > things up with the controls on the dialog no longer working. > > Has any one got any ideas how to achieve this. > > thanks > > >