/[H7]/trunk/H7 Server/H7 ServerDlg.cpp
ViewVC logotype

Annotation of /trunk/H7 Server/H7 ServerDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (hide annotations) (download)
Mon Jan 29 10:44:29 2007 UTC (17 years, 4 months ago) by hedin
File size: 4111 byte(s)
Added basic server structure
1 hedin 3 // H7 ServerDlg.cpp : implementation file
2     //
3    
4     #include "stdafx.h"
5     #include "H7 Server.h"
6     #include "H7 ServerDlg.h"
7     #include ".\h7 serverdlg.h"
8    
9     #ifdef _DEBUG
10     #define new DEBUG_NEW
11     #endif
12    
13    
14     // CAboutDlg dialog used for App About
15    
16     class CAboutDlg : public CDialog
17     {
18     public:
19     CAboutDlg();
20    
21     // Dialog Data
22     enum { IDD = IDD_ABOUTBOX };
23    
24     protected:
25     virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
26    
27     // Implementation
28     protected:
29     DECLARE_MESSAGE_MAP()
30     };
31    
32     CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
33     {
34     }
35    
36     void CAboutDlg::DoDataExchange(CDataExchange* pDX)
37     {
38     CDialog::DoDataExchange(pDX);
39     }
40    
41     BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
42     END_MESSAGE_MAP()
43    
44    
45     // CH7ServerDlg dialog
46    
47    
48    
49     CH7ServerDlg::CH7ServerDlg(CWnd* pParent /*=NULL*/)
50     : CDialog(CH7ServerDlg::IDD, pParent)
51     , m_Start(0)
52     {
53     m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
54     }
55    
56     void CH7ServerDlg::DoDataExchange(CDataExchange* pDX)
57     {
58     CDialog::DoDataExchange(pDX);
59     DDX_Control(pDX, IDC_STATUS, m_Status);
60     DDX_Control(pDX, IDC_BaudRate, m_BaudRate);
61     DDX_Control(pDX, IDC_SERIAL, m_Serial);
62     DDX_Control(pDX, IDC_STOP, m_Stop);
63     DDX_Control(pDX, IDC_PORT, m_Port);
64     DDX_Control(pDX, IDC_RESTART, m_Restart);
65     }
66    
67     BEGIN_MESSAGE_MAP(CH7ServerDlg, CDialog)
68     ON_WM_SYSCOMMAND()
69     ON_WM_PAINT()
70     ON_WM_QUERYDRAGICON()
71     //}}AFX_MSG_MAP
72     ON_BN_CLICKED(IDC_Start, OnBnClickedStart)
73     END_MESSAGE_MAP()
74    
75    
76     // CH7ServerDlg message handlers
77    
78     BOOL CH7ServerDlg::OnInitDialog()
79     {
80     CDialog::OnInitDialog();
81    
82     // Add "About..." menu item to system menu.
83    
84     // IDM_ABOUTBOX must be in the system command range.
85     ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
86     ASSERT(IDM_ABOUTBOX < 0xF000);
87    
88     CMenu* pSysMenu = GetSystemMenu(FALSE);
89     if (pSysMenu != NULL)
90     {
91     CString strAboutMenu;
92     strAboutMenu.LoadString(IDS_ABOUTBOX);
93     if (!strAboutMenu.IsEmpty())
94     {
95     pSysMenu->AppendMenu(MF_SEPARATOR);
96     pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
97     }
98     }
99    
100     // Set the icon for this dialog. The framework does this automatically
101     // when the application's main window is not a dialog
102     SetIcon(m_hIcon, TRUE); // Set big icon
103     SetIcon(m_hIcon, FALSE); // Set small icon
104    
105     /**********************************************************************/
106     // TODO: Add extra initialization here
107    
108    
109     /**********************************************************************/
110     return TRUE; // return TRUE unless you set the focus to a control
111     }
112    
113     void CH7ServerDlg::OnSysCommand(UINT nID, LPARAM lParam)
114     {
115     if ((nID & 0xFFF0) == IDM_ABOUTBOX)
116     {
117     CAboutDlg dlgAbout;
118     dlgAbout.DoModal();
119     }
120     else
121     {
122     CDialog::OnSysCommand(nID, lParam);
123     }
124     }
125    
126     // If you add a minimize button to your dialog, you will need the code below
127     // to draw the icon. For MFC applications using the document/view model,
128     // this is automatically done for you by the framework.
129    
130     void CH7ServerDlg::OnPaint()
131     {
132     if (IsIconic())
133     {
134     CPaintDC dc(this); // device context for painting
135    
136     SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
137    
138     // Center icon in client rectangle
139     int cxIcon = GetSystemMetrics(SM_CXICON);
140     int cyIcon = GetSystemMetrics(SM_CYICON);
141     CRect rect;
142     GetClientRect(&rect);
143     int x = (rect.Width() - cxIcon + 1) / 2;
144     int y = (rect.Height() - cyIcon + 1) / 2;
145    
146     // Draw the icon
147     dc.DrawIcon(x, y, m_hIcon);
148     }
149     else
150     {
151     CDialog::OnPaint();
152     }
153     }
154    
155     // The system calls this function to obtain the cursor to display while the user drags
156     // the minimized window.
157     HCURSOR CH7ServerDlg::OnQueryDragIcon()
158     {
159     return static_cast<HCURSOR>(m_hIcon);
160     }
161    
162     void CH7ServerDlg::OnBnClickedStart()
163     {
164     CString Port = NULL;
165     CString Tmp;
166     m_Port.GetWindowText(Port);
167     // CRegKey reg;
168     // reg.Create(HKEY_LOCAL_MACHINE, "SOFTWARE\\Projekt\\Server");
169    
170    
171     m_Status.SetWindowText(Port);
172     }
173    
174     /*CString CH7ServerDlg::SetTcpPort(CString Port)
175     {
176     CString Tmp;
177     m_Port.GetWindowText(Tmp);
178     // if( Tmp )
179     // Port = atoi(Tmp);
180     MessageBox(Port);
181    
182     return Port;
183     }
184     */

  ViewVC Help
Powered by ViewVC 1.1.20