1 // $Id: rundialog.cpp,v 1.1 2002/05/29 22:06:50 nedko Exp $
4 // Copyright (C) 2000,2001,2002 Nedko Arnaudov <nedko@users.sourceforge.net>
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "RunDialog.h"
25 CRunDialog::CRunDialog(const char *pszDefault
)
27 strcpy(m_FilenameBuffer
,pszDefault
);
30 m_pMRU
= new CMRUList(RUN_MRU_MAX
, RUN_MRU_KEY
, hr
);
38 CRunDialog::~CRunDialog()
42 const char * CRunDialog::DoModal(HWND hwnd
)
44 if (DialogBoxParam(_Module
.GetModuleInstance(),MAKEINTRESOURCE(IDD_DIALOG_RUN
),hwnd
,DialogProc
,(LPARAM
)this) == IDOK
)
45 return m_FilenameBuffer
;
50 int __stdcall
CRunDialog::DialogProc(HWND hwndDlg
, UINT nMsg
, WPARAM wParam
, LPARAM lParam
)
52 CRunDialog
*pThis
= (CRunDialog
*)GetWindowLong(hwndDlg
,GWL_USERDATA
);
57 SetForegroundWindow(hwndDlg
);
58 pThis
= (CRunDialog
*)lParam
;
59 SetWindowLong(hwndDlg
,GWL_USERDATA
,(LPARAM
)pThis
);
60 HWND hwndCombo
= GetDlgItem(hwndDlg
,IDC_COMBO_COMMAND
);
61 if (hwndCombo
&& pThis
->m_pMRU
)
63 for (unsigned int i
= 0; i
< pThis
->m_pMRU
->GetCount(); i
++)
64 SendMessage(hwndCombo
,CB_INSERTSTRING
,-1,(LPARAM
)pThis
->m_pMRU
->GetEntry(i
));
66 SendMessage(hwndCombo
,CB_SETCURSEL
,0,0);
67 SendMessage(hwndCombo
,CB_SETDROPPEDWIDTH
,600,0);
71 switch(LOWORD(wParam
))
73 case IDC_BUTTON_BROWSE
:
76 ofn
.lStructSize
= sizeof(OPENFILENAME
);
77 ofn
.hwndOwner
= hwndDlg
;
79 ofn
.lpstrFilter
= "Executable Files (*.exe;*.com;*.bat)\0*.exe;*.com;*.bat\0All Files (*.*)\0*.*\0";
80 ofn
.lpstrCustomFilter
= NULL
;
81 ofn
.nMaxCustFilter
= 0;
83 pThis
->m_FilenameBuffer
[0] = 0;
84 ofn
.lpstrFile
= pThis
->m_FilenameBuffer
;
85 ofn
.nMaxFile
= MAX_FILENAME_SIZE
;
86 ofn
.lpstrFileTitle
= NULL
;
87 ofn
.nMaxFileTitle
= 0;
88 ofn
.lpstrInitialDir
= NULL
;
89 ofn
.lpstrTitle
= "Please select file to run";
90 ofn
.Flags
= OFN_FILEMUSTEXIST
|OFN_HIDEREADONLY
|OFN_PATHMUSTEXIST
;
92 ofn
.nFileExtension
= 0;
93 ofn
.lpstrDefExt
= NULL
;
94 ofn
.lCustData
= (LPARAM
)pThis
;
96 ofn
.lpTemplateName
= NULL
;
97 #if (_WIN32_WINNT >= 0x0500)
98 ofn
.pvReserved
= NULL
;
102 if (GetOpenFileName(&ofn
))
103 SetWindowText(GetDlgItem(hwndDlg
,IDC_COMBO_COMMAND
),pThis
->m_FilenameBuffer
);
107 if (!GetWindowText(GetDlgItem(hwndDlg
,IDC_COMBO_COMMAND
),pThis
->m_FilenameBuffer
,MAX_FILENAME_SIZE
))
109 strcpy(pThis
->m_FilenameBuffer
,"cmd");
111 else if (pThis
->m_pMRU
)
113 VERIFY(SUCCEEDED(pThis
->m_pMRU
->Add(pThis
->m_FilenameBuffer
)));
116 EndDialog(hwndDlg
,LOWORD(wParam
));