scbc.sat2 пре 5 година
родитељ
комит
fa93d789f8

+ 97 - 1
SATHelper/SATHelper/MainFrm.cpp

@@ -22,6 +22,11 @@
 #define new DEBUG_NEW
 #endif
 
+#if USE_TRAYICON
+#define WM_MY_TRAY_NOTIFICATION WM_USER + 108
+const UINT WM_TASKBARCREATED = ::RegisterWindowMessage(_T("UB530"));
+#endif
+
 // CMainFrame
 
 IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWndEx)
@@ -35,25 +40,116 @@ BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWndEx)
 	ON_UPDATE_COMMAND_UI(ID_VIEW_CAPTION_BAR, &CMainFrame::OnUpdateViewCaptionBar)
 	ON_COMMAND(ID_TOOLS_OPTIONS, &CMainFrame::OnOptions)
 	ON_WM_SETTINGCHANGE()
+#if USE_TRAYICON
+	ON_MESSAGE(WM_MY_TRAY_NOTIFICATION, OnTrayNotification)
+	ON_REGISTERED_MESSAGE(WM_TASKBARCREATED, OnTaskBarCreated)
+#endif
 END_MESSAGE_MAP()
 
 // CMainFrame 构造/析构
 
-CMainFrame::CMainFrame() noexcept
+CMainFrame::CMainFrame() noexcept :m_trayIcon(IDR_MAINFRAME)
 {
 	// TODO: 在此添加成员初始化代码
 	theApp.m_nAppLook = theApp.GetInt(_T("ApplicationLook"), ID_VIEW_APPLOOK_VS_2008);
+#if USE_TRAYICON
+	m_isNotify = TRUE;
+	m_bNoticeTray = TRUE;
+#endif
 }
 
 CMainFrame::~CMainFrame()
 {
 }
 
+
+#if USE_TRAYICON
+void CMainFrame::InitTrayIcon()
+{
+	m_trayIcon.SetNotificationWnd(this, WM_MY_TRAY_NOTIFICATION);
+	m_trayIcon.SetIcon(IDR_MAINFRAME, _T("UB530"));
+	m_trayIcon.SetIconInfos(IDR_MAINFRAME, IDR_MAINFRAME, IDR_MAINFRAME);
+	m_trayIcon.SetDefaultTip(_T("UB530"));
+}
+
+LRESULT CMainFrame::OnTaskBarCreated(WPARAM wp, LPARAM lp)
+{
+	Shell_NotifyIcon(NIM_ADD, &m_trayIcon.m_nid);
+	return 0;
+}
+
+// Handle notification from tray icon: display a message.
+LRESULT CMainFrame::OnTrayNotification(WPARAM uID, LPARAM lEvent)
+{
+	if (m_isNotify)
+	{
+		static LPCSTR MouseMessages[] = { "WM_MOUSEMOVE",
+			"WM_LBUTTONDOWN", "WM_LBUTTONUP", "WM_LBUTTONDBLCLK",
+			"WM_RBUTTONDOWN", "WM_RBUTTONUP", "WM_RBUTTONDBLCLK",
+			"WM_MBUTTONDOWN", "WM_MBUTTONUP", "WM_MBUTTONDBLCLK" };
+	}
+
+	if (uID != IDR_MAINFRAME)
+		return m_trayIcon.OnTrayNotification(uID, lEvent);
+
+	switch (lEvent)
+	{
+	case WM_RBUTTONUP:
+		TrayRight();
+		break;
+	case WM_LBUTTONUP:
+		break;
+	case WM_LBUTTONDBLCLK:
+		TaskNotifyIcon();
+		break;
+	default:
+		break;
+	}
+	return 0;
+}
+
+void CMainFrame::TrayRight()
+{
+	CMenu menu;
+	if (!menu.LoadMenu(IDR_MAINFRAME))
+		return;
+
+	CMenu* pSubMenu = menu.GetSubMenu(4);
+	if (!pSubMenu)
+		return;
+
+	CPoint point;
+	GetCursorPos(&point);
+	::SetForegroundWindow(m_hWnd);
+	pSubMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);
+}
+
+void CMainFrame::TaskNotifyIcon()
+{
+	if (!m_bNoticeTray)
+	{
+		m_trayIcon.SetIcon(IDR_MAINFRAME, _T("UB530采集程序"));
+		ShowWindow(SW_SHOWNORMAL);
+		m_bNoticeTray = TRUE;
+	}
+	else
+	{
+		m_trayIcon.SetIcon(IDR_MAINFRAME, _T("UB530采集程序"));
+		ShowWindow(SW_HIDE);
+		m_bNoticeTray = FALSE;
+	}
+}
+#endif
+
 int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
 {
 	if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1)
 		return -1;
 
