/[H6]/h6-udlånssystemDlg.cpp
ViewVC logotype

Annotation of /h6-udlånssystemDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.20