/[H7]/trunk/Client/ClientDlg.cpp
ViewVC logotype

Diff of /trunk/Client/ClientDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 11 by kevin, Mon Jan 29 15:07:29 2007 UTC revision 12 by kevin, Mon Jan 29 20:10:02 2007 UTC
# Line 10  Line 10 
10  #define new DEBUG_NEW  #define new DEBUG_NEW
11  #endif  #endif
12    
13            
14    CString Ip;
15    unsigned long Port;
16    
17  // CAboutDlg dialog used for App About  // CAboutDlg dialog used for App About
18    
# Line 45  END_MESSAGE_MAP() Line 48  END_MESSAGE_MAP()
48  // CClientDlg dialog  // CClientDlg dialog
49    
50    
   
51  CClientDlg::CClientDlg(CWnd* pParent /*=NULL*/)  CClientDlg::CClientDlg(CWnd* pParent /*=NULL*/)
52          : CDialog(CClientDlg::IDD, pParent)          : CDialog(CClientDlg::IDD, pParent)
53  {  {
# Line 116  BOOL CClientDlg::OnInitDialog() Line 118  BOOL CClientDlg::OnInitDialog()
118                    
119          // Get data from regedit          // Get data from regedit
120          CString strip, strport;          CString strip, strport;
121          char Ip[16];          char chaip[16];
         char Port[6];  
122          CRegKey reg;          CRegKey reg;
123          unsigned long size = 16;          unsigned long size = 16;
124          LONG res=reg.Open(HKEY_LOCAL_MACHINE, "SOFTWARE\\Projekt\\Client",KEY_READ);          LONG res=reg.Open(HKEY_LOCAL_MACHINE, "SOFTWARE\\Projekt\\Client",KEY_READ);
125    
126          if (res == ERROR_SUCCESS)          if (res == ERROR_SUCCESS)
127          {          {
128                  res=reg.QueryStringValue("IP", Ip,&size);                  res=reg.QueryStringValue("IP", chaip, &size);
129          }          }
130            Ip = chaip;
131          m_ip.SetWindowText(Ip);          m_ip.SetWindowText(Ip);
132          LONG res2=reg.Open(HKEY_LOCAL_MACHINE, "SOFTWARE\\Projekt\\Client",KEY_READ);          LONG res2=reg.Open(HKEY_LOCAL_MACHINE, "SOFTWARE\\Projekt\\Client",KEY_READ);
133    
134          if (res2 == ERROR_SUCCESS)          if (res2 == ERROR_SUCCESS)
135          {          {
136                  res2=reg.QueryStringValue("Port", Port,&size);                  res2=reg.QueryDWORDValue("Port", Port);
137          }          }
138          m_port.SetWindowText(Port);          strport.Format("%d",Port);
139            m_port.SetWindowText(strport);
140          reg.Close();          reg.Close();
141                    
142          //connect til server          //connect til server
143  //      Start();  
144                                    
145          return TRUE;  // return TRUE  unless you set the focus to a control          return TRUE;  // return TRUE  unless you set the focus to a control
146  }  }
# Line 194  HCURSOR CClientDlg::OnQueryDragIcon() Line 197  HCURSOR CClientDlg::OnQueryDragIcon()
197    
198  ClientSocket    sockClient;  ClientSocket    sockClient;
199  CString strIp, strPort;  CString strIp, strPort;
 UINT Portuint;  
200    
201  /*Clientsocket class used for client socket connections*/  /*Clientsocket class used for client socket connections*/
202  void ClientSocket::OnReceive( int nErrorCode )  void ClientSocket::OnReceive( int nErrorCode )
# Line 231  void CClientDlg::OnBnClickedIpport() Line 233  void CClientDlg::OnBnClickedIpport()
233          reg.Create(HKEY_LOCAL_MACHINE, "SOFTWARE\\Projekt\\Client");          reg.Create(HKEY_LOCAL_MACHINE, "SOFTWARE\\Projekt\\Client");
234          reg.SetStringValue("IP",strIp);          reg.SetStringValue("IP",strIp);
235          reg.Create(HKEY_LOCAL_MACHINE, "SOFTWARE\\Projekt\\Client");          reg.Create(HKEY_LOCAL_MACHINE, "SOFTWARE\\Projekt\\Client");
236          reg.SetStringValue("Port",strPort);          reg.SetDWORDValue("Port",atoi(strPort));
237          reg.Close();          reg.Close();
238  }  }
239    
240  void ClientSocket::OnConnect(int nErrorCode)  void ClientSocket::OnConnect(int nErrorCode)
241  {  {
242          // TODO: Add your specialized code here and/or call the base class          // TODO: Add your specialized code here and/or call the base class
243          strPort.Format("%d",Portuint);          strPort.Format("%d",strPort);
244          sockClient.Connect(strIp,Portuint);          sockClient.Connect(strIp,Port);
245            sockClient.Send(strPort,strPort.GetLength(),0);
246            sockClient.Close();
247          CSocket::OnConnect(nErrorCode);          CSocket::OnConnect(nErrorCode);
248  }  }
249  void Start()  void Start()
250  {  {
251            strPort.Format("%d",Port);
252            sockClient.Connect(Ip,Port);
253            sockClient.Send(strPort,strPort.GetLength(),NULL);
254            sockClient.Close();
255  }  }
256  void CClientDlg::OnBnClickedConnect()  void CClientDlg::OnBnClickedConnect()
257  {  {

Legend:
Removed from v.11  
changed lines
  Added in v.12

  ViewVC Help
Powered by ViewVC 1.1.20