| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- /*
- ** Command & Conquer Generals(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /***********************************************************************************************
- *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
- ***********************************************************************************************
- * *
- * Project Name : G *
- * *
- * $Archive:: /Commando/Code/Tools/max2w3d/ExportAllDlg.cpp $*
- * *
- * $Author:: Andre_a $*
- * *
- * $Modtime:: 10/15/99 4:25p $*
- * *
- * $Revision:: 2 $*
- * *
- *---------------------------------------------------------------------------------------------*
- * Functions: *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- // ExportAllDlg.cpp : implementation file
- //
- #include "ExportAllDlg.h"
- #include <Max.h>
- #include <assert.h>
- #include <shlobj.h> // SHBrowseForFolder
- static BOOL CALLBACK _thunk_dialog_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
- /////////////////////////////////////////////////////////////////////////////
- // ExportAllDlg dialog
- ExportAllDlg::ExportAllDlg (Interface *max_interface)
- {
- m_Directory[0] = '\0';
- m_Recursive = TRUE;
- m_hWnd = NULL;
- assert(max_interface != NULL);
- m_MaxInterface = max_interface;
- }
- /////////////////////////////////////////////////////////////////////////////
- // ExportAllDlg Methods
- int ExportAllDlg::DoModal (void)
- {
- // Put up the dialog box.
- BOOL result = DialogBoxParam(AppInstance, MAKEINTRESOURCE(IDD_EXPORT_ALL),
- m_MaxInterface->GetMAXHWnd(), (DLGPROC)_thunk_dialog_proc,
- (LPARAM)this);
- // Return IDOK if the user accepted the new settings.
- return (result == 1) ? IDOK : IDCANCEL;
- }
- /////////////////////////////////////////////////////////////////////////////
- // ExportAllDlg DialogProc
- BOOL CALLBACK _thunk_dialog_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- static ExportAllDlg *dialog = NULL;
- if (uMsg == WM_INITDIALOG)
- {
- dialog = (ExportAllDlg*)lParam;
- dialog->m_hWnd = hWnd;
- }
- if (dialog)
- return dialog->DialogProc(hWnd, uMsg, wParam, lParam);
- else
- return 0;
- }
- BOOL CALLBACK ExportAllDlg::DialogProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- int code = HIWORD(wParam);
- switch (uMsg)
- {
- /*******************************************************************
- * WM_INITDIALOG
- *
- * Initialize all of the custom controls for the dialog box
- *
- *******************************************************************/
- case WM_INITDIALOG:
- OnInitDialog();
- return TRUE;
- /*******************************************************************
- * WM_COMMAND
- *
- *
- *******************************************************************/
- case WM_COMMAND:
- switch (LOWORD(wParam))
- {
- case IDOK:
- if (OnOK() == FALSE)
- return TRUE;
- SetCursor(LoadCursor(NULL, IDC_WAIT));
- EndDialog(m_hWnd, 1);
- break;
- case IDCANCEL:
- EndDialog(m_hWnd, 0);
- break;
- case IDC_BROWSE:
- OnBrowse();
- return FALSE;
- }
- return TRUE;
- }
- return FALSE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // ExportAllDlg message handlers
- void ExportAllDlg::OnInitDialog (void)
- {
- CenterWindow(m_hWnd, m_MaxInterface->GetMAXHWnd());
- SetCursor(LoadCursor(NULL, IDC_ARROW));
- // Set the check box state.
- CheckDlgButton(m_hWnd, IDC_RECURSIVE, m_Recursive);
- // Set the default directory.
- HWND edit = GetDlgItem(m_hWnd, IDC_DIRECTORY);
- assert(edit != NULL);
- SetWindowText(edit, m_Directory);
- }
- void ExportAllDlg::OnBrowse()
- {
- char folder_name[MAX_PATH];
- BROWSEINFO bi;
- ZeroMemory(&bi, sizeof(bi));
- bi.hwndOwner = m_hWnd;
- bi.pszDisplayName = folder_name;
- bi.lpszTitle = "Select a folder for export...";
- bi.ulFlags = BIF_RETURNONLYFSDIRS;
- // Browse for a folder.
- LPITEMIDLIST il = SHBrowseForFolder(&bi);
- if (il)
- {
- // Get the path of the folder.
- if (SHGetPathFromIDList(il, folder_name))
- {
- HWND edit = GetDlgItem(m_hWnd, IDC_DIRECTORY);
- assert(edit != NULL);
- SetWindowText(edit, folder_name);
- }
- else
- MessageBox(m_hWnd, "Error getting pathname with SHGetPathFromIDList()",
- "Error", MB_OK | MB_ICONSTOP);
- }
- }
- BOOL ExportAllDlg::OnOK (void)
- {
- // Get the directory chosen by the user. If none is entered,
- // freak on the user.
- char dir[_MAX_PATH];
- HWND edit = GetDlgItem(m_hWnd, IDC_DIRECTORY);
- assert(edit != NULL);
- if (GetWindowText(edit, dir, sizeof(dir)) == 0)
- {
- // The edit box is empty, that's not a valid choice.
- MessageBox(m_hWnd, "You must choose a directory to export",
- "Invalid Directory", MB_OK);
- SetFocus(edit);
- return FALSE;
- }
- // TODO: Validate the directory as one that actually exists.
- // Store the values from the dialog in our class members.
- strcpy(m_Directory, dir);
- m_Recursive = (IsDlgButtonChecked(m_hWnd, IDC_RECURSIVE) == BST_CHECKED) ? TRUE : FALSE;
- return TRUE;
- }
|