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 abstract void reset(); 19 20 21 // Uses currently active window of the application as owner. 22 abstract DialogResult showDialog(); 23 24 /// ditto 25 abstract DialogResult showDialog(IWindow owner); 26 27 28 29 Event!(CommonDialog, HelpEventArgs) helpRequest; 30 31 32 protected: 33 34 35 // See the CDN_* Windows notification messages. 36 LRESULT hookProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { 37 switch(msg) { 38 case WM_NOTIFY: { 39 NMHDR* nmhdr; 40 nmhdr = cast(NMHDR*)lparam; 41 switch(nmhdr.code) { 42 case CDN_HELP: { 43 Point pt; 44 GetCursorPos(&pt.point); 45 onHelpRequest(new HelpEventArgs(pt)); 46 } 47 break; 48 49 default: 50 } 51 } 52 break; 53 54 default: 55 } 56 57 return 0; 58 } 59 60 61 // TODO: implement. 62 //LRESULT ownerWndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) 63 64 65 66 void onHelpRequest(HelpEventArgs ea) { 67 helpRequest(this, ea); 68 } 69 70 71 72 abstract bool runDialog(HWND owner); 73 74 75 package final void _cantrun() { 76 throw new DflException("Error running dialog"); 77 } 78 } 79