class CKlant
{
public:
CKlant();
CKlant(CString naam, CString adres, CString plaats, CString tlnr);
virtual ~CKlant();
private:
CString cnaam;
CString cplaats;
CString cadres;
CString ctlnr;
public:
CString getNaam();
void setNaam(CString naam);
};
#include "stdafx.h"
#include "KlantenLijst.h"
#include "Klant.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CKlant::CKlant()
{
cnaam = "";
cadres = "";
cplaats = "";
ctlnr="";
}
CKlant::CKlant(CString naam, CString adres, CString plaats, CString tlnr)
{
cnaam = naam;
cadres = adres;
cplaats = plaats;
ctlnr=tlnr;
}
CKlant::~CKlant()
{
}
CString CKlant::getNaam()
{
return cnaam;
}
void CKlant::setNaam(CString naam)
{
cnaam = naam;
}
// KlantenLijstDlg.h : header file
//
#if !defined(AFX_KLANTENLIJSTDLG_H__55D4DDF1_B28B_4E60_A000_F24DFC324BD6__INCLUDED_)
#define AFX_KLANTENLIJSTDLG_H__55D4DDF1_B28B_4E60_A000_F24DFC324BD6__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/////////////////////////////////////////////////////////////////////////////
// CKlantenLijstDlg dialog
class CKlantenLijstDlg : public CDialog
{
// Construction
public:
CKlantenLijstDlg(CWnd* pParent = NULL); // standard constructor
//CArray<Klant,Klant&> klantLijst;
// Dialog Data
//{{AFX_DATA(CKlantenLijstDlg)
enum { IDD = IDD_KLANTENLIJST_DIALOG };
CListBox m_lijst;
CString m_naam;
CString m_plaats;
CString m_tlnr;
CString m_adres;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CKlantenLijstDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CKlantenLijstDlg)
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnToevoegen();
afx_msg void OnSelchangeLijst();
afx_msg void OnLeeg();
afx_msg void OnVerwijderen();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_KLANTENLIJSTDLG_H__55D4DDF1_B28B_4E60_A000_F24DFC324BD6__INCLUDED_)
// KlantenLijstDlg.cpp : implementation file
//
#include "stdafx.h"
#include "KlantenLijst.h"
#include "KlantenLijstDlg.h"
#include "Klant.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CKlantenLijstDlg dialog
CKlantenLijstDlg::CKlantenLijstDlg(CWnd* pParent /*=NULL*/)
: CDialog(CKlantenLijstDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CKlantenLijstDlg)
m_naam = _T("");
m_plaats = _T("");
m_tlnr = _T("");
m_adres = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CKlantenLijstDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CKlantenLijstDlg)
DDX_Control(pDX, IDC_LIJST, m_lijst);
DDX_Text(pDX, IDC_NAAM, m_naam);
DDV_MaxChars(pDX, m_naam, 100);
DDX_Text(pDX, IDC_PLAATS, m_plaats);
DDV_MaxChars(pDX, m_plaats, 100);
DDX_Text(pDX, IDC_TLNR, m_tlnr);
DDV_MaxChars(pDX, m_tlnr, 10);
DDX_Text(pDX, IDC_ADRES, m_adres);
DDV_MaxChars(pDX, m_adres, 100);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CKlantenLijstDlg, CDialog)
//{{AFX_MSG_MAP(CKlantenLijstDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_TOEVOEGEN, OnToevoegen)
ON_LBN_SELCHANGE(IDC_LIJST, OnSelchangeLijst)
ON_BN_CLICKED(IDC_LEEG, OnLeeg)
ON_BN_CLICKED(IDC_VERWIJDEREN, OnVerwijderen)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CKlantenLijstDlg message handlers
BOOL CKlantenLijstDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CKlantenLijstDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CKlantenLijstDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CKlantenLijstDlg::OnToevoegen()
{
UpdateData();
CKlant naw(m_naam,m_adres,m_plaats,m_tlnr);
m_lijst.AddString(naw.getNaam());
m_naam="";
UpdateData(FALSE);
Invalidate();
}
void CKlantenLijstDlg::OnSelchangeLijst()
{
m_lijst.GetText(m_lijst.GetCurSel(), m_naam);
UpdateData(FALSE);
}
void CKlantenLijstDlg::OnLeeg()
{
int result = AfxMessageBox ("Wilt u alles verwijderen?", MB_YESNO|MB_ICONQUESTION);
if(result == IDYES)
{
m_lijst.ResetContent();
}
}
void CKlantenLijstDlg::OnVerwijderen()
{
int index = m_lijst.GetCurSel();
if (index != LB_ERR)
{
m_lijst.DeleteString(index);
}
else
{
AfxMessageBox ("Selecteer een klant in de lijst en daarna druk op 'Verwijderen'!",MB_ICONINFORMATION|MB_OK);
}
}