Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close a Modal Dialog by clicking outside the Dialog

Status
Not open for further replies.

ashorton

Programmer
Mar 1, 2001
24
GB
I have a Modal Dialog Window. My problem is that I would like to simulate IDOK when the mouse is clicked outside of the Dialog.

Any idea's

Should I be using a modeless dialog? I have not used these before.
 
If it make sence, you couldn't do it directly with dialogs created with MessageBox...
If there are some dialogs obtained by
hDlg = CreateWindow/CreateDialog
then call
CloseWindow/DestroyWindow(hDlg); Ion Filipski
1c.bmp


filipski@excite.com
 
What I really need to know is: Is it possible to force a modal dialog that I have created by clicking the mouse outside of the dialog window. Similar to a popup window. The dialog class would have control so I would need to trap the mouse click from the dialog class.
 
Is possible to close any windows in the system by using CloseWindow, your problem is to get the handle to them. Ion Filipski
1c.bmp


filipski@excite.com
 
You should re-think you application. This is bad programming style. Anyway you might try by catching some WM_NC... windows message.

Try olso to put a call to CDialog::OnOK() in the WM_LOSTFOCUS event handler of your dialog window.

Hope this helps, s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
Yes, it is a bad atyle as Ionel said, but anyway you can get handle to a window from point with coords X, Y
POINT pt;
HWND xwnd;
pt.x = 10;
pt.y = 20;
///.....
xwnd = WindowFromPoint(pt);
...do something what do you want with xwnd Ion Filipski
1c.bmp


filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top