123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516 |
- // MainFrm.cpp : implementation of the CMainFrame class
- //
- #include "stdafx.h"
- #include "LYFZIPManage.h"
- #include "resource.h"
- #include "MainFrm.h"
- #include "Psw.h"
- #include "TakeFrom.h"
- #include "ClientIPForm.h"
- #include "LogForm.h"
- #include <Mmsystem.h>
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- #define IPC_CUSTOM_MSG2 _T("{a4Fa76E2-w78F-2aD5-q98A-Y0B0D078u2}")
- UINT g_wmClose = RegisterWindowMessage(IPC_CUSTOM_MSG2);
- #define WM_ICON_NOTIFY WM_USER+12
- extern HWND g_hConnectWnd;
- CRect g_rc;
- CMainFrame *g_pMainWnd=NULL;
- HWND g_hSendWnd=NULL;
- extern CString newGUID();
- BOOL g_bNeedCoon=1;
- BOOL g_bAutoRun=0;
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame
- /////////////////////////////////////////////////////////////////////////////
- float m_WidthScale;
- float m_HeightScale;
- BOOL g_bWork = 0;
- BOOL CALLBACK EnumChildProc(HWND hwnd,LPARAM lParam)
- {
- CRect rtCtrl,rtWnd;
- if(hwnd)
- {
- ::GetWindowRect(hwnd,&rtCtrl);
- ::GetWindowRect(GetParent(hwnd),&rtWnd);
- rtCtrl.OffsetRect(-rtWnd.left,-rtWnd.top);
- float temp;
- temp= (float)rtCtrl.left*m_WidthScale;
- rtCtrl.left = (int)temp;
- temp= (float)rtCtrl.top*m_HeightScale;
- rtCtrl.top = (int)temp;
- temp = (float)rtCtrl.right*m_WidthScale;
- rtCtrl.right = (int)temp;
- temp =(float)rtCtrl.bottom*m_HeightScale;
- rtCtrl.bottom =(int)temp;
- ::MoveWindow(hwnd,rtCtrl.left,rtCtrl.top,rtCtrl.Width(),rtCtrl.Height(),TRUE);
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
- IMPLEMENT_DYNCREATE(CMainFrame, CMDIFrameWnd)
- BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
- //{{AFX_MSG_MAP(CMainFrame)
- ON_WM_CREATE()
- ON_WM_DESTROY()
- ON_WM_CLOSE()
- ON_WM_TIMER()
- ON_COMMAND(IDM_TODAY, OnToday)
- ON_COMMAND(IDM_DINDAN, OnDindan)
- ON_COMMAND(IDM_MSGREG, OnMsgreg)
- ON_COMMAND(IDM_EXIT, OnExit)
- ON_COMMAND(IDM_OPEN, OnOpen)
- ON_COMMAND(IDM_AUTORUN, OnAutorun)
- ON_COMMAND(IDM_CLIENTIP, OnClientip)
- ON_COMMAND(IDM_LOG, OnLog)
- ON_WM_NCLBUTTONDBLCLK()
- ON_WM_NCHITTEST()
- ON_COMMAND(IDM_CLIENTIP2, OnClientip2)
- //}}AFX_MSG_MAP
- ON_MESSAGE(WM_ICON_NOTIFY, OnTrayNotification)
- ON_REGISTERED_MESSAGE(g_wmClose, OnAbortClose)
- END_MESSAGE_MAP()
- static UINT indicators[] =
- {
- ID_SEPARATOR, // status line indicator
- ID_INDICATOR_CAPS,
- ID_INDICATOR_NUM,
- ID_INDICATOR_SCRL,
- };
- LRESULT CMainFrame::OnAbortClose(WPARAM wParam, LPARAM lParam)
- {
- if(g_bWork)return 0;
- m_TrayIcon.RemoveIcon();
- if(m_Mdi.MainClose())
- CMDIFrameWnd::OnClose();
- return 1;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame construction/destruction
- #if defined(VC70) || defined(VC60)
- UINT CMainFrame::OnNcHitTest(CPoint point)
- {
- if (CWnd::OnNcHitTest(point) == HTRIGHT || CWnd::OnNcHitTest(point) == HTLEFT || CWnd::OnNcHitTest(point) == HTTOP || CWnd::OnNcHitTest(point) == HTBOTTOM)
- return HTCLIENT;
- return CWnd::OnNcHitTest(point);
- }
- #else
- LRESULT CMainFrame::OnNcHitTest(CPoint point)
- {
- if (CWnd::OnNcHitTest(point) == HTRIGHT || CWnd::OnNcHitTest(point) == HTLEFT || CWnd::OnNcHitTest(point) == HTTOP || CWnd::OnNcHitTest(point) == HTBOTTOM)
- return HTCLIENT;
- return CWnd::OnNcHitTest(point);
- }
- #endif
- void CMainFrame::OnNcLButtonDblClk(UINT nFlags, CPoint point)
- {
- if(nFlags != HTCAPTION)
- CMDIFrameWnd::OnNcLButtonDblClk(nFlags, point);
- }
- CMainFrame::CMainFrame()
- {
- // TODO: add member initialization code here
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- CString version = _T ("Version 1.0");
- g_bAutoRun=AfxGetApp()->GetProfileInt (version, "brun", 0);
- }
- CMainFrame::~CMainFrame()
- {
- }
- void LoadImageFromFile(Bitmap **img, CString path)
- {
- try
- {
- if(!::PathFileExists (path))return;
- if(*img)delete *img;
- *img=NULL;
- BSTR bstr= path.AllocSysString();
- *img= Bitmap::FromFile(bstr);
- SysFreeString(bstr);
- }
- catch(...)
- {
- }
- }
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
- if(!m_wndClient.SubclassWindow (m_hWndMDIClient))
- {
- return -1;
- }
- if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
- | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
- !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
- {
- TRACE0("Failed to create toolbar\n");
- return -1; // fail to create
- }
- m_wndToolBar.LoadTrueColorToolBar(90, IDB_NORMAL, 0, IDB_DISABLE);
- // second toolbar must have different ID
- // TODO: Delete these three lines if you don't want the toolbar to
- // be dockable
- ::GetWindowRect (this->m_hWndMDIClient, g_rc);
- g_pMainWnd=this;
- m_WidthScale = (float)g_rc.Width ()/722;
- m_HeightScale = (float)g_rc.Height ()/533;
- SetTimer(1, 5*60000, NULL);
- m_TrayIcon.Create(this,WM_ICON_NOTIFY,"域名服务器" ,m_hIcon,IDR_MENUtray); //构造
- OnClose();
- g_pMainWnd->SetTimer (3, 20000, NULL);
- return 0;
- }
- BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- if( !CMDIFrameWnd::PreCreateWindow(cs) )
- return FALSE;
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- cs.style&=~WS_MAXIMIZEBOX;
- cs.style&=~WS_THICKFRAME;
- RECT rect;
- HWND hWnd = ::FindWindow("Shell_TrayWnd", 0);
- ::GetWindowRect(hWnd,&rect);
- cs.x=0;
- cs.y=0;
- cs.cx=GetSystemMetrics(SM_CXSCREEN);
- cs.cy=GetSystemMetrics(SM_CYSCREEN)-(rect.bottom -rect.top)+3;
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame diagnostics
- #ifdef _DEBUG
- void CMainFrame::AssertValid() const
- {
- CMDIFrameWnd::AssertValid();
- }
- void CMainFrame::Dump(CDumpContext& dc) const
- {
- CMDIFrameWnd::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame message handlers
- void CMainFrame::OnDestroy()
- {
- m_Mdi.DeleteAll();
- CMDIFrameWnd::OnDestroy();
- }
- void CMainFrame::OnClose()
- {
- // TODO: Add your message handler code here and/or call default
- ShowWindow(SW_HIDE); //隐藏窗口
- }
- LRESULT CMainFrame::OnTrayNotification(WPARAM wParam,LPARAM lParam)
- {
- return m_TrayIcon.OnTrayNotification(wParam,lParam);
- }
- ///////////////////////////////////////////////////////
- //减少代码
- #define OPEN_MENU(x) m_Mdi.Append(pName, RUNTIME_CLASS(x), IDR_MAINFRAME, this, nID)
- //减少代码
- ///////////////////////////////////////////////////////////////////////////////
- DWORD CMainFrame::GetConnectionID()
- {
- return m_dwConnectionID;
- }
- void CMainFrame::SetConnectionID(DWORD dwConnection)
- {
- m_dwConnectionID = dwConnection;
- }
- void CMainFrame::ProcessChatMessageRequest2(BYTE code)
- {
-
- }
- void CMainFrame::ProcessChatMessageRequest2(CString sql)
- {
- }
- void CMainFrame::ProcessChatMessageRequest2(BYTE *pData, int length)
- {
- }
- BOOL CMainFrame::ProcessChatMessageRequest(void *szDataBuf, int nDataLen)
- {
- return 1;
- }
- //ACEESS+TCPIP实现网络版
- BOOL CMainFrame::OnConnect()
- {
- return 1;
- }
- void CMainFrame::ProcessNetEvent(int nEventType, void *pRecvMsg, DWORD dwDataLen)
- {
- ///////
- }
- void CMainFrame::OnTimer(UINT nIDEvent)
- {
- // TODO: Add your message handler code here and/or call default
- if(nIDEvent==1)
- {
- }
- else if(nIDEvent==3)
- {
- if(g_bWork)return;
- KillTimer(3);
- g_pMainWnd->SetTimer (3, 20000, NULL);
- }
- else if(nIDEvent==4)
- {
- // m_Mdi.CloseAll();
- }
- }
- void CMainFrame::ProcessLoginResponse(void *pLoginResult)
- {
- }
- BOOL CMainFrame::ProcessLoginRequest()
- {
- return 1;
- }
- void CMainFrame::OnOutbarNotify(CString strMsg)
- {
- }
- void CMainFrame::AutoUpdate()
- {
- }
- BOOL g_bInSkin=0;
- BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
- {
- // TODO: Add your specialized code here and/or call the base class
- if(pMsg->message==WM_KEYDOWN)
- {
- switch (pMsg->wParam)
- {
- case VK_F3:
- ChangePsw();
- break;
- }
- }
- return CMDIFrameWnd::PreTranslateMessage(pMsg);
- }
- void CMainFrame::GetSkin()
- {
- }
- void CMainFrame::PrintDinDan(CString m_id)
- {
- }
- void CMainFrame::SetSelFolder(int pos)
- {
- }
- void CMainFrame::ToPhotoPrint()
- {
- }
- void CMainFrame::GetOcx()
- {
- }
- CArray<CStringArray, CStringArray>g_List1array;
- DWORD g_nLeng=0;
- BYTE *g_pData=NULL;
- void CMainFrame::ProcessChatMessageResponse(void *pResponse)
- {
- }
- void CMainFrame::AddHistoryMenu(CArray<CStringArray, CStringArray>*hisyeararray)
- {
- }
- void CMainFrame::OnHistory(UINT nID)
- {
- }
- void CMainFrame::PrintDinDan2(CString m_id)
- {
- }
- void CMainFrame::OnToday()
- {
- // TODO: Add your command handler code here
- // TODO: Add your command handler code here
- UINT nID=1;
- LPSTR pName ;
- pName = (LPSTR)(LPCSTR)"客户资料";
- OPEN_MENU(TakeFrom);
- }
- void CMainFrame::OnDindan()
- {
- UINT nID=1;
- LPSTR pName ;
- pName = (LPSTR)(LPCSTR)"我的账户";
-
- }
- void CMainFrame::ChangePsw()
- {
- Psw dlg;
- dlg.DoModal ();
- }
- void CMainFrame::OnMsgreg()
- {
- // TODO: Add your command handler code here
- UINT nID=1;
- LPSTR pName ;
- pName = (LPSTR)(LPCSTR)"发送记录";
- //OPEN_MENU(DesignFrom);
- }
- extern DWORD FindAppProcessID(CString path);
- void CMainFrame::OnExit()
- {
- // TODO: Add your command handler code here
- m_TrayIcon.RemoveIcon();
- if(m_Mdi.MainClose())
- CMDIFrameWnd::OnClose();
- DWORD id=FindAppProcessID("AutoRun3.exe");
- if(id!=-1)
- {
- HANDLE ProcessHandle=OpenProcess(PROCESS_ALL_ACCESS,FALSE,id);
- if(ProcessHandle)TerminateProcess(ProcessHandle,0);
- }
- // exit(-1);
- }
- void CMainFrame::OnOpen()
- {
- // TODO: Add your command handler code here
- ShowWindow(SW_SHOW);
- }
- void CMainFrame::OnAutorun()
- {
- // TODO: Add your command handler code here
- g_bAutoRun=!g_bAutoRun;
- CString version = _T ("Version 1.0");
- AfxGetApp()->WriteProfileInt (version, "brun", g_bAutoRun);
- TCHAR szKey[MAX_PATH];
- HKEY hKey=0;
- DWORD disp=0;
- lstrcpy(szKey,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
- if(g_bAutoRun)
- {
- int lResult=RegCreateKeyEx(HKEY_LOCAL_MACHINE,szKey,0,NULL,REG_OPTION_VOLATILE, KEY_ALL_ACCESS,NULL,&hKey,&disp);
- if(lResult==ERROR_SUCCESS)
- {
- TCHAR szDir[MAX_PATH];
- ::GetModuleFileName (NULL, szDir, MAX_PATH);
- lResult=RegSetValueEx(hKey,"YLGLMSGMANAGE",0,REG_SZ,(const unsigned char*)szDir,lstrlen(szDir));
- RegCloseKey(hKey);
- }
- }
- else
- {
- int lResult=RegCreateKeyEx(HKEY_LOCAL_MACHINE,szKey,0,NULL,REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,NULL,&hKey,&disp);
- if(lResult==ERROR_SUCCESS)
- {
- RegDeleteValue(hKey,"YLGLMSGMANAGE");
- RegDeleteKey (hKey,"YLGLMSGMANAGE");
- RegCloseKey(hKey);
- }
- }
- }
- void CMainFrame::OnExit2()
- {
- }
- void CMainFrame::OnClientip()
- {
- // TODO: Add your command handler code here
- UINT nID=1;
- LPSTR pName ;
- pName = (LPSTR)(LPCSTR)"域名管理";
- OPEN_MENU(ClientIPFrom);
- }
- void CMainFrame::OnLog()
- {
- // TODO: Add your command handler code here
- UINT nID=1;
- LPSTR pName ;
- pName = (LPSTR)(LPCSTR)"系统日志";
- OPEN_MENU(LogFrom);
- }
- void CMainFrame::OnClientip2()
- {
- // TODO: Add your command handler code here
- UINT nID=1;
- LPSTR pName ;
- pName = (LPSTR)(LPCSTR)"域名管理2";
- //OPEN_MENU(ClientIPFrom2);
- }
|