MainFrm.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "LYFZIPManage.h"
  5. #include "resource.h"
  6. #include "MainFrm.h"
  7. #include "Psw.h"
  8. #include "TakeFrom.h"
  9. #include "ClientIPForm.h"
  10. #include "LogForm.h"
  11. #include <Mmsystem.h>
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17. #define IPC_CUSTOM_MSG2 _T("{a4Fa76E2-w78F-2aD5-q98A-Y0B0D078u2}")
  18. UINT g_wmClose = RegisterWindowMessage(IPC_CUSTOM_MSG2);
  19. #define WM_ICON_NOTIFY WM_USER+12
  20. extern HWND g_hConnectWnd;
  21. CRect g_rc;
  22. CMainFrame *g_pMainWnd=NULL;
  23. HWND g_hSendWnd=NULL;
  24. extern CString newGUID();
  25. BOOL g_bNeedCoon=1;
  26. BOOL g_bAutoRun=0;
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CMainFrame
  29. /////////////////////////////////////////////////////////////////////////////
  30. float m_WidthScale;
  31. float m_HeightScale;
  32. BOOL g_bWork = 0;
  33. BOOL CALLBACK EnumChildProc(HWND hwnd,LPARAM lParam)
  34. {
  35. CRect rtCtrl,rtWnd;
  36. if(hwnd)
  37. {
  38. ::GetWindowRect(hwnd,&rtCtrl);
  39. ::GetWindowRect(GetParent(hwnd),&rtWnd);
  40. rtCtrl.OffsetRect(-rtWnd.left,-rtWnd.top);
  41. float temp;
  42. temp= (float)rtCtrl.left*m_WidthScale;
  43. rtCtrl.left = (int)temp;
  44. temp= (float)rtCtrl.top*m_HeightScale;
  45. rtCtrl.top = (int)temp;
  46. temp = (float)rtCtrl.right*m_WidthScale;
  47. rtCtrl.right = (int)temp;
  48. temp =(float)rtCtrl.bottom*m_HeightScale;
  49. rtCtrl.bottom =(int)temp;
  50. ::MoveWindow(hwnd,rtCtrl.left,rtCtrl.top,rtCtrl.Width(),rtCtrl.Height(),TRUE);
  51. return TRUE;
  52. }
  53. else
  54. {
  55. return FALSE;
  56. }
  57. }
  58. IMPLEMENT_DYNCREATE(CMainFrame, CMDIFrameWnd)
  59. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  60. //{{AFX_MSG_MAP(CMainFrame)
  61. ON_WM_CREATE()
  62. ON_WM_DESTROY()
  63. ON_WM_CLOSE()
  64. ON_WM_TIMER()
  65. ON_COMMAND(IDM_TODAY, OnToday)
  66. ON_COMMAND(IDM_DINDAN, OnDindan)
  67. ON_COMMAND(IDM_MSGREG, OnMsgreg)
  68. ON_COMMAND(IDM_EXIT, OnExit)
  69. ON_COMMAND(IDM_OPEN, OnOpen)
  70. ON_COMMAND(IDM_AUTORUN, OnAutorun)
  71. ON_COMMAND(IDM_CLIENTIP, OnClientip)
  72. ON_COMMAND(IDM_LOG, OnLog)
  73. ON_WM_NCLBUTTONDBLCLK()
  74. ON_WM_NCHITTEST()
  75. ON_COMMAND(IDM_CLIENTIP2, OnClientip2)
  76. //}}AFX_MSG_MAP
  77. ON_MESSAGE(WM_ICON_NOTIFY, OnTrayNotification)
  78. ON_REGISTERED_MESSAGE(g_wmClose, OnAbortClose)
  79. END_MESSAGE_MAP()
  80. static UINT indicators[] =
  81. {
  82. ID_SEPARATOR, // status line indicator
  83. ID_INDICATOR_CAPS,
  84. ID_INDICATOR_NUM,
  85. ID_INDICATOR_SCRL,
  86. };
  87. LRESULT CMainFrame::OnAbortClose(WPARAM wParam, LPARAM lParam)
  88. {
  89. if(g_bWork)return 0;
  90. m_TrayIcon.RemoveIcon();
  91. if(m_Mdi.MainClose())
  92. CMDIFrameWnd::OnClose();
  93. return 1;
  94. }
  95. /////////////////////////////////////////////////////////////////////////////
  96. // CMainFrame construction/destruction
  97. #if defined(VC70) || defined(VC60)
  98. UINT CMainFrame::OnNcHitTest(CPoint point)
  99. {
  100. if (CWnd::OnNcHitTest(point) == HTRIGHT || CWnd::OnNcHitTest(point) == HTLEFT || CWnd::OnNcHitTest(point) == HTTOP || CWnd::OnNcHitTest(point) == HTBOTTOM)
  101. return HTCLIENT;
  102. return CWnd::OnNcHitTest(point);
  103. }
  104. #else
  105. LRESULT CMainFrame::OnNcHitTest(CPoint point)
  106. {
  107. if (CWnd::OnNcHitTest(point) == HTRIGHT || CWnd::OnNcHitTest(point) == HTLEFT || CWnd::OnNcHitTest(point) == HTTOP || CWnd::OnNcHitTest(point) == HTBOTTOM)
  108. return HTCLIENT;
  109. return CWnd::OnNcHitTest(point);
  110. }
  111. #endif
  112. void CMainFrame::OnNcLButtonDblClk(UINT nFlags, CPoint point)
  113. {
  114. if(nFlags != HTCAPTION)
  115. CMDIFrameWnd::OnNcLButtonDblClk(nFlags, point);
  116. }
  117. CMainFrame::CMainFrame()
  118. {
  119. // TODO: add member initialization code here
  120. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  121. CString version = _T ("Version 1.0");
  122. g_bAutoRun=AfxGetApp()->GetProfileInt (version, "brun", 0);
  123. }
  124. CMainFrame::~CMainFrame()
  125. {
  126. }
  127. void LoadImageFromFile(Bitmap **img, CString path)
  128. {
  129. try
  130. {
  131. if(!::PathFileExists (path))return;
  132. if(*img)delete *img;
  133. *img=NULL;
  134. BSTR bstr= path.AllocSysString();
  135. *img= Bitmap::FromFile(bstr);
  136. SysFreeString(bstr);
  137. }
  138. catch(...)
  139. {
  140. }
  141. }
  142. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  143. {
  144. if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  145. return -1;
  146. if(!m_wndClient.SubclassWindow (m_hWndMDIClient))
  147. {
  148. return -1;
  149. }
  150. if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
  151. | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
  152. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  153. {
  154. TRACE0("Failed to create toolbar\n");
  155. return -1; // fail to create
  156. }
  157. m_wndToolBar.LoadTrueColorToolBar(90, IDB_NORMAL, 0, IDB_DISABLE);
  158. // second toolbar must have different ID
  159. // TODO: Delete these three lines if you don't want the toolbar to
  160. // be dockable
  161. ::GetWindowRect (this->m_hWndMDIClient, g_rc);
  162. g_pMainWnd=this;
  163. m_WidthScale = (float)g_rc.Width ()/722;
  164. m_HeightScale = (float)g_rc.Height ()/533;
  165. SetTimer(1, 5*60000, NULL);
  166. m_TrayIcon.Create(this,WM_ICON_NOTIFY,"域名服务器" ,m_hIcon,IDR_MENUtray); //构造
  167. OnClose();
  168. g_pMainWnd->SetTimer (3, 20000, NULL);
  169. return 0;
  170. }
  171. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  172. {
  173. if( !CMDIFrameWnd::PreCreateWindow(cs) )
  174. return FALSE;
  175. // TODO: Modify the Window class or styles here by modifying
  176. // the CREATESTRUCT cs
  177. cs.style&=~WS_MAXIMIZEBOX;
  178. cs.style&=~WS_THICKFRAME;
  179. RECT rect;
  180. HWND hWnd = ::FindWindow("Shell_TrayWnd", 0);
  181. ::GetWindowRect(hWnd,&rect);
  182. cs.x=0;
  183. cs.y=0;
  184. cs.cx=GetSystemMetrics(SM_CXSCREEN);
  185. cs.cy=GetSystemMetrics(SM_CYSCREEN)-(rect.bottom -rect.top)+3;
  186. return TRUE;
  187. }
  188. /////////////////////////////////////////////////////////////////////////////
  189. // CMainFrame diagnostics
  190. #ifdef _DEBUG
  191. void CMainFrame::AssertValid() const
  192. {
  193. CMDIFrameWnd::AssertValid();
  194. }
  195. void CMainFrame::Dump(CDumpContext& dc) const
  196. {
  197. CMDIFrameWnd::Dump(dc);
  198. }
  199. #endif //_DEBUG
  200. /////////////////////////////////////////////////////////////////////////////
  201. // CMainFrame message handlers
  202. void CMainFrame::OnDestroy()
  203. {
  204. m_Mdi.DeleteAll();
  205. CMDIFrameWnd::OnDestroy();
  206. }
  207. void CMainFrame::OnClose()
  208. {
  209. // TODO: Add your message handler code here and/or call default
  210. ShowWindow(SW_HIDE); //隐藏窗口
  211. }
  212. LRESULT CMainFrame::OnTrayNotification(WPARAM wParam,LPARAM lParam)
  213. {
  214. return m_TrayIcon.OnTrayNotification(wParam,lParam);
  215. }
  216. ///////////////////////////////////////////////////////
  217. //减少代码
  218. #define OPEN_MENU(x) m_Mdi.Append(pName, RUNTIME_CLASS(x), IDR_MAINFRAME, this, nID)
  219. //减少代码
  220. ///////////////////////////////////////////////////////////////////////////////
  221. DWORD CMainFrame::GetConnectionID()
  222. {
  223. return m_dwConnectionID;
  224. }
  225. void CMainFrame::SetConnectionID(DWORD dwConnection)
  226. {
  227. m_dwConnectionID = dwConnection;
  228. }
  229. void CMainFrame::ProcessChatMessageRequest2(BYTE code)
  230. {
  231. }
  232. void CMainFrame::ProcessChatMessageRequest2(CString sql)
  233. {
  234. }
  235. void CMainFrame::ProcessChatMessageRequest2(BYTE *pData, int length)
  236. {
  237. }
  238. BOOL CMainFrame::ProcessChatMessageRequest(void *szDataBuf, int nDataLen)
  239. {
  240. return 1;
  241. }
  242. //ACEESS+TCPIP实现网络版
  243. BOOL CMainFrame::OnConnect()
  244. {
  245. return 1;
  246. }
  247. void CMainFrame::ProcessNetEvent(int nEventType, void *pRecvMsg, DWORD dwDataLen)
  248. {
  249. ///////
  250. }
  251. void CMainFrame::OnTimer(UINT nIDEvent)
  252. {
  253. // TODO: Add your message handler code here and/or call default
  254. if(nIDEvent==1)
  255. {
  256. }
  257. else if(nIDEvent==3)
  258. {
  259. if(g_bWork)return;
  260. KillTimer(3);
  261. g_pMainWnd->SetTimer (3, 20000, NULL);
  262. }
  263. else if(nIDEvent==4)
  264. {
  265. // m_Mdi.CloseAll();
  266. }
  267. }
  268. void CMainFrame::ProcessLoginResponse(void *pLoginResult)
  269. {
  270. }
  271. BOOL CMainFrame::ProcessLoginRequest()
  272. {
  273. return 1;
  274. }
  275. void CMainFrame::OnOutbarNotify(CString strMsg)
  276. {
  277. }
  278. void CMainFrame::AutoUpdate()
  279. {
  280. }
  281. BOOL g_bInSkin=0;
  282. BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
  283. {
  284. // TODO: Add your specialized code here and/or call the base class
  285. if(pMsg->message==WM_KEYDOWN)
  286. {
  287. switch (pMsg->wParam)
  288. {
  289. case VK_F3:
  290. ChangePsw();
  291. break;
  292. }
  293. }
  294. return CMDIFrameWnd::PreTranslateMessage(pMsg);
  295. }
  296. void CMainFrame::GetSkin()
  297. {
  298. }
  299. void CMainFrame::PrintDinDan(CString m_id)
  300. {
  301. }
  302. void CMainFrame::SetSelFolder(int pos)
  303. {
  304. }
  305. void CMainFrame::ToPhotoPrint()
  306. {
  307. }
  308. void CMainFrame::GetOcx()
  309. {
  310. }
  311. CArray<CStringArray, CStringArray>g_List1array;
  312. DWORD g_nLeng=0;
  313. BYTE *g_pData=NULL;
  314. void CMainFrame::ProcessChatMessageResponse(void *pResponse)
  315. {
  316. }
  317. void CMainFrame::AddHistoryMenu(CArray<CStringArray, CStringArray>*hisyeararray)
  318. {
  319. }
  320. void CMainFrame::OnHistory(UINT nID)
  321. {
  322. }
  323. void CMainFrame::PrintDinDan2(CString m_id)
  324. {
  325. }
  326. void CMainFrame::OnToday()
  327. {
  328. // TODO: Add your command handler code here
  329. // TODO: Add your command handler code here
  330. UINT nID=1;
  331. LPSTR pName ;
  332. pName = (LPSTR)(LPCSTR)"客户资料";
  333. OPEN_MENU(TakeFrom);
  334. }
  335. void CMainFrame::OnDindan()
  336. {
  337. UINT nID=1;
  338. LPSTR pName ;
  339. pName = (LPSTR)(LPCSTR)"我的账户";
  340. }
  341. void CMainFrame::ChangePsw()
  342. {
  343. Psw dlg;
  344. dlg.DoModal ();
  345. }
  346. void CMainFrame::OnMsgreg()
  347. {
  348. // TODO: Add your command handler code here
  349. UINT nID=1;
  350. LPSTR pName ;
  351. pName = (LPSTR)(LPCSTR)"发送记录";
  352. //OPEN_MENU(DesignFrom);
  353. }
  354. extern DWORD FindAppProcessID(CString path);
  355. void CMainFrame::OnExit()
  356. {
  357. // TODO: Add your command handler code here
  358. m_TrayIcon.RemoveIcon();
  359. if(m_Mdi.MainClose())
  360. CMDIFrameWnd::OnClose();
  361. DWORD id=FindAppProcessID("AutoRun3.exe");
  362. if(id!=-1)
  363. {
  364. HANDLE ProcessHandle=OpenProcess(PROCESS_ALL_ACCESS,FALSE,id);
  365. if(ProcessHandle)TerminateProcess(ProcessHandle,0);
  366. }
  367. // exit(-1);
  368. }
  369. void CMainFrame::OnOpen()
  370. {
  371. // TODO: Add your command handler code here
  372. ShowWindow(SW_SHOW);
  373. }
  374. void CMainFrame::OnAutorun()
  375. {
  376. // TODO: Add your command handler code here
  377. g_bAutoRun=!g_bAutoRun;
  378. CString version = _T ("Version 1.0");
  379. AfxGetApp()->WriteProfileInt (version, "brun", g_bAutoRun);
  380. TCHAR szKey[MAX_PATH];
  381. HKEY hKey=0;
  382. DWORD disp=0;
  383. lstrcpy(szKey,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
  384. if(g_bAutoRun)
  385. {
  386. int lResult=RegCreateKeyEx(HKEY_LOCAL_MACHINE,szKey,0,NULL,REG_OPTION_VOLATILE, KEY_ALL_ACCESS,NULL,&hKey,&disp);
  387. if(lResult==ERROR_SUCCESS)
  388. {
  389. TCHAR szDir[MAX_PATH];
  390. ::GetModuleFileName (NULL, szDir, MAX_PATH);
  391. lResult=RegSetValueEx(hKey,"YLGLMSGMANAGE",0,REG_SZ,(const unsigned char*)szDir,lstrlen(szDir));
  392. RegCloseKey(hKey);
  393. }
  394. }
  395. else
  396. {
  397. int lResult=RegCreateKeyEx(HKEY_LOCAL_MACHINE,szKey,0,NULL,REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,NULL,&hKey,&disp);
  398. if(lResult==ERROR_SUCCESS)
  399. {
  400. RegDeleteValue(hKey,"YLGLMSGMANAGE");
  401. RegDeleteKey (hKey,"YLGLMSGMANAGE");
  402. RegCloseKey(hKey);
  403. }
  404. }
  405. }
  406. void CMainFrame::OnExit2()
  407. {
  408. }
  409. void CMainFrame::OnClientip()
  410. {
  411. // TODO: Add your command handler code here
  412. UINT nID=1;
  413. LPSTR pName ;
  414. pName = (LPSTR)(LPCSTR)"域名管理";
  415. OPEN_MENU(ClientIPFrom);
  416. }
  417. void CMainFrame::OnLog()
  418. {
  419. // TODO: Add your command handler code here
  420. UINT nID=1;
  421. LPSTR pName ;
  422. pName = (LPSTR)(LPCSTR)"系统日志";
  423. OPEN_MENU(LogFrom);
  424. }
  425. void CMainFrame::OnClientip2()
  426. {
  427. // TODO: Add your command handler code here
  428. UINT nID=1;
  429. LPSTR pName ;
  430. pName = (LPSTR)(LPCSTR)"域名管理2";
  431. //OPEN_MENU(ClientIPFrom2);
  432. }