+#if USE_TRAYICON
+	InitTrayIcon();
+#endif
+
 	BOOL bNameValid;
 
 #if __TAB_BAR__

+ 45 - 0
SATHelper/SATHelper/MainFrm.h

@@ -19,6 +19,11 @@
 #include "PropertiesWnd.h"
 #include "CalendarBar.h"
 #include "Resource.h"
+//////////////////////////////////////////////////////////////////////////
+#include "TrayIcon.h"
+#define USE_TRAYICON 1
+// 状态栏消息;
+#define MSG_STATUS_BAR (WM_USER + 101)
 
 class COutlookBar : public CMFCOutlookBar
 {
@@ -106,6 +111,46 @@ protected:
 	CMFCOutlookBarTabCtrl* FindOutlookParent(CWnd* pWnd);
 	CMFCOutlookBarTabCtrl* m_pCurrOutlookWnd;
 	CMFCOutlookBarPane*    m_pCurrOutlookPage;
+
+public:
+#if USE_TRAYICON
+	void InitTrayIcon();
+
+	// 托盘是否显示;
+	BOOL			m_isNotify;
+
+	// 启动程序时,隐藏或显示对话框,在消息处理程序OnNcPaint()中使用;
+	BOOL            m_bShowNc;
+
+	// 是否响应托盘消息;
+	BOOL            m_bNoticeTray;
+
+	// 托盘工作类;
+	ITrayIcon		m_trayIcon;
+	BOOL			m_bAutoRuning;
+
+	afx_msg LRESULT OnTrayNotification(WPARAM wp, LPARAM lp);
+	afx_msg LRESULT OnTaskBarCreated(WPARAM   wp, LPARAM   lp);
+	void TaskNotifyIcon();	// 托盘的工作内容;
+	void TrayRight();
+#endif
+
+	CMFCRibbonButton* GetRibbonButton(int uId) {
+		return DYNAMIC_DOWNCAST(CMFCRibbonButton, m_wndRibbonBar.FindByID(uId));
+	}
+
+	// 设置状态栏文本;
+	void SetRibbonStatusBarText(CString strText, int uId) {
+		if (IsWindow(m_wndStatusBar))
+		{
+			CMFCRibbonBaseElement* pElement = m_wndStatusBar.FindByID(uId);
+			if (pElement)
+			{
+				pElement->SetText(strText);
+				pElement->Redraw();
+			}
+		}
+	}
 };
 
 

+ 8 - 8
SATHelper/SATHelper/MemoryClient.cpp

@@ -5,7 +5,7 @@
 #include "Global.h"
 #include "MainFrm.h"
 
-CVideoCaptureView* CMemoryClient::m_pView = NULL;
+CSATHelperView* CMemoryClient::m_pView = NULL;
 HANDLE CMemoryClient::m_hRecordFile = NULL;
 HANDLE CMemoryClient::m_hThreadAudio = NULL;
 BOOL CMemoryClient::m_bCapture = FALSE;
