MAINFRM.H
上传用户:tjfeida
上传日期:2013-03-10
资源大小:1917k
文件大小:14k
源码类别:

Ftp客户端

开发平台:

Visual C++

  1. // MainFrm.h : interface of the CMainFrame class
  2. //
  3. /////////////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_MAINFRM_H__12BB9B69_5C23_4A93_8206_EAFAAA22E1E4__INCLUDED_)
  5. #define AFX_MAINFRM_H__12BB9B69_5C23_4A93_8206_EAFAAA22E1E4__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #ifndef __AFXEXT_H__
  10. #include <afxext.h>
  11. #endif
  12. #include <afxinet.h>
  13. enum
  14. {
  15. FILEICON,
  16. DIRECTORYICON,
  17. DIRECTORYSEL,
  18. LOCFILE,
  19. SERVFILE
  20. };
  21. class CDialDlg;
  22. class CMainFrame : public CFrameWnd
  23. {
  24. protected: // create from serialization only
  25. CMainFrame();
  26. DECLARE_DYNCREATE(CMainFrame)
  27. // Attributes
  28. public:
  29. CString GetFtpName();
  30. int GetFtpPort();
  31. CString GetFtpUser();
  32. CString GetFtpPassword();
  33. // Operations
  34. public:
  35. // Overrides
  36. // ClassWizard generated virtual function overrides
  37. //{{AFX_VIRTUAL(CMainFrame)
  38. virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  39. //}}AFX_VIRTUAL
  40. // Implementation
  41. public:
  42. virtual ~CMainFrame();
  43. #ifdef _DEBUG
  44. virtual void AssertValid() const;
  45. virtual void Dump(CDumpContext& dc) const;
  46. #endif
  47. protected:  // control bar embedded members
  48. CStatusBar  m_wndStatusBar;
  49. CToolBar    m_wndToolBar;
  50. // Generated message map functions
  51. protected:
  52. CSplitterWnd m_wndSplitter1;
  53. CSplitterWnd m_wndSplitter2;
  54. virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
  55. CDialogBar m_wndMyDialogBar;
  56. //{{AFX_MSG(CMainFrame)
  57. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  58. afx_msg void OnQuickconnect();
  59. afx_msg void OnFileDisconnect();
  60. afx_msg void OnUpdateFileDisconnect(CCmdUI* pCmdUI);
  61. afx_msg void OnFileReconnect();
  62. afx_msg void OnFileConnect();
  63. afx_msg void OnUpdateFileConnect(CCmdUI* pCmdUI);
  64. afx_msg void OnUpdateFileReconnect(CCmdUI* pCmdUI);
  65. afx_msg void OnFileStop();
  66. afx_msg void OnUpdateFileStop(CCmdUI* pCmdUI);
  67. afx_msg void OnUpdateFileSend(CCmdUI* pCmdUI);
  68. afx_msg void OnUpdateFileFtpDownload(CCmdUI* pCmdUI);
  69. //}}AFX_MSG
  70. DECLARE_MESSAGE_MAP()
  71. };
  72. /////////////////////////////////////////////////////////////////////////////
  73. class CFtpParaClass  
  74. {
  75. public:
  76. CFtpParaClass();
  77. protected:
  78. HCURSOR m_hDragCursor;
  79. BOOL m_bDragging;
  80. CImageList* m_pDragImageList;
  81. CImageList m_ctImageList;
  82. public:
  83. typedef struct
  84. {
  85. char szFileName[256];
  86. char szFileDate[20];
  87. char szFileSize[20];
  88. char szFilePath[MAX_PATH];
  89. int nType;
  90. }FILE_FTP_INFO;
  91. typedef struct
  92. {
  93. char fileName[256];
  94. UINT ufileFlag;
  95. }FILE_COUNT_INFO;
  96. typedef struct
  97. {
  98. char OldName[256];
  99. char NewName[256];
  100. LPVOID pThread;
  101. }FILE_CHANGE_INFO;
  102. typedef struct
  103. {
  104. FILE_COUNT_INFO* pCount;
  105. LPVOID pThread;
  106. }SEND_RECEIVE_INFO;
  107. protected:
  108. int OnInsertDir(CComboBoxEx* pCombo,CString& str,int iIcon,int iIconSel);
  109. void OnFileName(CListCtrl* pListCtrl);
  110. void SetPopMenu(int nIndex);
  111. void OnInsertFile(CListCtrl* pListCtrl,LPVOID pIn,LPARAM lParam);
  112. void GetFileIcon(CString& fileName,int* iIcon,int* iIconSel=NULL);
  113. BOOL SetImageList(CListCtrl* pListCtrl,CComboBoxEx* pCombo=NULL);
  114. void SetFileColumns(CListCtrl* pListCtrl);
  115. public:
  116. virtual ~CFtpParaClass();
  117. };
  118. /////////////////////////////////////////////////////////////////////////////
  119. // CLocFileView form view
  120. class CLocFileView : public CFormView ,public CFtpParaClass
  121. {
  122. protected:
  123. CLocFileView();           // protected constructor used by dynamic creation
  124. DECLARE_DYNCREATE(CLocFileView)
  125. // Form Data
  126. public:
  127. //{{AFX_DATA(CLocFileView)
  128. enum { IDD = IDD_LOC_FORMVIEW };
  129. CListCtrl m_ctLocFile;
  130. CComboBoxEx m_ctLocDir;
  131. //}}AFX_DATA
  132. // Attributes
  133. public:
  134. // Operations
  135. public:
  136. protected:
  137. CMainFrame* m_pMainFrame;
  138. BOOL m_bHaveDotFlag;
  139. CWinThread* m_pSendFileThread;
  140. CWinThread* m_pFindLocFileThread;
  141. int m_iDirCount;
  142. // Overrides
  143. // ClassWizard generated virtual function overrides
  144. //{{AFX_VIRTUAL(CLocFileView)
  145. public:
  146. virtual void OnInitialUpdate();
  147. virtual BOOL PreTranslateMessage(MSG* pMsg);
  148. protected:
  149. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  150. //}}AFX_VIRTUAL
  151. // Implementation
  152. protected:
  153. BOOL BeginPreSendFile(LPVOID pInfo);
  154. BOOL BeginSendFile(LPVOID pInfo);
  155. BOOL BeginFindLocFile(LPVOID pInfo);
  156. void GetLocDir();
  157. int InsertLocDir(CString& str,int iIcon,int iIconSel);
  158. virtual ~CLocFileView();
  159. #ifdef _DEBUG
  160. virtual void AssertValid() const;
  161. virtual void Dump(CDumpContext& dc) const;
  162. #endif
  163. // Generated message map functions
  164. //{{AFX_MSG(CLocFileView)
  165. afx_msg void OnDblclkLocFile(NMHDR* pNMHDR, LRESULT* pResult);
  166. afx_msg void OnSize(UINT nType, int cx, int cy);
  167. afx_msg void OnSelchangeLocDir();
  168. afx_msg void OnBegindragLocFile(NMHDR* pNMHDR, LRESULT* pResult);
  169. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  170. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  171. afx_msg void OnRclickLocFile(NMHDR* pNMHDR, LRESULT* pResult);
  172. afx_msg void OnBeginlabeleditLocFile(NMHDR* pNMHDR, LRESULT* pResult);
  173. afx_msg void OnEndlabeleditLocFile(NMHDR* pNMHDR, LRESULT* pResult);
  174. //}}AFX_MSG
  175. afx_msg LRESULT OnReDisplayLocFile(WPARAM wParam,LPARAM lParam);
  176. afx_msg LRESULT OnSetLocDirectoryDisplay(WPARAM wParam,LPARAM lParam);
  177. afx_msg LRESULT OnInsertLocFile(WPARAM wParam,LPARAM lParam);
  178. afx_msg LRESULT OnSetLocRedrawFlag(WPARAM wParam,LPARAM lParam);
  179. afx_msg LRESULT OnPreSendFile(WPARAM wParam,LPARAM lParam);
  180. afx_msg LRESULT OnSetLocDir(WPARAM wParam,LPARAM lParam);
  181. afx_msg void OnLocFileSend();
  182. afx_msg void OnLocFileDelete();
  183. afx_msg void OnLocFileReName();
  184. afx_msg void OnLocFileOpen();
  185. DECLARE_MESSAGE_MAP()
  186. };
  187. /////////////////////////////////////////////////////////////////////////////
  188. /////////////////////////////////////////////////////////////////////////////
  189. // CServFileView form view
  190. class CServFileView : public CFormView ,public CFtpParaClass
  191. {
  192. protected:
  193. CServFileView();           // protected constructor used by dynamic creation
  194. DECLARE_DYNCREATE(CServFileView)
  195. // Form Data
  196. public:
  197. void OnQuickConnect();
  198. BOOL BeginRenameFile(LPVOID pInfo);
  199. BOOL BeginReceiveFile(LPVOID pIn);
  200. BOOL BeginPreDeleteFile(LPVOID pInfo);
  201. BOOL BeginPreReceiveFile(LPVOID pInfo);
  202. BOOL BeginFindServFile(LPVOID pInfo);
  203. BOOL BeginDeleteFile(LPVOID pInfo);
  204. //{{AFX_DATA(CServFileView)
  205. enum { IDD = IDD_SERV_FORMVIEW };
  206. CButton m_ctBack;
  207. CListCtrl m_ctServFile;
  208. CComboBoxEx m_ctServDir;
  209. //}}AFX_DATA
  210. // Attributes
  211. public:
  212. // Operations
  213. public:
  214. protected:
  215. HBITMAP hBitmap;
  216. CMainFrame* m_pMainFrame;
  217. CImageList m_ctServImageList;
  218. CWinThread*m_pRenameFileThread;
  219. CWinThread* m_pDeleteFileThread;
  220. CWinThread* m_pReceiveFileThread;
  221. CWinThread* m_pFindServFileThread;
  222. BOOL m_bHaveDotFlag;
  223. // Overrides
  224. // ClassWizard generated virtual function overrides
  225. //{{AFX_VIRTUAL(CServFileView)
  226. public:
  227. virtual void OnInitialUpdate();
  228. virtual BOOL PreTranslateMessage(MSG* pMsg);
  229. protected:
  230. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  231. //}}AFX_VIRTUAL
  232. // Implementation
  233. protected:
  234. BOOL BeginPreSendFile(LPVOID pInfo);
  235. BOOL SetServImageList(UINT nBitmapID);
  236. virtual ~CServFileView();
  237. #ifdef _DEBUG
  238. virtual void AssertValid() const;
  239. virtual void Dump(CDumpContext& dc) const;
  240. #endif
  241. // Generated message map functions
  242. //{{AFX_MSG(CServFileView)
  243. afx_msg void OnSize(UINT nType, int cx, int cy);
  244. afx_msg void OnDblclkServFile(NMHDR* pNMHDR, LRESULT* pResult);
  245. afx_msg void OnBegindragServFile(NMHDR* pNMHDR, LRESULT* pResult);
  246. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  247. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  248. afx_msg void OnRclickServFile(NMHDR* pNMHDR, LRESULT* pResult);
  249. afx_msg void OnBeginlabeleditServFile(NMHDR* pNMHDR, LRESULT* pResult);
  250. afx_msg void OnEndlabeleditServFile(NMHDR* pNMHDR, LRESULT* pResult);
  251. afx_msg void OnBack();
  252. afx_msg void OnSelchangeServDir();
  253. //}}AFX_MSG
  254. afx_msg LRESULT OnPreDeleteFile(WPARAM wParam,LPARAM lParam);
  255. afx_msg LRESULT OnInsertServFile(WPARAM wParam,LPARAM lParam);
  256. afx_msg LRESULT OnSetServRedrawFlag(WPARAM wParam,LPARAM lParam);
  257. afx_msg LRESULT OnSetServDirectoryDisplay(WPARAM wParam,LPARAM lParam);
  258. afx_msg LRESULT OnReDisplayServFile(WPARAM wParam,LPARAM lParam);
  259. afx_msg LRESULT OnSetServDir(WPARAM wParam,LPARAM lParam);
  260. afx_msg LRESULT OnPreReceiveFile(WPARAM wParam,LPARAM lParam);
  261. afx_msg void OnServFileDownload();
  262. afx_msg void OnServFileDelete();
  263. afx_msg void OnServFileReName();
  264. afx_msg void OnServFileOpen();
  265. DECLARE_MESSAGE_MAP()
  266. };
  267. /////////////////////////////////////////////////////////////////////////////
  268. /////////////////////////////////////////////////////////////////////////////
  269. // CFtpInfoView view
  270. class CFtpInfoView : public CEditView
  271. {
  272. protected:
  273. CFtpInfoView();           // protected constructor used by dynamic creation
  274. DECLARE_DYNCREATE(CFtpInfoView)
  275. // Attributes
  276. public:
  277. // Operations
  278. public:
  279. // Overrides
  280. // ClassWizard generated virtual function overrides
  281. //{{AFX_VIRTUAL(CFtpInfoView)
  282. protected:
  283. virtual void OnDraw(CDC* pDC);      // overridden to draw this view
  284. //}}AFX_VIRTUAL
  285. // Implementation
  286. protected:
  287. CFont m_NewFont;
  288. virtual ~CFtpInfoView();
  289. #ifdef _DEBUG
  290. virtual void AssertValid() const;
  291. virtual void Dump(CDumpContext& dc) const;
  292. #endif
  293. // Generated message map functions
  294. protected:
  295. //{{AFX_MSG(CFtpInfoView)
  296. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  297. afx_msg void OnChange();
  298. afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  299. //}}AFX_MSG
  300. afx_msg LRESULT OnRecordFtpInfo(WPARAM wParam,LPARAM lParam);
  301. DECLARE_MESSAGE_MAP()
  302. };
  303. /////////////////////////////////////////////////////////////////////////////
  304. /////////////////////////////////////////////////////////////////////////////
  305. // CMyAppThread thread
  306. //#include <afxinet.h>
  307. class CMyAppThread : public CWinThread
  308. {
  309. DECLARE_DYNCREATE(CMyAppThread)
  310. public:
  311. protected:
  312. char* m_szAppName;
  313. CString m_szFtpName;
  314. CString m_szFtpUser;
  315. CString m_szFtpPassword;
  316. CString m_szFtpDirectory;
  317. CString m_szLocDirectory;
  318. int   m_nPort;
  319. int   m_nCount;
  320. HINTERNET hFtpConn;
  321. protected:
  322. public:
  323. CMyAppThread();           // protected constructor used by dynamic creation
  324. // Attributes
  325. public:
  326. CMyAppThread(const char* szLocDirectory,const char* szFtpName=NULL,const char* szFtpUser=NULL,
  327. const char* szFtpPassword=NULL,int nPort=21,const char* szFtpDirectory=NULL,BOOL bIsFtp=FALSE,int nCount=0)
  328. {
  329. extern HINTERNET hInetSession;
  330. hFtpConn=NULL;
  331. m_szLocDirectory=szLocDirectory;
  332. if(bIsFtp)
  333. {
  334. m_szFtpName=szFtpName;
  335. m_szFtpUser=szFtpUser;
  336. m_szFtpPassword=szFtpPassword;
  337. m_nPort=nPort;
  338. m_szFtpDirectory=szFtpDirectory;
  339. m_nCount=nCount;
  340. if(!(hFtpConn=InternetConnect(hInetSession,m_szFtpName,m_nPort,m_szFtpUser,
  341. m_szFtpPassword,INTERNET_SERVICE_FTP,INTERNET_FLAG_PASSIVE,0)))
  342. hFtpConn=NULL;
  343. }
  344. }
  345. public:
  346. static UINT StartPreDeleteFileThread(LPVOID lParam);
  347. static UINT StartPreReceiveFileThread(LPVOID lParam);
  348. static UINT StartPreSendFileThread(LPVOID lParam);
  349. static UINT StartRenameFileThread(LPVOID lParam);
  350. static UINT StartDeleteFileThread(LPVOID lParam);
  351. static UINT StartReceiveFileThread(LPVOID lParam);
  352. static UINT StartSendFileThread(LPVOID lParam);
  353. static UINT StartFindLocFileThread(LPVOID lParam);
  354. static UINT StartFindServFileThread(LPVOID lParam);
  355. protected:
  356. virtual UINT PreDeleteFileThread(LPVOID lParam);
  357. virtual UINT PreRecieveFileThread(LPVOID lParam);
  358. virtual UINT PreSendFileThread(LPVOID lParam);
  359. virtual UINT RenameFileThread(LPVOID lParam);
  360. virtual UINT DeleteFileThread(LPVOID lParam);
  361. virtual UINT ReceiveFileThread(LPVOID lParam);
  362. virtual UINT SendFileThread(LPVOID lParam);
  363. virtual UINT FindLocFileThread(LPVOID lParam);
  364. virtual UINT FindServFileThread(LPVOID lParam);
  365. protected:
  366. // Overrides
  367. // ClassWizard generated virtual function overrides
  368. //{{AFX_VIRTUAL(CMyAppThread)
  369. public:
  370. virtual BOOL InitInstance();
  371. virtual int ExitInstance();
  372. //}}AFX_VIRTUAL
  373. // Implementation
  374. public:
  375. virtual ~CMyAppThread();
  376. // Generated message map functions
  377. //{{AFX_MSG(CMyAppThread)
  378. // NOTE - the ClassWizard will add and remove member functions here.
  379. //}}AFX_MSG
  380. DECLARE_MESSAGE_MAP()
  381. };
  382. /////////////////////////////////////////////////////////////////////////////
  383. /////////////////////////////////////////////////////////////////////////////
  384. // CInputEdit window
  385. class CInputEdit : public CEdit
  386. {
  387. // Construction
  388. public:
  389. CInputEdit(int iItem,int iSubItem,CString& szInitText,CListCtrl* pListCtrl);
  390. // Attributes
  391. public:
  392. // Operations
  393. private:
  394. CListCtrl* m_pListCtrl;
  395. CString m_szInitText;
  396. int m_iItem;
  397. int m_iSubItem;
  398. BOOL m_bEsc;
  399. public:
  400. // Overrides
  401. // ClassWizard generated virtual function overrides
  402. //{{AFX_VIRTUAL(CInputEdit)
  403. public:
  404. virtual BOOL PreTranslateMessage(MSG* pMsg);
  405. //}}AFX_VIRTUAL
  406. // Implementation
  407. public:
  408. virtual ~CInputEdit();
  409. // Generated message map functions
  410. protected:
  411. //{{AFX_MSG(CInputEdit)
  412. afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  413. afx_msg void OnKillFocus(CWnd* pNewWnd);
  414. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  415. afx_msg void OnNcDestroy();
  416. //}}AFX_MSG
  417. DECLARE_MESSAGE_MAP()
  418. };
  419. /////////////////////////////////////////////////////////////////////////////
  420. /////////////////////////////////////////////////////////////////////////////
  421. // CDialDlg dialog
  422. class CDialDlg : public CDialog
  423. {
  424. // Construction
  425. public:
  426. CDialDlg(CWnd* pParent = NULL);   // standard constructor
  427. // Dialog Data
  428. //{{AFX_DATA(CDialDlg)
  429. enum { IDD = IDD_DIALPROCDIG };
  430. CComboBox m_ctEntryName;
  431. CString m_szPassword;
  432. CString m_szUserID;
  433. //}}AFX_DATA
  434. // Overrides
  435. // ClassWizard generated virtual function overrides
  436. //{{AFX_VIRTUAL(CDialDlg)
  437. protected:
  438. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  439. //}}AFX_VIRTUAL
  440. // Implementation
  441. protected:
  442. // Generated message map functions
  443. //{{AFX_MSG(CDialDlg)
  444. virtual BOOL OnInitDialog();
  445. //}}AFX_MSG
  446. DECLARE_MESSAGE_MAP()
  447. };
  448. //{{AFX_INSERT_LOCATION}}
  449. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  450. #endif // !defined(AFX_MAINFRM_H__12BB9B69_5C23_4A93_8206_EAFAAA22E1E4__INCLUDED_)