1 // Written by Christopher E. Miller
2 // See the included license.txt for copyright and license details.
3 
4 
5 ///
6 module dfl.commondialog;
7 
8 private import dfl.control, dfl.internal.winapi, dfl.base, dfl.drawing,
9 	dfl.event;
10 private import dfl.application;
11 
12 public import dfl.filedialog, dfl.folderdialog, dfl.colordialog, dfl.fontdialog;
13 
14 
15 ///
16 abstract class CommonDialog // docmain
17 {
18 	///
19 	abstract void reset();
20 	
21 	///
22 	// Uses currently active window of the application as owner.
23 	abstract DialogResult showDialog();
24 	
25 	/// ditto
26 	abstract DialogResult showDialog(IWindow owner);
27 	
28 	
29 	///
30 	Event!(CommonDialog, HelpEventArgs) helpRequest;
31 	
32 	
33 	protected:
34 	
35 	///
36 	// See the CDN_* Windows notification messages.
37 	LRESULT hookProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
38 	{
39 		switch(msg)
40 		{
41 			case WM_NOTIFY:
42 				{
43 					NMHDR* nmhdr;
44 					nmhdr = cast(NMHDR*)lparam;
45 					switch(nmhdr.code)
46 					{
47 						case CDN_HELP:
48 							{
49 								Point pt;
50 								GetCursorPos(&pt.point);
51 								onHelpRequest(new HelpEventArgs(pt));
52 							}
53 							break;
54 						
55 						default:
56 					}
57 				}
58 				break;
59 			
60 			default:
61 		}
62 		
63 		return 0;
64 	}
65 	
66 	
67 	// TODO: implement.
68 	//LRESULT ownerWndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
69 	
70 	
71 	///
72 	void onHelpRequest(HelpEventArgs ea)
73 	{
74 		helpRequest(this, ea);
75 	}
76 	
77 	
78 	///
79 	abstract bool runDialog(HWND owner);
80 	
81 	
82 	package final void _cantrun()
83 	{
84 		throw new DflException("Error running dialog");
85 	}
86 }
87