@@ -101,7 +101,7 @@ DWORD CMemoryClient::ThreadProc(LPVOID lpVoid)
 						CMD_Result result;
 						unsigned short nIndex = 0;
 						memcpy(&nIndex, ((BYTE*)pThis->m_pMemory) + sizeof(CommandHead), sizeof(unsigned short));
-						result.bResult = m_pView->HwInitialize();
+						//result.bResult = m_pView->HwInitialize();
 
 						// 返回结果;						
 						result.cmdHead = cmdHead;
@@ -116,7 +116,7 @@ DWORD CMemoryClient::ThreadProc(LPVOID lpVoid)
 						CMD_Result result;
 						unsigned short nIndex = 0;
 						memcpy(&nIndex, ((BYTE*)pThis->m_pMemory) + sizeof(CommandHead), sizeof(unsigned short));
-						result.bResult = m_pView->HwUninitialize();
+						//result.bResult = m_pView->HwUninitialize();
 						m_pView->Invalidate();
 
 						// 返回结果;						
@@ -270,7 +270,7 @@ BOOL CMemoryClient::CaptureImage(const CMD_CaputerImage& cmd, BOOL bSingle)
 			}
 		}
 
-		m_pView->CaptureMultiImageEx(cmd.szSaveDir, cmd.szPrefix, bIsJPG, cmd.nKeepTime);
+		//m_pView->CaptureMultiImageEx(cmd.szSaveDir, cmd.szPrefix, bIsJPG, cmd.nKeepTime);
 	}
 	else
 	{// 单张;
@@ -304,13 +304,13 @@ BOOL CMemoryClient::CaptureImage(const CMD_CaputerImage& cmd, BOOL bSingle)
 					strFile.append(_T("\\"));
 			}
 
-			m_pView->CaptureSingleImageAutoNameEx(strFile.c_str(), bIsJPG);
+			//m_pView->CaptureSingleImageAutoNameEx(strFile.c_str(), bIsJPG);
 		}
 		else
 		{
 			TCHAR szFile[MAX_PATH] = { 0 };
 			_stprintf_s(szFile, _T("%s"), cmd.szSaveDir);
-			m_pView->CaptureSingleImageEx(szFile, bIsJPG);
+			//m_pView->CaptureSingleImageEx(szFile, bIsJPG);
 		}
 		// 等待磁盘完成写入;
 		//Sleep(bIsJPG ? 200 : 200);
@@ -327,12 +327,12 @@ BOOL CMemoryClient::SynCaptureAudio(const CMD_CaputerAudio& cmd)
 
 BOOL CMemoryClient::AsyCaptureAudio(const CMD_CaputerAudio& cmd)
 {
-	m_pView->StartRecord(cmd.dwDuration, cmd.szSaveDir);
+	//m_pView->StartRecord(cmd.dwDuration, cmd.szSaveDir);
 	return TRUE;
 }
 
 BOOL CMemoryClient::StopCaptureAudio()
 {
-	m_pView->StopRecord();
+	//m_pView->StopRecord();
 	return TRUE;
 }

+ 3 - 3
SATHelper/SATHelper/MemoryClient.h

@@ -5,8 +5,8 @@
 
 #include "MemoryDef.h"
 #include "MemoryComm.h"
