// FSDlg.cpp : implementation file // #include "stdafx.h" #include "cldprn32.h" #include "FSDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif #define CREATE_TITLE TEXT("Create Film Session") #define UPDATE_TITLE TEXT("Update Film Session") #define CREATE_LABEL TEXT("&Create") #define UPDATE_LABEL TEXT("&Update") ///////////////////////////////////////////////////////////////////////////// // CFilmSessionDlg dialog CFilmSessionDlg::CFilmSessionDlg(CWnd* pParent /*=NULL*/) : CDialog(CFilmSessionDlg::IDD, pParent), m_bCreationMode(TRUE), m_bGrayscalePrintManagement(TRUE), m_iNumberOfCopies(-1), m_iMemoryAllocation(-1), m_bEnablePrintManagementCheckBox(TRUE), m_NumberOfCopiesChkBox(IDC_EDIT_NUMBEROFCOPIES), m_PrintPriorityChkBox(IDC_COMBO_PRINTPRIORITY), m_MediumTypeChkBox(IDC_COMBO_MEDIUMTYPE), m_FilmDestinationChkBox(IDC_COMBO_FILMDESTINATION), m_FilmSessionLabelChkBox(IDC_EDIT_FILMSESSIONLABEL), m_MemoryAllocationChkBox(IDC_EDIT_MEMORYALLOCATION), m_OwnerIDChkBox(IDC_EDIT_OWNERID) { //{{AFX_DATA_INIT(CFilmSessionDlg) //}}AFX_DATA_INIT } void CFilmSessionDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CFilmSessionDlg) DDX_Control(pDX, IDC_COMBO_FILMDESTINATION, m_FilmDestinationCombo); DDX_Control(pDX, IDC_COMBO_MEDIUMTYPE, m_MediumTypeCombo); DDX_Control(pDX, IDC_COMBO_PRINTPRIORITY, m_PrintPriorityCombo); DDX_Control(pDX, IDC_CHECK_OWNERID, m_OwnerIDChkBox); DDX_Control(pDX, IDC_CHECK_MEMORYALLOCATION, m_MemoryAllocationChkBox); DDX_Control(pDX, IDC_CHECK_FILMSESSIONLABEL, m_FilmSessionLabelChkBox); DDX_Control(pDX, IDC_CHECK_FILMDESTINATION, m_FilmDestinationChkBox); DDX_Control(pDX, IDC_CHECK_MEDIUMTYPE, m_MediumTypeChkBox); DDX_Control(pDX, IDC_CHECK_PRINTPRIORITY, m_PrintPriorityChkBox); DDX_Control(pDX, IDC_CHECK_NUMBEROFCOPIES, m_NumberOfCopiesChkBox); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CFilmSessionDlg, CDialog) //{{AFX_MSG_MAP(CFilmSessionDlg) ON_BN_CLICKED(IDC_BUTTON_CREATEUPDATE, OnButtonCreateUpdate) //}}AFX_MSG_MAP END_MESSAGE_MAP() void CFilmSessionDlg::SetDefaults() { // Number of Copies m_NumberOfCopiesChkBox.m_bChecked = TRUE; m_iNumberOfCopies = 1; // Print Priority m_PrintPriorityChkBox.m_bChecked = TRUE; m_sPrintPriority = TEXT("MED"); // Medium Type m_MediumTypeChkBox.m_bChecked = FALSE; m_sMediumType = TEXT(""); // Film Destination m_FilmDestinationChkBox.m_bChecked = FALSE; m_sFilmDestination = TEXT(""); // Film Session Label m_FilmSessionLabelChkBox.m_bChecked = FALSE; m_sFilmSessionLabel = TEXT(""); // Memory Allocation m_MemoryAllocationChkBox.m_bChecked = FALSE; m_iMemoryAllocation = -1; // Owner ID m_OwnerIDChkBox.m_bChecked = FALSE; m_sOwnerID = TEXT(""); } void CFilmSessionDlg::InitializeFields() { // Number of Copies if (m_iNumberOfCopies >= 0) { SetDlgItemInt(IDC_EDIT_NUMBEROFCOPIES, m_iNumberOfCopies, FALSE); } // Print Priority m_PrintPriorityCombo.AddString(TEXT("HIGH")); m_PrintPriorityCombo.AddString(TEXT("MED")); m_PrintPriorityCombo.AddString(TEXT("LOW")); m_PrintPriorityCombo.SetCurSel(0); m_PrintPriorityCombo.SelectString(-1, m_sPrintPriority); // Medium Type m_MediumTypeCombo.AddString(TEXT("PAPER")); m_MediumTypeCombo.AddString(TEXT("CLEAR FILM")); m_MediumTypeCombo.AddString(TEXT("BLUE FILM")); m_MediumTypeCombo.SetCurSel(0); m_MediumTypeCombo.SelectString(-1, m_sMediumType); // Film Destination m_FilmDestinationCombo.AddString(TEXT("MAGAZINE")); m_FilmDestinationCombo.AddString(TEXT("PROCESSOR")); m_FilmDestinationCombo.AddString(TEXT("BIN_1")); m_FilmDestinationCombo.SetCurSel(0); if (m_sFilmDestination.GetLength()) { m_FilmDestinationCombo.SetWindowText(m_sFilmDestination); } // Film Session Label SetDlgItemText(IDC_EDIT_FILMSESSIONLABEL, m_sFilmSessionLabel); // Memory Allocation if (m_iMemoryAllocation >= 0) { SetDlgItemInt(IDC_EDIT_MEMORYALLOCATION, m_iMemoryAllocation, FALSE); } // Owner ID SetDlgItemText(IDC_EDIT_OWNERID, m_sOwnerID); } ///////////////////////////////////////////////////////////////////////////// // CFilmSessionDlg message handlers BOOL CFilmSessionDlg::OnInitDialog() { CDialog::OnInitDialog(); SetWindowText(m_bCreationMode ? CREATE_TITLE : UPDATE_TITLE); SetDlgItemText(IDC_BUTTON_CREATEUPDATE, m_bCreationMode ? CREATE_LABEL : UPDATE_LABEL); // Initialize the "Color Print Management" check box CheckDlgButton(IDC_CHECK_COLORPRINT, m_bGrayscalePrintManagement ? BST_UNCHECKED : BST_CHECKED); GetDlgItem(IDC_CHECK_COLORPRINT)->EnableWindow(m_bCreationMode && m_bEnablePrintManagementCheckBox); m_NumberOfCopiesChkBox.Initialize(); m_PrintPriorityChkBox.Initialize(); m_MediumTypeChkBox.Initialize(); m_FilmDestinationChkBox.Initialize(); m_FilmSessionLabelChkBox.Initialize(); m_MemoryAllocationChkBox.Initialize(); m_OwnerIDChkBox.Initialize(); InitializeFields(); return TRUE; } void CFilmSessionDlg::OnButtonCreateUpdate() { m_bGrayscalePrintManagement = (IsDlgButtonChecked(IDC_CHECK_COLORPRINT) == 0); // If we are updating the Film Session, then at least one attribute must be specified if (!m_bCreationMode) { CAttribCheckBox* AttribCheckBoxes[] = { &m_NumberOfCopiesChkBox, &m_PrintPriorityChkBox, &m_MediumTypeChkBox, &m_FilmDestinationChkBox, &m_FilmSessionLabelChkBox, &m_MemoryAllocationChkBox, &m_OwnerIDChkBox }; int iCount = sizeof(AttribCheckBoxes) / sizeof(AttribCheckBoxes[0]); for (int i = 0; i < iCount; i++) { if (AttribCheckBoxes[i]->m_bChecked) break; } if (i >= iCount) { MessageBox(TEXT("Please specify at least one attribute to be updated."), TEXT("Print SCU"), MB_ICONEXCLAMATION); return; } } CString sValue; // Number of Copies GetDlgItemText(IDC_EDIT_NUMBEROFCOPIES, sValue); if (!m_NumberOfCopiesChkBox.m_bChecked && sValue.IsEmpty()) { m_iNumberOfCopies = -1; } else { m_iNumberOfCopies = atoi(sValue); } // Print Priority m_PrintPriorityCombo.GetWindowText(m_sPrintPriority); // Medium Type m_MediumTypeCombo.GetWindowText(m_sMediumType); // Film Destination m_FilmDestinationCombo.GetWindowText(m_sFilmDestination); // Film Session Label GetDlgItemText(IDC_EDIT_FILMSESSIONLABEL, m_sFilmSessionLabel); // Memory Allocation GetDlgItemText(IDC_EDIT_MEMORYALLOCATION, sValue); if (!m_MemoryAllocationChkBox.m_bChecked && sValue.IsEmpty()) { m_iMemoryAllocation = -1; } else { m_iMemoryAllocation = atoi(sValue); } // Owner ID GetDlgItemText(IDC_EDIT_OWNERID, m_sOwnerID); CDialog::OnOK(); } void CFilmSessionDlg::OnCancel() { m_NumberOfCopiesChkBox.m_bChecked = m_NumberOfCopiesChkBox.m_bInitiallyChecked; m_PrintPriorityChkBox.m_bChecked = m_PrintPriorityChkBox.m_bInitiallyChecked; m_MediumTypeChkBox.m_bChecked = m_MediumTypeChkBox.m_bInitiallyChecked; m_FilmDestinationChkBox.m_bChecked = m_FilmDestinationChkBox.m_bInitiallyChecked; m_FilmSessionLabelChkBox.m_bChecked = m_FilmSessionLabelChkBox.m_bInitiallyChecked; m_MemoryAllocationChkBox.m_bChecked = m_MemoryAllocationChkBox.m_bInitiallyChecked; m_OwnerIDChkBox.m_bChecked = m_OwnerIDChkBox.m_bInitiallyChecked; CDialog::OnCancel(); }