// OPC KonfiguratorView.cpp : implementation of the COPCKonfiguratorView class // #include "stdafx.h" #include "OPC Konfigurator.h" #include "OPC KonfiguratorDoc.h" #include "OPC KonfiguratorView.h" #include "Group2.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // COPCKonfiguratorView IMPLEMENT_DYNCREATE(COPCKonfiguratorView, CFormView) BEGIN_MESSAGE_MAP(COPCKonfiguratorView, CFormView) //{{AFX_MSG_MAP(COPCKonfiguratorView) ON_NOTIFY(NM_DBLCLK, IDC_GROUP, OnDblclkGroup) ON_BN_CLICKED(IDC_KS, OnKs) ON_BN_CLICKED(IDC_M10, OnM10) ON_BN_CLICKED(IDC_PI, OnPi) ON_BN_CLICKED(IDC_SID, OnSid) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // COPCKonfiguratorView construction/destruction COPCKonfiguratorView::COPCKonfiguratorView() : CFormView(COPCKonfiguratorView::IDD) { //{{AFX_DATA_INIT(COPCKonfiguratorView) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT // TODO: add construction code here m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); m_bResize = FALSE; } COPCKonfiguratorView::~COPCKonfiguratorView() { } void COPCKonfiguratorView::DoDataExchange(CDataExchange* pDX) { CFormView::DoDataExchange(pDX); //{{AFX_DATA_MAP(COPCKonfiguratorView) DDX_Control(pDX, IDC_UNITS, m_txtUnits); DDX_Control(pDX, IDC_PROJEKTNAME, m_txtProjektname); DDX_Control(pDX, IDC_PROJECTNAME, m_txtProjectname); DDX_Control(pDX, IDC_LOAD, m_txtLoad); DDX_Control(pDX, IDC_LIFT, m_cobLift); DDX_Control(pDX, IDC_KOMMNUMMER, m_txtKommnummer); DDX_Control(pDX, IDC_GRUPPENNAME, m_txtGruppenname); DDX_Control(pDX, IDC_GRUPPENANZAHL, m_txtGruppenanzahl); DDX_Control(pDX, IDC_GROUPNUMBER, m_txtGroupnumber); DDX_Control(pDX, IDC_GROUPNAME, m_txtGroupname); DDX_Control(pDX, IDC_GROUPINFOS, m_btnGroupinfos); DDX_Control(pDX, IDC_GROUPEDIT, m_txtGroupedit); DDX_Control(pDX, IDC_GROUP, m_lcGroup); DDX_Control(pDX, IDC_DD, m_cbDD); DDX_Control(pDX, IDC_COMMNUMBER, m_txtCommnumber); DDX_Control(pDX, IDC_BUCHNUMMER, m_txtBuchnummer); DDX_Control(pDX, IDC_BOOKNUMBER, m_txtBooknumber); DDX_Control(pDX, IDC_KS, m_cbKs); DDX_Control(pDX, IDC_M10,m_cbM10); DDX_Control(pDX, IDC_PI, m_cbPi); DDX_Control(pDX, IDC_SID,m_cbSid); //}}AFX_DATA_MAP } BOOL COPCKonfiguratorView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CFormView::PreCreateWindow(cs); } void COPCKonfiguratorView::OnInitialUpdate() { CFormView::OnInitialUpdate(); ResizeParentToFit(); Initialization(); } ///////////////////////////////////////////////////////////////////////////// // COPCKonfiguratorView diagnostics #ifdef _DEBUG void COPCKonfiguratorView::AssertValid() const { CFormView::AssertValid(); } void COPCKonfiguratorView::Dump(CDumpContext& dc) const { CFormView::Dump(dc); } COPCKonfiguratorDoc* COPCKonfiguratorView::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(COPCKonfiguratorDoc))); return (COPCKonfiguratorDoc*)m_pDocument; } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // COPCKonfiguratorView message handlers void COPCKonfiguratorView::Initialization() { InitCtrl(); Resize(); // style of the list box item DWORD dwStyle = m_lcGroup.GetExtendedStyle(); m_lcGroup.SetExtendedStyle(dwStyle| LVS_EX_FULLROWSELECT| LVS_EX_GRIDLINES); } void COPCKonfiguratorView::InitCtrl() { // ListCtrl m_lcGroup.InsertColumn(0, "Name", LVCFMT_LEFT); m_lcGroup.InsertColumn(1, "CommPartner", LVCFMT_LEFT); m_lcGroup.InsertColumn(2, "ContrMode", LVCFMT_LEFT); m_lcGroup.InsertColumn(3, "Units", LVCFMT_LEFT); m_lcGroup.InsertColumn(4, "Load", LVCFMT_LEFT); m_lcGroup.InsertColumn(5, "Komm.Nr.", LVCFMT_LEFT); /////////////// } void COPCKonfiguratorView::UpdateList() { m_lcGroup.SetRedraw(FALSE); m_lcGroup.DeleteAllItems(); for(POSITION pos = m_oblComm.GetHeadPosition(); pos != NULL;) { COPC* pCom = (COPC*) m_oblComm.GetNext(pos); { int nItem = m_lcGroup.InsertItem(m_lcGroup.GetItemCount(), pCom->GetCommnumber()); m_lcGroup.SetItemText(nItem, 1, pCom->GetName()); m_lcGroup.SetItemText(nItem, 2, pCom->GetCommPartner()); m_lcGroup.SetItemText(nItem, 3, pCom->GetContrMode()); m_lcGroup.SetItemText(nItem, 4, pCom->GetUnits()); m_lcGroup.SetItemText(nItem, 5, pCom->GetLoad()); m_lcGroup.SetItemText(nItem, 6, pCom->GetKommNr()); m_lcGroup.SetItemData(nItem, (DWORD) pCom); } } m_lcGroup.SetRedraw(TRUE); m_lcGroup.Invalidate(); m_lcGroup.UpdateWindow(); } void COPCKonfiguratorView::RButton(CGroup* pGroup) { int nItem = m_lcGroup.GetSelectionMark(); if(nItem >= 0) { CString str; CGroup* pGroup = (CGroup*) m_lcGroup.GetItemData(nItem); if (m_cbPi .GetCheck() == BST_CHECKED && pGroup->GetContrMode() != CM_PI) pGroup->SetContrMode(CM_PI); else if (m_cbKs .GetCheck() == BST_CHECKED && pGroup->GetContrMode() != CM_KS) pGroup->SetContrMode(CM_KS); else if (m_cbM10.GetCheck() == BST_CHECKED && pGroup->GetContrMode() != CM_M10) pGroup->SetContrMode(CM_M10); else if (m_cbSid.GetCheck() == BST_CHECKED && pGroup->GetContrMode() != CM_SID) pGroup->SetContrMode(CM_SID); else pGroup->SetContrMode(CM_NONE); UpdateData(FALSE); } } void COPCKonfiguratorView::OnKs() { RButton(); } void COPCKonfiguratorView::OnM10(){ RButton(); } void COPCKonfiguratorView::OnPi() { RButton(); } void COPCKonfiguratorView::OnSid(){ RButton(); } void COPCKonfiguratorView::OnDD() { int nItem = m_lcGroup.GetSelectionMark(); if(nItem >= 0) { CString str; CGroup* pGroup = (CGroup*) m_lcGroup.GetItemData(nItem); if (m_cbDD.GetCheck() == BST_CHECKED && !pGroup->IsDD()) pGroup->SetDD(TRUE); else if (m_cbDD.GetCheck() == BST_UNCHECKED && pGroup->IsDD()) pGroup->SetDD(FALSE); UpdateData(TRUE); } } void COPCKonfiguratorView::Resize() { m_bResize = TRUE; CRect rcDlg; GetClientRect(&rcDlg); const int nSpace = 5; const CSize szButton = CSize(120,20); const int nWidthScroll = ::GetSystemMetrics(SM_CXVSCROLL) + 4*::GetSystemMetrics(SM_CXBORDER); int nWidth = rcDlg.Width() - nSpace - szButton.cx; m_lcGroup.SetWindowPos(NULL, rcDlg.left+10, rcDlg.top + 150, nWidth -60, rcDlg.Height()-80, NULL); m_lcGroup.SetColumnWidth(0, nWidth - 3*80 - 2*60 - nWidthScroll); m_lcGroup.SetColumnWidth(1, 80); m_lcGroup.SetColumnWidth(2, 50); m_lcGroup.SetColumnWidth(3, 50); m_lcGroup.SetColumnWidth(4, 50); m_lcGroup.SetColumnWidth(5, 80); const CSize szButton1 = CSize((rcDlg.Width()-5*nSpace)/4, 20); int nWidth1 = 2*szButton1.cx + 1*nSpace; const int nRows[6] = { 1* nSpace + 0* szButton1.cy, 2* nSpace + 1* szButton1.cy, 3* nSpace + 2* szButton1.cy, 4* nSpace + 3* szButton1.cy, 5* nSpace + 4* szButton1.cy, 6* nSpace + 5* szButton1.cy }; const int nCols[4] = { 1* nSpace + 0* szButton1.cx, 2* nSpace + 1* szButton1.cx, 3* nSpace + 2* szButton1.cx, 4* nSpace + 3* szButton1.cx }; //Alle Elemente in der Group Box Filter m_txtKommnummer.SetWindowPos(NULL, nCols[0], nRows[0], szButton1.cx, szButton1.cy, NULL); m_txtCommnumber.SetWindowPos(NULL, nCols[1], nRows[0], nWidth1, szButton.cy, NULL); m_txtBuchnummer.SetWindowPos(NULL, nCols[0], nRows[1], szButton1.cx, szButton1.cy, NULL); m_txtBooknumber.SetWindowPos(&m_txtCommnumber, nCols[1], nRows[1], nWidth1, szButton.cy, NULL); m_txtProjektname.SetWindowPos(NULL, nCols[0], nRows[2], szButton1.cx, szButton1.cy, NULL); m_txtProjectname.SetWindowPos(&m_txtBooknumber, nCols[1], nRows[2], nWidth1, szButton1.cy, NULL); m_txtGruppenname.SetWindowPos(NULL, nCols[0], nRows[3], szButton1.cx, szButton1.cy, NULL); m_txtGroupname.SetWindowPos(&m_txtProjektname, nCols[1], nRows[3], nWidth1, szButton.cy, NULL); m_txtGruppenanzahl.SetWindowPos(NULL, nCols[0], nRows[4], szButton.cx, szButton.cy, NULL); m_txtGroupnumber.SetWindowPos(&m_txtGroupname, nCols[1], nRows[4], nWidth1, szButton.cy, NULL); m_btnGroupinfos.SetWindowPos(NULL,5,130,rcDlg.Width()-2*10,rcDlg.Height()-110, SWP_NOSIZE|SWP_NOZORDER); m_txtGroupedit .SetWindowPos(&m_lcGroup, nWidth + nSpace-40, 150, szButton.cx, szButton.cy, NULL); m_cobLift .SetWindowPos(&m_txtGroupedit, nWidth + nSpace-40, 7*(szButton.cy+nSpace), szButton.cx, szButton.cy, NULL); m_cbPi .SetWindowPos(&m_cobLift, nWidth + nSpace-40, 8*(szButton.cy+nSpace) -0*nSpace, szButton.cx, szButton.cy, NULL); m_cbKs .SetWindowPos(&m_cbPi, nWidth + nSpace-40, 9*(szButton.cy+nSpace) -1*nSpace, szButton.cx, szButton.cy, NULL); m_cbM10 .SetWindowPos(&m_cbKs, nWidth + nSpace-40, 10*(szButton.cy+nSpace) -2*nSpace, szButton.cx, szButton.cy, NULL); m_cbSid .SetWindowPos(&m_cbM10, nWidth + nSpace-40, 11*(szButton.cy+nSpace) -3*nSpace, szButton.cx, szButton.cy, NULL); m_cbDD .SetWindowPos(&m_cbSid, nWidth + nSpace-40, 12*(szButton.cy+nSpace) +nSpace, szButton.cx, szButton.cy, NULL); m_txtUnits .SetWindowPos(&m_cbDD, nWidth + nSpace-40, 13*(szButton.cy+nSpace) +nSpace, szButton.cx, szButton.cy, NULL); m_txtLoad .SetWindowPos(&m_txtUnits, nWidth + nSpace-40, 14*(szButton.cy+nSpace) +nSpace, szButton.cx, szButton.cy, NULL); } void COPCKonfiguratorView::OnSize(UINT nType, int cx, int cy) { CFormView::OnSize(nType, cx, cy); if(m_bResize) Resize(); } void COPCKonfiguratorView::OnDblclkGroup(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here *pResult = 0; }