-#include "VideoCaptureView.h"
- class CVideoCaptureView;
+#include "SATHelperView.h"
+class CSATHelperView;
 
 class CMemoryClient:public CMemoryComm
 {
@@ -21,7 +21,7 @@ private:
 	static BOOL m_bIsConnect;
 	static HANDLE m_hThreadAudio;
 public:
-	static CVideoCaptureView* m_pView;
+	static CSATHelperView* m_pView;
 	static HANDLE m_hRecordFile;
 	BOOL StartThread();
 	void EndOfThread();

+ 8 - 5
SATHelper/SATHelper/SATHelper.vcxproj

@@ -30,7 +30,7 @@
     <ConfigurationType>Application</ConfigurationType>
     <UseDebugLibraries>true</UseDebugLibraries>
     <PlatformToolset>v142</PlatformToolset>
-    <CharacterSet>Unicode</CharacterSet>
+    <CharacterSet>MultiByte</CharacterSet>
     <UseOfMfc>Dynamic</UseOfMfc>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
@@ -38,7 +38,7 @@
     <UseDebugLibraries>false</UseDebugLibraries>
     <PlatformToolset>v142</PlatformToolset>
     <WholeProgramOptimization>true</WholeProgramOptimization>
-    <CharacterSet>Unicode</CharacterSet>
+    <CharacterSet>MultiByte</CharacterSet>
     <UseOfMfc>Dynamic</UseOfMfc>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
@@ -95,7 +95,7 @@
       <PrecompiledHeader>Use</PrecompiledHeader>
       <WarningLevel>Level3</WarningLevel>
       <Optimization>Disabled</Optimization>
-      <SDLCheck>true</SDLCheck>
+      <SDLCheck>false</SDLCheck>
       <PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
       <AdditionalIncludeDirectories>..\UI;..\filehelper;..\cJson</AdditionalIncludeDirectories>
@@ -145,7 +145,7 @@
       <Optimization>MaxSpeed</Optimization>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <IntrinsicFunctions>true</IntrinsicFunctions>
-      <SDLCheck>true</SDLCheck>
+      <SDLCheck>false</SDLCheck>
       <PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
       <AdditionalIncludeDirectories>..\UI;..\filehelper;..\cJson</AdditionalIncludeDirectories>
@@ -270,7 +270,10 @@
     <ClCompile Include="SATHelperDoc.cpp" />
     <ClCompile Include="SATHelperView.cpp" />
     <ClCompile Include="SynSerial.cpp" />
-    <ClCompile Include="tinyxml2.cpp" />
+    <ClCompile Include="tinyxml2.cpp">
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
+    </ClCompile>
     <ClCompile Include="TrayIcon.cpp" />
     <ClCompile Include="ViewTree.cpp" />
   </ItemGroup>

+ 1 - 0
SATHelper/SATHelper/SATHelperView.h

@@ -13,6 +13,7 @@
 //
 
 #pragma once
+#include "SATHelperDoc.h"
 
 
 class CSATHelperView : public CView

+ 32 - 2
SATHelper/SATHelper/stdafx.h

@@ -10,6 +10,14 @@
 // 添加要在此处预编译的标头
 #include "framework.h"
 
+#include <thread>
+#include <future>               // std::async, std::future
+#include <chrono>   
+#include <mutex>
+#include <condition_variable>
+using namespace std;
+using namespace chrono;
+
 // 启停停靠窗口;
 #define __DOCKINGBAR__ 1
 // 启停导航栏;
@@ -24,7 +32,29 @@
 #define __FC_WIN__ 0
 // Pane使用对话框;
 #define __PANE_DLG__ 0
-// 禁用选项卡标题;
-#define __TAB_BAR__ 0
+
+//////////////////////////////////////////////////////////////////////////
+// START;
+#include <VFW.H>
+//#include "AMESDK.H"
+#include "QCAP.H"
+#define FREE( p ) { if( p ) { free( p ); p = NULL; } }	
+
+// SET INITIAL PARAMETER VALUES
+// CY3014 USB
+#define	SC_DEFAULT_STANDARD                 0		// 0 = NTSC / 1 = PALB
+#define SC_DEFAULT_INPUT_SUPPORT			0x00000000	// HDMI
+#define DEFAULT_PRODUCT						"StreamCatcher QCAP - UB658G"
+#define DEFAULT_PRODUCT_VERSION				""
+// END
+//////////////////////////////////////////////////////////////////////////
+#include <string>
+#include <map>
+#include "Global.h"
+#include <afxcontrolbars.h>
+#include "tinyxml2.h"
+#include "cJSON.h"
+#include "Device.h"
+#include <afxext.h>
 
 #endif //PCH_H