1 |
// h6-udlånssystemDlg.cpp : implementation file
|
2 |
//
|
3 |
|
4 |
#include "stdafx.h"
|
5 |
#include "h6-udlånssystem.h"
|
6 |
#include "h6-udlånssystemDlg.h"
|
7 |
#include ".\h6-udlånssystemdlg.h"
|
8 |
|
9 |
#include "commonstorage.h"
|
10 |
#include "databaselayer.h"
|
11 |
|
12 |
#ifdef _DEBUG
|
13 |
#define new DEBUG_NEW
|
14 |
#endif
|
15 |
|
16 |
|
17 |
// CAboutDlg dialog used for App About
|
18 |
|
19 |
class CAboutDlg : public CDialog
|
20 |
{
|
21 |
public:
|
22 |
CAboutDlg();
|
23 |
|
24 |
// Dialog Data
|
25 |
enum { IDD = IDD_ABOUTBOX };
|
26 |
|
27 |
protected:
|
28 |
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
29 |
|
30 |
// Implementation
|
31 |
protected:
|
32 |
DECLARE_MESSAGE_MAP()
|
33 |
};
|
34 |
|
35 |
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
|
36 |
{
|
37 |
}
|
38 |
|
39 |
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
|
40 |
{
|
41 |
CDialog::DoDataExchange(pDX);
|
42 |
}
|
43 |
|
44 |
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
|
45 |
END_MESSAGE_MAP()
|
46 |
|
47 |
|
48 |
// Ch6udlnssystemDlg dialog
|
49 |
|
50 |
|
51 |
|
52 |
Ch6udlnssystemDlg::Ch6udlnssystemDlg(CWnd* pParent /*=NULL*/)
|
53 |
: CDialog(Ch6udlnssystemDlg::IDD, pParent)
|
54 |
{
|
55 |
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
56 |
}
|
57 |
|
58 |
void Ch6udlnssystemDlg::DoDataExchange(CDataExchange* pDX)
|
59 |
{
|
60 |
CDialog::DoDataExchange(pDX);
|
61 |
DDX_Control(pDX, IDC_TAB, m_tabs);
|
62 |
}
|
63 |
|
64 |
BEGIN_MESSAGE_MAP(Ch6udlnssystemDlg, CDialog)
|
65 |
ON_WM_SYSCOMMAND()
|
66 |
ON_WM_PAINT()
|
67 |
ON_WM_QUERYDRAGICON()
|
68 |
//}}AFX_MSG_MAP
|
69 |
ON_COMMAND(ID_HELP_ABOUT, OnHelpAbout)
|
70 |
ON_COMMAND(ID_FILE_EXIT, OnFileExit)
|
71 |
END_MESSAGE_MAP()
|
72 |
|
73 |
|
74 |
// Ch6udlnssystemDlg message handlers
|
75 |
|
76 |
BOOL Ch6udlnssystemDlg::OnInitDialog()
|
77 |
{
|
78 |
CDialog::OnInitDialog();
|
79 |
CWaitCursor wait;
|
80 |
|
81 |
// Add "About..." menu item to system menu.
|
82 |
|
83 |
// IDM_ABOUTBOX must be in the system command range.
|
84 |
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
|
85 |
ASSERT(IDM_ABOUTBOX < 0xF000);
|
86 |
|
87 |
CMenu* pSysMenu = GetSystemMenu(FALSE);
|
88 |
if (pSysMenu != NULL)
|
89 |
{
|
90 |
CString strAboutMenu;
|
91 |
strAboutMenu.LoadString(IDS_ABOUTBOX);
|
92 |
if (!strAboutMenu.IsEmpty())
|
93 |
{
|
94 |
pSysMenu->AppendMenu(MF_SEPARATOR);
|
95 |
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
|
96 |
}
|
97 |
}
|
98 |
|
99 |
// Set the icon for this dialog. The framework does this automatically
|
100 |
// when the application's main window is not a dialog
|
101 |
SetIcon(m_hIcon, TRUE); // Set big icon
|
102 |
SetIcon(m_hIcon, FALSE); // Set small icon
|
103 |
|
104 |
m_tabs.InsertItem(0,"Search");
|
105 |
m_tabs.InsertItem(1,"Result");
|
106 |
m_tabs.InsertItem(2,"Administration");
|
107 |
m_tabs.Init();
|
108 |
m_tabs.SetCurSel(0);
|
109 |
|
110 |
|
111 |
try {
|
112 |
DatabaseLayer *dbl = new DatabaseLayer;
|
113 |
CommonStorage::Instance()->setDBLayer(dbl);
|
114 |
} catch (...) {
|
115 |
MessageBox(CString("Could not establish connection to the database server\r\n") +
|
116 |
"Please contact your network administrator\r\n" +
|
117 |
"(This application shuts down automatically)");
|
118 |
OnOK();
|
119 |
}
|
120 |
|
121 |
|
122 |
// TODO: Add extra initialization here
|
123 |
|
124 |
return TRUE; // return TRUE unless you set the focus to a control
|
125 |
}
|
126 |
|
127 |
void Ch6udlnssystemDlg::OnSysCommand(UINT nID, LPARAM lParam)
|
128 |
{
|
129 |
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
|
130 |
{
|
131 |
CAboutDlg dlgAbout;
|
132 |
dlgAbout.DoModal();
|
133 |
}
|
134 |
else
|
135 |
{
|
136 |
CDialog::OnSysCommand(nID, lParam);
|
137 |
}
|
138 |
}
|
139 |
|
140 |
// If you add a minimize button to your dialog, you will need the code below
|
141 |
// to draw the icon. For MFC applications using the document/view model,
|
142 |
// this is automatically done for you by the framework.
|
143 |
|
144 |
void Ch6udlnssystemDlg::OnPaint()
|
145 |
{
|
146 |
if (IsIconic())
|
147 |
{
|
148 |
CPaintDC dc(this); // device context for painting
|
149 |
|
150 |
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
|
151 |
|
152 |
// Center icon in client rectangle
|
153 |
int cxIcon = GetSystemMetrics(SM_CXICON);
|
154 |
int cyIcon = GetSystemMetrics(SM_CYICON);
|
155 |
CRect rect;
|
156 |
GetClientRect(&rect);
|
157 |
int x = (rect.Width() - cxIcon + 1) / 2;
|
158 |
int y = (rect.Height() - cyIcon + 1) / 2;
|
159 |
|
160 |
// Draw the icon
|
161 |
dc.DrawIcon(x, y, m_hIcon);
|
162 |
}
|
163 |
else
|
164 |
{
|
165 |
CDialog::OnPaint();
|
166 |
}
|
167 |
}
|
168 |
|
169 |
// The system calls this function to obtain the cursor to display while the user drags
|
170 |
// the minimized window.
|
171 |
HCURSOR Ch6udlnssystemDlg::OnQueryDragIcon()
|
172 |
{
|
173 |
return static_cast<HCURSOR>(m_hIcon);
|
174 |
}
|
175 |
|
176 |
void Ch6udlnssystemDlg::OnHelpAbout()
|
177 |
{
|
178 |
MessageBox("DA6H :: Udlånssystem\r\nLavet af:\r\nKevin, Hedin & Torben");
|
179 |
}
|
180 |
|
181 |
void Ch6udlnssystemDlg::OnFileExit()
|
182 |
{
|
183 |
// TODO: Add your command handler code here
|
184 |
OnOK();
|
185 |
}
|