From 4d6d9b1fbcb55516e50efcf8f4884075f8a04581 Mon Sep 17 00:00:00 2001 From: mjjo Date: Sat, 20 Jul 2013 23:23:08 +0000 Subject: [PATCH] --- HookMsg/HookMsgDlg.h | 308 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 308 insertions(+) create mode 100644 HookMsg/HookMsgDlg.h diff --git a/HookMsg/HookMsgDlg.h b/HookMsg/HookMsgDlg.h new file mode 100644 index 0000000..8d9b9e9 --- /dev/null +++ b/HookMsg/HookMsgDlg.h @@ -0,0 +1,308 @@ + // HookMsgDlg.h : header file +// + +#if !defined(AFX_HOOKMSGDLG_H__C6A5153E_1FD5_46AD_955E_DADD41BD7DAD__INCLUDED_) +#define AFX_HOOKMSGDLG_H__C6A5153E_1FD5_46AD_955E_DADD41BD7DAD__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +///////////////////////////////////////////////////////////////////////////// +// CHookMsgDlg dialog +#include +#include "LockControlDlg.h" + +#include "./UtilClass/TrayIcon.h" + +#include "TickerSocket.h" + + +#define WM_ICON_NOTIFY WM_USER+10 + +#define WM_SVRSEND_COMMAND WM_USER+200 + +#define WM_START_COMMAND WM_USER+9000 +#define WM_STOP_COMMAND WM_USER+9001 +#define WM_REJECTLISTUPDATE_COMMAND WM_USER+9010 + +#define TIMEID_TRAYICON 1 +#define TIMEID_7121DBCLICK 2 + +#define UM_SRC_INFOTICKER 0x4444 +class CClientSocket; +class CTickerSocket; + +class CHookMsgDlg : public CDialog, public CThinThread +{ + friend class CLockControlDlg; + + BOOL m_bInitSuccess; // ÃʱâÈ­ ¿Ï·á¿©ºÎ. + +private: + HANDLE hFile; + +public: + void StartWork(); // override to do startup + void DoWork(UINT ThreadType); // override to do work + void EndWork(); // override to do shutdown + + void _WorkThreadProc(UINT ThreadType); // ¸Å¼öÆÇ´Ü Processing ÇÔ¼ö. + + BOOL _ExtractJCode( int nSrcType, CString &_strTitle, CString & strJCode, CString & strJName ); + char m_szHotKey_JCode[20]; + +// IDibPtr m_pCpConclusion; +// CCpDibEvent * m_pCpConclusionEvent; + + long m_nSrcJumoon_Number; // ¸Å¼ö(¸Åµµ)¿ø ÁÖ¹®¹øÈ£. + long m_nAutoMedoMoney; // ÀÚµ¿¸Åµµ½Ã ÁÖ¹®±Ý¾×. + BOOL m_bUsingStockCheckThread; // ÄÚ½º´Ú ÇöÀç°¡ ¾²·¹µå Àû¿ë¿©ºÎ. + +// Construction +public: + CHookMsgDlg(CWnd* pParent = NULL); // standard constructor + virtual ~CHookMsgDlg(); + + void PlaySound( CString strWaveFile ); + void TraceMsg( CString strMsg, CXListBox::Color tc=CXListBox::Black, CXListBox::Color bc=CXListBox::White, BOOL bWriteFile=FALSE ); + void SetDlgCtrlPosition(int cx, int cy); + + DWORD m_dwTickStart; // ÀÛ¾÷¾²·¹µåÀÇ ½ÃÀ۽𢠱â·Ï. + DWORD m_dwCallTimeLast; // 30Ãʰ£ÀÇ ÁÖ¹®È£Ãâ ȸ¼öÁ¦ÇÑÀ» À§ÇÑ ÀÌÀü ½Ã°¢±â·Ï. + DWORD m_dwMonitorPauseTime; // Àá±è»óÅ Àüȯ½Ã ½Ã°¢±â·Ï. + + CTrayIcon m_TrayIcon; + UINT m_nTrayIconTimer; + + BOOL m_bMonitorStatus; + + char m_szTitle[MAX_RECEIVE_LEN]; // ´º½º ¸Þ½ÃÁö ¿ø¹®. + int m_nSourceFrom; // ÈÄÅ·µÈ ¸Þ½ÃÁöÀÇ ¿øÃµ. + + ////////////////////////////////////////////////////////////////////// + // Åë½Å¿ë µ¥ÀÌÅÍ. +public: + CString m_strSendCommand; + CString m_strName; + CString m_strSvrIP; + UINT m_nSvrPort; + CClientSocket * m_pClientSocket; + + CTickerSocket * m_pTickerSocket; // °Å·¡¼Ò InfoTicker ¼­¹ö¿¡ Á¢¼Ó. + +public: + void ClientClosed(); + void AddClientsCom( CString strFrom, CString strMessage ); + +private: + bool RetrieveNewsData(); + + void InstallHotKey(); + void EmulateHotkey( WORD wVk, WORD wModifier ); + + BOOL InputCodeTypeStatus( int & nSrcType ); + void HookInstallTargetWnd(); + + void AutoInputJongmokCode(int nSrcFrom, CString strCode ); + void AutoScreenSwitch(); + + void HLStockWindowShow( CString strJCode, CString strExtraData = "" ); + void ShowHideLockControlDlg( BOOL bShow ); + + CLockControlDlg * m_pLCDlg; + + CFont m_LockUnlockBtnFont; + + //~! + char m_szWnd3_Time[10]; + char m_szWnd3_Title[MAX_RECEIVE_LEN],m_szWnd3_Name[100]; + + CString g_strTitle; + CString g_strJCode; + CString g_strJName; + int g_nSourceFrom; + +public: + +// Dialog Data + //{{AFX_DATA(CHookMsgDlg) + enum { IDD = IDD_HOOKMSG_DIALOG }; + CStatic m_hCPValue; + CXListBox m_hTraceListBox; + BOOL m_bInputCode1; + BOOL m_bInputCode2; + BOOL m_bInputCode3; + BOOL m_bSvrConnect; + BOOL m_bInfoTickerConnect; + //}}AFX_DATA + + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CHookMsgDlg) + public: + virtual BOOL DestroyWindow(); + protected: + virtual BOOL OnInitDialog(); + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); + virtual void OnCancel(); + //}}AFX_VIRTUAL + +// Implementation +protected: + HICON m_hIcon; + + // Generated message map functions + //{{AFX_MSG(CHookMsgDlg) + afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu); + afx_msg void OnClose(); + afx_msg void OnSysCommand(UINT nID, LPARAM lParam); + afx_msg void OnPaint(); + afx_msg HCURSOR OnQueryDragIcon(); + afx_msg void OnTimer(UINT nIDEvent); + afx_msg BOOL OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct); + afx_msg LRESULT OnNcHitTest(CPoint point); + afx_msg void OnMonitorStart(); + afx_msg void OnUpdateMonitorStart(CCmdUI* pCmdUI); + afx_msg void OnMonitorPause(); + afx_msg void OnUpdateMonitorPause(CCmdUI* pCmdUI); + afx_msg void OnTargetWndBtn(); + afx_msg void OnUpdateTargetWndBtn(CCmdUI* pCmdUI); + afx_msg void OnHookOnOffCheck(); + afx_msg void OnConfigEnvBtn(); + afx_msg void OnConfigRejectlistBtn(); + afx_msg void OnConfigPassListBtn(); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI); + afx_msg void OnHookmsgMedoBtn(); + afx_msg void OnHookmsgStockpriceCheck(); + afx_msg void OnConfigRejectlistBtn2(); + afx_msg void OnHookmsgHookstateCheck1(); + afx_msg void OnHookmsgHookstateCheck2(); + afx_msg void OnHookmsgHookstateCheck3(); + afx_msg void OnConfigSpecialList(); + afx_msg void OnConfigManualList(); + afx_msg void OnSvrconnectCheck(); + afx_msg void OnInfotickerCheck(); + //}}AFX_MSG + + afx_msg LONG OnReceived(WPARAM wParam, LPARAM lParam); // Ãß°¡ÇÑ °ÍÀÓ + + afx_msg LRESULT OnHotKey(WPARAM wParam, LPARAM lParam); + afx_msg LONG OnTrayNotification(UINT wParam, LONG lParam); + afx_msg LRESULT OnUpdateMarketInfo( WPARAM wParam, LPARAM lParam ); + afx_msg LRESULT OnTargetAppDestoryed( WPARAM wParam, LPARAM lParam ); + afx_msg LRESULT OnStartCommand(WPARAM wParam, LPARAM lParam); + afx_msg LRESULT OnStopCommand(WPARAM wParam, LPARAM lParam); + afx_msg LRESULT OnUpdateRejectListCommand(WPARAM wParam, LPARAM lParam); + + afx_msg LRESULT OnSvrSendCommand(WPARAM wParam, LPARAM lParam); + + afx_msg LRESULT OnTickerSocketClose(WPARAM wParam, LPARAM lClient); // Client ¼ÒÄÏ ÇØÁ¦ + afx_msg LRESULT OnTickerSocketReceive(WPARAM wParam, LPARAM lClient); // Client ¼ÒÄÏÀ¸·Î ºÎÅÍ ¼ö½ÅµÇ´Â µ¥ÀÌÅÍ + + DECLARE_MESSAGE_MAP() +}; + + +inline void CHookMsgDlg::ShowHideLockControlDlg( BOOL bShow ) +{ + if( bShow ) + { + if (m_pLCDlg != NULL) + { + m_pLCDlg->SetFocus (); + } + else + { + m_pLCDlg = new CLockControlDlg; + if(m_pLCDlg) + m_pLCDlg->Create( IDD_CONTROL_DLG, this ); + } + + g_theApp.m_bShowLockContorlDlg = TRUE; + } + else + { + if( m_pLCDlg ) + m_pLCDlg->SendMessage(WM_CLOSE); + + g_theApp.m_bShowLockContorlDlg = FALSE; + } +} + +inline BOOL CHookMsgDlg::InputCodeTypeStatus( int & nSrcType ) +{ + if( nSrcType == UM_HOOKOK_WND1 ) + return m_bInputCode1; + else if( nSrcType == UM_HOOKOK_WND2 ) + return m_bInputCode2; + else if( nSrcType == UM_HOOKOK_WND3 ) + return m_bInputCode3; + else if( nSrcType == UM_SRC_INFOTICKER ) + return m_bInfoTickerConnect; + + return FALSE; +} + + +inline void CHookMsgDlg::HLStockWindowShow( CString strJCode, CString strExtraData ) +{ + if( g_AppEnv.bLowmoneyInfoDlg == FALSE ) + return; + + try { + memset( &g_HLStockWindowData, NULL, sizeof(HLSTOCKWINDOWDATA) ); + + g_HLStockWindowData.wParam = 0; + g_HLStockWindowData.lParam = 0; + sprintf( g_HLStockWindowData.szJCode, "%s", strJCode ); + strcpy( (char*)g_HLStockWindowData.ExtraData, strExtraData); + + g_HLStockWindowData_CDS.dwData = TYPEOF_HLStockWindow; + + HWND hTagretWnd = ::FindWindow( "HLStockWindow_Dialog", NULL ); + if( ::IsWindow( hTagretWnd ) ) + { + ::SendMessage(hTagretWnd, WM_COPYDATA, (WPARAM)m_hWnd, (LPARAM)&g_HLStockWindowData_CDS); + } + else + { + TCHAR szFilePath[_MAX_PATH]={0,}; + ::GetModuleFileName(NULL, szFilePath, _MAX_PATH); + *(strrchr( szFilePath, '\\' ) + 1) = 0; + strcat( szFilePath, "\\HLStockWindow.exe" ); + SHELLEXECUTEINFO ShExecInfo; + ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); + ShExecInfo.fMask = NULL; + ShExecInfo.hwnd = NULL; + ShExecInfo.lpVerb = NULL; + ShExecInfo.lpFile = szFilePath; + ShExecInfo.lpParameters = NULL; + ShExecInfo.lpDirectory = NULL; + ShExecInfo.nShow = SW_SHOW; + ShExecInfo.hInstApp = NULL; + ShellExecuteEx(&ShExecInfo); + + for(int i=0; i<10; i++) + { + HWND hTagretWnd = ::FindWindow( "HLStockWindow_Dialog", NULL ); + if( ::IsWindow( hTagretWnd ) ) + { + ::SendMessage(hTagretWnd, WM_COPYDATA, (WPARAM)m_hWnd, (LPARAM)&g_HLStockWindowData_CDS); + break; + } + Sleep(100); + } + } + } + catch(...) + { + TRACE("HLStockWindowShow exception !!!"); + } +} + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_HOOKMSGDLG_H__C6A5153E_1FD5_46AD_955E_DADD41BD7DAD__INCLUDED_)