diff --git a/TopUI.sln b/TopUI.sln
index 04a6860..5094345 100644
--- a/TopUI.sln
+++ b/TopUI.sln
@@ -7,9 +7,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestApp1", "demo\TestApp1\T
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Launcher", "demo\Launcher\Launcher.vcxproj", "{A9AB5B7E-074C-49E5-B039-90655217701B}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Downloader", "demo\Downloader\Downloader.vcxproj", "{CCF86175-4572-490D-977E-9ECA4D24E79E}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
+ dsad|Win32 = dsad|Win32
Release|Win32 = Release|Win32
UnicodeDebug|Win32 = UnicodeDebug|Win32
UnicodeRelease|Win32 = UnicodeRelease|Win32
@@ -17,6 +20,8 @@ Global
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{41B017E7-7805-40D5-9D96-AABF572F57D1}.Debug|Win32.ActiveCfg = Debug|Win32
{41B017E7-7805-40D5-9D96-AABF572F57D1}.Debug|Win32.Build.0 = Debug|Win32
+ {41B017E7-7805-40D5-9D96-AABF572F57D1}.dsad|Win32.ActiveCfg = UnicodeDebug|Win32
+ {41B017E7-7805-40D5-9D96-AABF572F57D1}.dsad|Win32.Build.0 = UnicodeDebug|Win32
{41B017E7-7805-40D5-9D96-AABF572F57D1}.Release|Win32.ActiveCfg = Release|Win32
{41B017E7-7805-40D5-9D96-AABF572F57D1}.Release|Win32.Build.0 = Release|Win32
{41B017E7-7805-40D5-9D96-AABF572F57D1}.UnicodeDebug|Win32.ActiveCfg = UnicodeDebug|Win32
@@ -25,12 +30,24 @@ Global
{41B017E7-7805-40D5-9D96-AABF572F57D1}.UnicodeRelease|Win32.Build.0 = UnicodeRelease|Win32
{A9AB5B7E-074C-49E5-B039-90655217701B}.Debug|Win32.ActiveCfg = Debug|Win32
{A9AB5B7E-074C-49E5-B039-90655217701B}.Debug|Win32.Build.0 = Debug|Win32
+ {A9AB5B7E-074C-49E5-B039-90655217701B}.dsad|Win32.ActiveCfg = Release|Win32
+ {A9AB5B7E-074C-49E5-B039-90655217701B}.dsad|Win32.Build.0 = Release|Win32
{A9AB5B7E-074C-49E5-B039-90655217701B}.Release|Win32.ActiveCfg = Release|Win32
{A9AB5B7E-074C-49E5-B039-90655217701B}.Release|Win32.Build.0 = Release|Win32
{A9AB5B7E-074C-49E5-B039-90655217701B}.UnicodeDebug|Win32.ActiveCfg = UnicodeDebug|Win32
{A9AB5B7E-074C-49E5-B039-90655217701B}.UnicodeDebug|Win32.Build.0 = UnicodeDebug|Win32
{A9AB5B7E-074C-49E5-B039-90655217701B}.UnicodeRelease|Win32.ActiveCfg = UnicodeRelease|Win32
{A9AB5B7E-074C-49E5-B039-90655217701B}.UnicodeRelease|Win32.Build.0 = UnicodeRelease|Win32
+ {CCF86175-4572-490D-977E-9ECA4D24E79E}.Debug|Win32.ActiveCfg = Debug|Win32
+ {CCF86175-4572-490D-977E-9ECA4D24E79E}.Debug|Win32.Build.0 = Debug|Win32
+ {CCF86175-4572-490D-977E-9ECA4D24E79E}.dsad|Win32.ActiveCfg = Debug|Win32
+ {CCF86175-4572-490D-977E-9ECA4D24E79E}.dsad|Win32.Build.0 = Debug|Win32
+ {CCF86175-4572-490D-977E-9ECA4D24E79E}.Release|Win32.ActiveCfg = Release|Win32
+ {CCF86175-4572-490D-977E-9ECA4D24E79E}.Release|Win32.Build.0 = Release|Win32
+ {CCF86175-4572-490D-977E-9ECA4D24E79E}.UnicodeDebug|Win32.ActiveCfg = Debug|Win32
+ {CCF86175-4572-490D-977E-9ECA4D24E79E}.UnicodeDebug|Win32.Build.0 = Debug|Win32
+ {CCF86175-4572-490D-977E-9ECA4D24E79E}.UnicodeRelease|Win32.ActiveCfg = Release|Win32
+ {CCF86175-4572-490D-977E-9ECA4D24E79E}.UnicodeRelease|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/bin/skin/menu.xml b/bin/skin/menu.xml
index 4137249..8902b9d 100644
--- a/bin/skin/menu.xml
+++ b/bin/skin/menu.xml
@@ -10,6 +10,9 @@
+
+
+
\ No newline at end of file
diff --git a/demo/Downloader/App.cpp b/demo/Downloader/App.cpp
new file mode 100644
index 0000000..a04a1ed
--- /dev/null
+++ b/demo/Downloader/App.cpp
@@ -0,0 +1,28 @@
+// App.cpp : Defines the entry point for the application.
+//
+#include "stdafx.h"
+#include "MainWnd.h"
+#include "resource.h"
+
+int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nCmdShow)
+{
+
+ CPaintManagerUI::SetInstance(hInstance);
+ CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + _T("..//x86"));
+
+ HRESULT Hr = ::CoInitialize(NULL);
+ if (FAILED(Hr)) return 0;
+
+ CMainWnd* pFrame = new CMainWnd();
+ pFrame->Create(NULL, NULL, UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE | WS_EX_ACCEPTFILES);
+ pFrame->SetIcon(IDI_ICON1);
+ pFrame->CenterWindow();
+ pFrame->ShowWindow(true);
+
+ CPaintManagerUI::MessageLoop();
+
+ ::CoUninitialize();
+ return 0;
+}
+
+
diff --git a/demo/Downloader/CalendarUI.cpp b/demo/Downloader/CalendarUI.cpp
new file mode 100644
index 0000000..66ec0bb
--- /dev/null
+++ b/demo/Downloader/CalendarUI.cpp
@@ -0,0 +1,177 @@
+#include "stdafx.h"
+#include "CalendarUI.h"
+
+CalendarUI::CalendarUI()
+:m_bTag(true)
+{
+
+}
+
+
+CalendarUI::~CalendarUI()
+{
+}
+
+DUI_BEGIN_MESSAGE_MAP(CalendarUI, WindowImplBase)
+DUI_ON_CLICK_CTRNAME(BT_CANCEL, OnClose)
+DUI_END_MESSAGE_MAP()
+
+LPCTSTR CalendarUI::GetWindowClassName() const
+{
+ return _T("CLogUI");
+}
+
+CDuiString CalendarUI::GetSkinFolder()
+{
+ return _T("..//x86");
+}
+
+CDuiString CalendarUI::GetSkinFile()
+{
+ return _T("CalendarUI.xml");
+}
+
+void CalendarUI::OnFinalMessage(HWND hWnd)
+{
+ WindowImplBase::OnFinalMessage(hWnd);
+ delete this;
+}
+
+void CalendarUI::Notify(TNotifyUI& msg)
+{
+ if (msg.sType == DUI_MSGTYPE_CLICK)
+ {
+ STDSTRING btnName = msg.pSender->GetName();
+ STDSTRING strTag(_T("Button"));
+ int iRet = btnName.compare(0, 6, strTag);
+ if (iRet == 0){
+ Close();
+ }
+ if (btnName == _T("Add_Year")){
+ m_sysTime.wYear = m_sysTime.wYear + 1;
+ DrawCalendar(m_sysTime);
+ }
+ if (btnName == _T("Sub_Year")){
+ m_sysTime.wYear = m_sysTime.wYear - 1;
+ DrawCalendar(m_sysTime);
+ }
+ }
+ if (m_bTag)
+ {
+ OnPrepare();
+ m_PrevMonth = m_sysTime.wMonth;
+ m_bTag = false;
+ }
+ if (msg.sType == DUI_MSGTYPE_ITEMSELECT && msg.pSender->GetName() == _T("CB_month"))
+ {
+ CComboUI* Comb = static_cast(m_PaintManager.FindControl(_T("CB_month")));
+ int newmonth = Comb->GetCurSel() + 1;
+ if (newmonth > m_PrevMonth){
+ m_sysTime.wMonth = m_sysTime.wMonth + newmonth - m_PrevMonth;
+ DrawCalendar(m_sysTime);
+ }
+ else if(newmonth < m_PrevMonth){
+ m_sysTime.wMonth = m_sysTime.wMonth + newmonth - m_PrevMonth;
+ DrawCalendar(m_sysTime);
+ }
+ m_PrevMonth = newmonth;
+ }
+ WindowImplBase::Notify(msg);
+}
+
+void CalendarUI::OnClose(TNotifyUI& msg)
+{
+ Close();
+}
+
+void CalendarUI::OnPrepare()
+{
+ ::GetLocalTime(&m_sysTime);
+ DrawCalendar(m_sysTime);
+}
+
+STDSTRING CalendarUI::intToString(int num)
+{
+ char Tmp[10] = { 0 };
+ _itoa(num, Tmp, 10);
+ STDSTRING result(Tmp);
+ return result;
+}
+
+//
+void CalendarUI::DrawCalendar(SYSTEMTIME m_sysTime)
+{
+ int iDay = 0;
+ STDSTRING cDay, cMonth, cYear;
+ STDSTRING itemName, BtnName;
+ //int iStartDay = m_sysTime.wDayOfWeek;
+ m_sysTime.wDay = 1;
+ int iStartDay = GetDayOfWeek(m_sysTime);
+ //
+ int iLastMonthStartDays = 31 - iStartDay;
+ if (m_sysTime.wMonth > 1)
+ iLastMonthStartDays = GetMonthDays(m_sysTime.wYear, m_sysTime.wMonth - 1) - iStartDay;
+ //
+ int iMonthDays = GetMonthDays(m_sysTime.wYear, m_sysTime.wMonth);
+ //
+ int iNextMonthDays = 0;
+
+ for (int i = 0; i < 42; i++)
+ {
+ BtnName = "Button" + intToString(i);
+ CButtonUI* btn = static_cast(m_PaintManager.FindControl(BtnName.c_str()));
+ //
+ if (iSetText(cDay.c_str());
+ btn->SetBkColor(0x64263232);
+ }
+ else if (i>iStartDay - 1 && iDay < iMonthDays)
+ {
+ iDay++;
+ cDay = intToString(iDay);
+ btn->SetText(cDay.c_str());
+ btn->SetBkColor(0xc3324534);
+ }
+ else
+ {
+ iNextMonthDays++;
+ cDay = intToString(iNextMonthDays);
+ btn->SetText(cDay.c_str());
+ btn->SetBkColor(0x64263232);
+ }
+ }
+
+ cMonth = intToString(m_sysTime.wMonth);
+ itemName = "Item" + cMonth;
+ CListLabelElementUI* itemLabe = static_cast(m_PaintManager.FindControl(itemName.c_str()));
+ itemLabe->Select(true);
+
+ cYear = intToString(m_sysTime.wYear);
+ CLabelUI* edit_year = static_cast(m_PaintManager.FindControl(_T("InputYear")));
+ edit_year->SetText(cYear.c_str());
+}
+
+
+int CalendarUI::GetMonthDays(int iY, int iM)
+{
+ int iTotalDay = 31;
+ if (iM == 2)
+ {
+ if (iY % 4 == 0 && iY % 100 != 0 || iY % 400 == 0)
+ iTotalDay = 29;
+ else
+ iTotalDay = 28;
+ }
+ else if (iM == 4 || iM == 6 || iM == 9 || iM == 11)
+ iTotalDay = 30;
+ return iTotalDay;
+}
+
+int CalendarUI::GetDayOfWeek(SYSTEMTIME m_sysTime)
+{
+ m_ctime.SetDate(m_sysTime.wYear, m_sysTime.wMonth, m_sysTime.wDay);
+ return m_ctime.GetDayOfWeek() - 1;
+}
diff --git a/demo/Downloader/CalendarUI.h b/demo/Downloader/CalendarUI.h
new file mode 100644
index 0000000..f5f73db
--- /dev/null
+++ b/demo/Downloader/CalendarUI.h
@@ -0,0 +1,37 @@
+#pragma once
+#include
+#include "DownLoadWnd.h"
+
+#include
+
+#define BT_CANCEL (_T("closebtn1"))
+
+
+class CalendarUI :
+ public WindowImplBase
+{
+public:
+ CalendarUI();
+ ~CalendarUI();
+ virtual void OnFinalMessage(HWND /*hWnd*/);
+ virtual void Notify(TNotifyUI& msg);
+ DUI_DECLARE_MESSAGE_MAP();
+ void OnClose(TNotifyUI& msg);
+
+ STDSTRING intToString(int num);
+
+ void OnPrepare();
+ void DrawCalendar(SYSTEMTIME m_sysTime);
+ int GetDayOfWeek(SYSTEMTIME m_sysTime);
+ int GetMonthDays(int iY, int iM);
+
+private:
+ BOOL m_bTag;
+ SYSTEMTIME m_sysTime;
+ COleDateTime m_ctime;
+ int m_PrevMonth;
+protected:
+ virtual LPCTSTR GetWindowClassName() const;
+ virtual CDuiString GetSkinFolder();
+ virtual CDuiString GetSkinFile();
+};
diff --git a/demo/Downloader/DownLoadWnd.cpp b/demo/Downloader/DownLoadWnd.cpp
new file mode 100644
index 0000000..27452f8
--- /dev/null
+++ b/demo/Downloader/DownLoadWnd.cpp
@@ -0,0 +1,271 @@
+#include "stdafx.h"
+#include "DownLoadWnd.h"
+#include "CalendarUI.h"
+#include "VideoLoginUI.h"
+#include "SearchFileUI.h"
+
+DownLoadWnd::DownLoadWnd()
+:m_FileCount(0)
+{
+ m_Vendor.SetPaintMagager(&m_PaintManager);
+ AddVirtualWnd(_T("Vendor"), &m_Vendor);
+}
+
+
+DownLoadWnd::~DownLoadWnd()
+{
+ RemoveVirtualWnd(_T("Vendor"));
+}
+
+
+DUI_BEGIN_MESSAGE_MAP(DownLoadWnd, WindowImplBase)
+DUI_ON_CLICK_CTRNAME(BT_OnVideoLoginUI, OnVideoLoginWnd)
+DUI_END_MESSAGE_MAP()
+
+STDSTRING DownLoadWnd::intToString(int num)
+{
+ char Tmp[10] = { 0 };
+ _itoa(num, Tmp, 10);
+ STDSTRING result(Tmp);
+ return result;
+}
+
+LPCTSTR DownLoadWnd::GetWindowClassName() const
+{
+ return _T("DownLoadWnd");
+}
+
+CDuiString DownLoadWnd::GetSkinFolder()
+{
+ return _T("..//x86");
+}
+
+CDuiString DownLoadWnd::GetSkinFile()
+{
+ return _T("Download.xml");
+}
+
+void DownLoadWnd::OnFinalMessage(HWND hWnd)
+{
+ WindowImplBase::OnFinalMessage(hWnd);
+ delete this;
+}
+
+void DownLoadWnd::OnSelectTimeType()
+{
+ CSliderUI* Slider = static_cast(m_PaintManager.FindControl(_T("Select_time")));
+ if (Slider->GetValue() > 50)
+ {
+ Slider->SetValue(100);
+ }
+ else
+ {
+ Slider->SetValue(0);
+ }
+}
+
+void DownLoadWnd::OnSelectCalendar()
+{
+ CalendarUI* pDlg = new CalendarUI();
+ assert(pDlg);
+ pDlg->Create(this->GetHWND(), NULL, UI_WNDSTYLE_EX_DIALOG, 0L, 0, 0, 350, 380);
+ pDlg->CenterWindow();
+ pDlg->ShowModal();
+}
+
+void DownLoadWnd::OnVideoLoginWnd(TNotifyUI& msg)
+{
+ VideoLoginUI* pDlg = new VideoLoginUI();
+ assert(pDlg);
+ pDlg->Create(this->GetHWND(), NULL, UI_WNDSTYLE_EX_DIALOG, 0L, 0, 0, 1024, 768);
+ pDlg->CenterWindow();
+ pDlg->ShowModal();
+}
+
+void DownLoadWnd::OnSearchFileWnd()
+{
+ SearchFileUI* pDlg = new SearchFileUI();
+ assert(pDlg);
+ pDlg->Create(this->GetHWND(), NULL, UI_WNDSTYLE_EX_DIALOG, 0L, 0, 0, 1024, 600);
+ pDlg->CenterWindow();
+ pDlg->ShowModal();
+}
+
+void DownLoadWnd::Notify(TNotifyUI& msg)
+{
+ STDSTRING strSendName = msg.pSender->GetName();
+ if (msg.sType == DUI_MSGTYPE_VALUECHANGED && strSendName == _T("Select_time")){
+ OnSelectTimeType();
+ }
+ if (msg.sType == DUI_MSGTYPE_ITEMCLICK && !strSendName.compare(0, SUBLISTNAMELONG, SUBLISTNAMETAG)){
+ CListUI* m_List = static_cast(m_PaintManager.FindControl(_T("DownloadList")));
+
+ int filesize = 5;
+ STDSTRING strUserData;
+ CListContainerElementUI* ContList = static_cast(m_PaintManager.FindSubControlByName(m_List, strSendName.c_str()));
+ int CurSel = GetSubListCurSel(ContList);
+ CListContainerElementUI* SubContList = static_cast(m_PaintManager.FindSubControlByClass(m_List, DUI_CTR_LISTCONTAINERELEMENT, CurSel + 1));
+ if (SubContList == NULL)
+ {
+ if (ContList->GetUserData() == _T("0"))
+ {
+ CListContainerElementUI* SubList = new CListContainerElementUI;
+ for (int i = CurSel + 1; i <= CurSel + filesize; i++)
+ {
+ SubList = Add_FileInfoList(i, false);
+ SubList->SetUserData(_T("Sub"));
+ m_List->AddAt(SubList, i);
+ }
+ strUserData = intToString(filesize);
+ ContList->SetUserData(strUserData.c_str());
+ }
+ }
+ else{
+ if (ContList->GetUserData() == _T("0") && SubContList->GetUserData() != _T("Sub"))
+ {
+ CListContainerElementUI* SubList = new CListContainerElementUI;
+ for (int i = CurSel + 1; i <= CurSel + filesize; i++)
+ {
+ SubList = Add_FileInfoList(i, false);
+ SubList->SetUserData(_T("Sub"));
+ m_List->AddAt(SubList, i);
+ }
+ strUserData = intToString(filesize);
+ ContList->SetUserData(strUserData.c_str());
+ }
+ if (ContList->GetUserData() != _T("0") && SubContList->GetUserData() == _T("Sub"))
+ {
+ strUserData = ContList->GetUserData();
+ int Count = atoi(strUserData.c_str());
+ for (int j = CurSel + 1; j <= CurSel + Count; j++)
+ {
+ m_List->RemoveAt(CurSel + 1, false);
+ }
+ ContList->SetUserData(_T("0"));
+ }
+ }
+ }
+ if (msg.sType == DUI_MSGTYPE_CLICK){
+ if (msg.pSender->GetName() == BT_Calendar1 || msg.pSender->GetName() == BT_Calendar2){
+ OnSelectCalendar();
+ }
+ if (msg.pSender->GetName() == _T("Search")){
+ OnSearchFileWnd();
+ }
+ if (msg.pSender->GetName() == _T("test"))
+ {
+ if (SearchFiles()){
+ ShowFileList();
+ }
+ }
+ if (!strSendName.compare(0, BTNAMELONG, BTNAMETAG))
+ {
+ CListUI* pList = static_cast(m_PaintManager.FindControl(_T("DownloadList")));
+ STDSTRING Serial = strSendName.substr(BTNAMELONG);
+ STDSTRING ContListName = SUBLISTNAMETAG + Serial;
+ CListContainerElementUI* ContList = static_cast(m_PaintManager.FindSubControlByName(pList, ContListName.c_str()));
+ int ContListserial = GetSubListCurSel(ContList);
+ STDSTRING SubListCount = ContList->GetUserData();
+ int Count = atoi(SubListCount.c_str());
+ for (int i = 0; i <= Count; i++)
+ {
+ pList->RemoveAt(ContListserial, true);
+ }
+ }
+ }
+ WindowImplBase::Notify(msg);
+}
+
+
+BOOL DownLoadWnd::SearchFiles()
+{
+ return true;
+ //m_fileInfo.clear();
+ //search files
+}
+
+void DownLoadWnd::ShowFileList()
+{
+ CListUI* pList = static_cast(m_PaintManager.FindControl(_T("DownloadList")));
+ //pList->RemoveAll();
+ CListContainerElementUI* SubList = new CListContainerElementUI;
+
+ SubList = Add_FileInfoList(1, true);
+ pList->Add(SubList);
+}
+
+
+CListContainerElementUI* DownLoadWnd::Add_FileInfoList(int n, bool IsShowCloseBT)
+{
+ m_FileCount = m_FileCount + n;
+ CListContainerElementUI* Sublist = new CListContainerElementUI;
+ CHorizontalLayoutUI* hLyt = new CHorizontalLayoutUI;
+
+ CLabelUI* Lab_Name = new CLabelUI;
+ CLabelUI* Lab_Size = new CLabelUI;
+ CProgressUI* Pro_Download = new CProgressUI;
+ CLabelUI* Lab_Speed = new CLabelUI;
+ CLabelUI* Lab_LastTime = new CLabelUI;
+ CLabelUI* Lab_State = new CLabelUI;
+ CButtonUI* BT_Cancel = new CButtonUI;
+ CTreeViewUI* sas = new CTreeViewUI;
+
+ if (IsShowCloseBT){
+ STDSTRING SublistName = SUBLISTNAMETAG + intToString(m_FileCount);
+ Sublist->SetUserData(_T("0"));
+ Sublist->SetName(SublistName.c_str());
+ }
+ Sublist->SetFixedHeight(30);
+ Sublist->Add(hLyt);
+ hLyt->Add(Lab_Name);
+ hLyt->Add(Lab_Size);
+ hLyt->Add(Pro_Download);
+ hLyt->Add(Lab_Speed);
+ hLyt->Add(Lab_LastTime);
+ hLyt->Add(Lab_State);
+ hLyt->Add(BT_Cancel);
+
+ Lab_Name->SetAttributeList("width=\"150\" align=\"center\" font=\"2\"");
+ Lab_Name->SetText(_T("name"));
+ Lab_Size->SetAttributeList("width=\"100\" align=\"center\" font=\"2\"");
+ Lab_Size->SetText(_T("size"));
+
+ STDSTRING ProgressName = STDSTRING(_T("progress")) + intToString(m_FileCount);
+ Pro_Download->SetAttributeList(_T("width=\"140\" height=\"12\" padding=\"10,8,10,8\" font=\"3\" bordersize=\"1\" bordercolor=\"0xf1234567\" foreimage=\"file='Downloader/jindutiao.png'\""));
+ Pro_Download->SetValue(50);
+ Pro_Download->SetText(_T("50%"));
+ Pro_Download->SetName(ProgressName.c_str());
+
+
+ Lab_Speed->SetAttributeList("width=\"100\" align=\"center\" font=\"2\"");
+ Lab_Speed->SetText(_T("speed"));
+ Lab_LastTime->SetAttributeList("width=\"100\" align=\"center\" font=\"2\"");
+ Lab_LastTime->SetText(_T("LastTime"));
+ Lab_State->SetAttributeList("width=\"100\" align=\"center\" font=\"2\"");
+ Lab_State->SetText(_T("State"));
+
+ STDSTRING buttonName = STDSTRING(_T("BT_Cancel")) + intToString(m_FileCount);
+ BT_Cancel->SetAttributeList(_T("width=\"30\" height=\"20\" padding=\"35,5,35,5\" normalimage=\"file='Downloader/hot_del.png' dest='8,3,22,17'\" hotimage=\"file='Downloader/del_download.png' dest='8,3,22,17'\""));
+ BT_Cancel->SetName(buttonName.c_str());
+ BT_Cancel->SetVisible(IsShowCloseBT);
+
+ return Sublist;
+}
+
+
+int DownLoadWnd::GetSubListCurSel(CListContainerElementUI* SubList)
+{
+ CListUI* m_List = static_cast(m_PaintManager.FindControl(_T("DownloadList")));
+ CListContainerElementUI* SubListTmp = new CListContainerElementUI;
+ int CurSel = -1;
+ for (int i = 0; i < m_List->GetCount(); i++)
+ {
+ SubListTmp = static_cast(m_PaintManager.FindSubControlByClass(m_List, DUI_CTR_LISTCONTAINERELEMENT, i));
+ if (SubListTmp->GetName() == SubList->GetName())
+ {
+ CurSel = i;
+ break;
+ }
+ }
+ return CurSel;
+}
\ No newline at end of file
diff --git a/demo/Downloader/DownLoadWnd.h b/demo/Downloader/DownLoadWnd.h
new file mode 100644
index 0000000..7eaf8dc
--- /dev/null
+++ b/demo/Downloader/DownLoadWnd.h
@@ -0,0 +1,58 @@
+#pragma once
+#include
+#include
+#include "Vendor.h"
+
+#define BT_Calendar1 (_T("DataTime1"))
+#define BT_Calendar2 (_T("DataTime2"))
+#define BT_OnVideoLoginUI (_T("Add_device"))
+#define BTNAMELONG 9
+#define SUBLISTNAMELONG 8
+#define BTNAMETAG STDSTRING(_T("BT_Cancel"))
+#define SUBLISTNAMETAG STDSTRING(_T("ContList"))
+
+typedef struct
+{
+ STDSTRING filename;
+ int filesize;
+ STDSTRING process;
+ STDSTRING speed;
+ STDSTRING remain_time;
+ STDSTRING state;
+ STDSTRING handle;
+}FILE_INFO;
+
+class DownLoadWnd :
+ public WindowImplBase
+{
+public:
+ DownLoadWnd();
+ ~DownLoadWnd();
+ virtual void OnFinalMessage(HWND /*hWnd*/);
+ virtual void Notify(TNotifyUI& msg);
+ DUI_DECLARE_MESSAGE_MAP();
+ void OnSelectTimeType();
+ void OnSelectCalendar();
+ void OnSearchFileWnd();
+
+ STDSTRING intToString(int num);
+ void OnVideoLoginWnd(TNotifyUI& msg);
+
+ BOOL SearchFiles();
+ void ShowFileList();
+
+ int GetSubListCurSel(CListContainerElementUI* SubList);
+
+ CListContainerElementUI* Add_FileInfoList(int n, bool IsShowCloseBT);
+
+protected:
+ vector m_fileInfo;
+ virtual LPCTSTR GetWindowClassName() const;
+ virtual CDuiString GetSkinFolder();
+ virtual CDuiString GetSkinFile();
+
+private:
+ CVendor m_Vendor;
+ int m_FileCount;
+};
+
diff --git a/demo/Downloader/Downloader.rc b/demo/Downloader/Downloader.rc
new file mode 100644
index 0000000..44b6d06
Binary files /dev/null and b/demo/Downloader/Downloader.rc differ
diff --git a/demo/Downloader/Downloader.vcxproj b/demo/Downloader/Downloader.vcxproj
new file mode 100644
index 0000000..653d1c6
--- /dev/null
+++ b/demo/Downloader/Downloader.vcxproj
@@ -0,0 +1,156 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+
+ {CCF86175-4572-490D-977E-9ECA4D24E79E}
+ Win32Proj
+ Downloader
+
+
+
+ Application
+ true
+ v120
+ MultiByte
+
+
+ Application
+ false
+ v120
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+ $(SolutionDir)bin\
+ $(ProjectName)_d
+ .\Debug\
+
+
+ false
+ $(SolutionDir)bin\
+ .\Release\
+
+
+
+ Use
+ Level3
+ Disabled
+ WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
+
+
+ $(SolutionDir)\library\;$(SolutionDir)\JSON\include\rapidjson;%(AdditionalIncludeDirectories)
+ ProgramDatabase
+ .\Debug/
+ .\Debug/
+ .\Debug/
+ MultiThreadedDebug
+ .\Debug/TestApp1.pch
+ true
+
+
+ Windows
+ true
+ $(TargetPath)
+ $(SolutionDir)\lib\;%(AdditionalLibraryDirectories)
+ true
+ duilib_d.lib;%(AdditionalDependencies)
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+
+
+ Level3
+ Use
+ MinSpace
+ true
+ false
+ WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
+
+
+ $(SolutionDir)\library\;$(SolutionDir)\JSON\include\rapidjson\;%(AdditionalIncludeDirectories)
+ OnlyExplicitInline
+ true
+ MultiThreaded
+ .\Release/(TargetName).pch
+ false
+
+
+
+
+
+ Windows
+
+
+
+
+
+
+ $(SolutionDir)\lib\;%(AdditionalLibraryDirectories)
+ duilib.lib;%(AdditionalDependencies)
+ .\Release/(TargetName).pdb
+ $(TargetPath)
+
+
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Create
+ Create
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/demo/Downloader/Downloader.vcxproj.filters b/demo/Downloader/Downloader.vcxproj.filters
new file mode 100644
index 0000000..38f9a51
--- /dev/null
+++ b/demo/Downloader/Downloader.vcxproj.filters
@@ -0,0 +1,82 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+
+
+
+ 头文件
+
+
+ 头文件
+
+
+ 头文件
+
+
+ 头文件
+
+
+ 头文件
+
+
+ 头文件
+
+
+ 头文件
+
+
+ 头文件
+
+
+
+
+ 源文件
+
+
+ 源文件
+
+
+ 源文件
+
+
+ 源文件
+
+
+ 源文件
+
+
+ 源文件
+
+
+ 源文件
+
+
+ 源文件
+
+
+
+
+ 资源文件
+
+
+
+
+ 资源文件
+
+
+
\ No newline at end of file
diff --git a/demo/Downloader/LogUI.cpp b/demo/Downloader/LogUI.cpp
new file mode 100644
index 0000000..0b45d91
--- /dev/null
+++ b/demo/Downloader/LogUI.cpp
@@ -0,0 +1,304 @@
+#include "stdafx.h"
+#include "LogUI.h"
+#include "CalendarUI.h"
+#include "CommDlg.h"
+
+CLogUI::CLogUI()
+{
+ m_bInit = TRUE;
+}
+
+CLogUI::~CLogUI()
+{
+}
+
+DUI_BEGIN_MESSAGE_MAP(CLogUI, WindowImplBase)
+DUI_ON_CLICK_CTRNAME(BT_SearchLog, OnBeginSearch)
+DUI_ON_CLICK_CTRNAME(BT_OnStartTime, OnSelectStartTime)
+DUI_ON_CLICK_CTRNAME(BT_OnStopTime, OnSelectStopTime)
+DUI_END_MESSAGE_MAP()
+
+LPCTSTR CLogUI::GetWindowClassName() const
+{
+ return _T("CLogUI");
+}
+
+CDuiString CLogUI::GetSkinFolder()
+{
+ return _T("..//x86");
+}
+
+CDuiString CLogUI::GetSkinFile()
+{
+ return _T("LogUI.xml");
+}
+
+void CLogUI::OnFinalMessage(HWND hWnd)
+{
+ WindowImplBase::OnFinalMessage(hWnd);
+ delete this;
+}
+
+void CLogUI::Notify(TNotifyUI& msg)
+{
+ if (m_bInit)
+ {
+ m_pList = static_cast(m_PaintManager.FindControl(_T("domainlist")));
+ m_bInit = FALSE;
+ }
+ if (msg.sType == DUI_MSGTYPE_CLICK) {
+ if (msg.pSender->GetName() == _T("LogType1")){
+ CreateLogList();
+ }
+ if (msg.pSender->GetName() == _T("LogType2")){
+ CreateCaseList();
+ }
+ if (msg.pSender->GetName() == _T("export")){
+ exportLog();
+ }
+ }
+ WindowImplBase::Notify(msg);
+}
+
+void CLogUI::OnBeginSearch(TNotifyUI& msg)
+{
+ COptionUI* Option1 = static_cast(m_PaintManager.FindControl(_T("LogType1")));
+ if (Option1->IsSelected())
+ {
+ OnSearchLog();
+ InsertLogInfoToList();
+ }
+ else
+ {
+ OnSearchCaseLog();
+ InsertCaseInfoToList();
+ }
+}
+
+void CLogUI::OnSearchLog()
+{
+ m_LogInfo.clear();
+ //Search Log infomaton
+}
+
+void CLogUI::OnSearchCaseLog()
+{
+ m_CaseInfo.clear();
+ //Search case information
+}
+
+void CLogUI::CreateLogList()
+{
+ //create log list
+ m_pList->RemoveAll();
+ CListHeaderUI* list_head = static_cast(m_PaintManager.FindControl(_T("list_head")));
+ CListHeaderUI* newlist = new CListHeaderUI;
+ newlist->SetName(_T("list_head"));
+ CListHeaderItemUI* Item1 = static_cast(m_PaintManager.FindControl(_T("Item1")));
+ CListHeaderItemUI* Item2 = static_cast(m_PaintManager.FindControl(_T("Item2")));
+ CListHeaderItemUI* Item3 = static_cast(m_PaintManager.FindControl(_T("Item3")));
+ CListHeaderItemUI* Item4 = static_cast(m_PaintManager.FindControl(_T("Item4")));
+ CListHeaderItemUI* Item5 = static_cast(m_PaintManager.FindControl(_T("Item5")));
+ CListHeaderItemUI* Item6 = static_cast(m_PaintManager.FindControl(_T("Item6")));
+ CListHeaderItemUI* Item7 = static_cast(m_PaintManager.FindControl(_T("Item7")));
+ CListHeaderItemUI* item1 = new CListHeaderItemUI;
+ CListHeaderItemUI* item2 = new CListHeaderItemUI;
+ CListHeaderItemUI* item3 = new CListHeaderItemUI;
+ CListHeaderItemUI* item4 = new CListHeaderItemUI;
+ CListHeaderItemUI* item5 = new CListHeaderItemUI;
+ CListHeaderItemUI* item6 = new CListHeaderItemUI;
+ CListHeaderItemUI* item7 = new CListHeaderItemUI;
+ item1->SetName(_T("Item1"));
+ item1->SetAttribute(_T("font"), _T("1"));
+ item2->SetName(_T("Item2"));
+ item2->SetAttribute(_T("font"), _T("1"));
+ item3->SetName(_T("Item3"));
+ item3->SetAttribute(_T("font"), _T("1"));
+ item4->SetName(_T("Item4"));
+ item5->SetName(_T("Item5"));
+ item6->SetName(_T("Item6"));
+ item7->SetName(_T("Item7"));
+ item1->SetText(_T("ʱ"));
+ item1->SetFixedWidth(200);
+ item2->SetText(_T(""));
+ item2->SetFixedWidth(300);
+ item3->SetText(_T(""));
+ item3->SetFixedWidth(480);
+ item4->SetFixedWidth(0);
+ item5->SetFixedWidth(0);
+ item6->SetFixedWidth(0);
+ item7->SetFixedWidth(0);
+ list_head->Remove(Item1);
+ list_head->Remove(Item2);
+ list_head->Remove(Item3);
+ list_head->Remove(Item4);
+ list_head->Remove(Item5);
+ list_head->Remove(Item6);
+ list_head->Remove(Item7);
+ m_pList->Remove(list_head);
+ m_pList->Add(newlist);
+ m_pList->SetAttribute(_T("headerbkimage"), _T("file='Downloader/lbl.png'"));
+ newlist->SetFixedHeight(31);
+ newlist->Add(item1);
+ newlist->Add(item2);
+ newlist->Add(item3);
+ newlist->Add(item4);
+ newlist->Add(item5);
+ newlist->Add(item6);
+ newlist->Add(item7);
+
+}
+
+void CLogUI::CreateCaseList()
+{
+ //create case list
+ m_pList->RemoveAll();
+
+ CListHeaderUI* list_head = static_cast(m_PaintManager.FindControl(_T("list_head")));
+ CListHeaderUI* newlist = new CListHeaderUI;
+ newlist->SetName(_T("list_head"));
+ CListHeaderItemUI* Item1 = static_cast(m_PaintManager.FindControl(_T("Item1")));
+ CListHeaderItemUI* Item2 = static_cast(m_PaintManager.FindControl(_T("Item2")));
+ CListHeaderItemUI* Item3 = static_cast(m_PaintManager.FindControl(_T("Item3")));
+ CListHeaderItemUI* Item4 = static_cast(m_PaintManager.FindControl(_T("Item4")));
+ CListHeaderItemUI* Item5 = static_cast(m_PaintManager.FindControl(_T("Item5")));
+ CListHeaderItemUI* Item6 = static_cast(m_PaintManager.FindControl(_T("Item6")));
+ CListHeaderItemUI* Item7 = static_cast(m_PaintManager.FindControl(_T("Item7")));
+ CListHeaderItemUI* item1 = new CListHeaderItemUI;
+ CListHeaderItemUI* item2 = new CListHeaderItemUI;
+ CListHeaderItemUI* item3 = new CListHeaderItemUI;
+ CListHeaderItemUI* item4 = new CListHeaderItemUI;
+ CListHeaderItemUI* item5 = new CListHeaderItemUI;
+ CListHeaderItemUI* item6 = new CListHeaderItemUI;
+ CListHeaderItemUI* item7 = new CListHeaderItemUI;
+ item1->SetName(_T("Item1"));
+ item1->SetAttribute(_T("font"), _T("1"));
+ item2->SetName(_T("Item2"));
+ item2->SetAttribute(_T("font"), _T("1"));
+ item3->SetName(_T("Item3"));
+ item3->SetAttribute(_T("font"), _T("1"));
+ item4->SetName(_T("Item4"));
+ item4->SetAttribute(_T("font"), _T("1"));
+ item5->SetName(_T("Item5"));
+ item5->SetAttribute(_T("font"), _T("1"));
+ item6->SetName(_T("Item6"));
+ item6->SetAttribute(_T("font"), _T("1"));
+ item7->SetName(_T("Item7"));
+ item7->SetAttribute(_T("font"), _T("1"));
+
+ item1->SetText(_T("ʱ"));
+ item1->SetFixedWidth(150);
+ item2->SetText(_T("ص"));
+ item2->SetFixedWidth(100);
+ item3->SetText(_T("ɼ"));
+ item3->SetFixedWidth(100);
+ item4->SetText(_T(""));
+ item4->SetFixedWidth(150);
+ item5->SetText(_T(""));
+ item5->SetFixedWidth(150);
+ item6->SetText(_T("豸IP"));
+ item6->SetFixedWidth(150);
+ item7->SetText(_T(""));
+ item7->SetFixedWidth(180);
+ list_head->Remove(Item1);
+ list_head->Remove(Item2);
+ list_head->Remove(Item3);
+ list_head->Remove(Item4);
+ list_head->Remove(Item5);
+ list_head->Remove(Item6);
+ list_head->Remove(Item7);
+ m_pList->Remove(list_head);
+ m_pList->Add(newlist);
+ m_pList->SetAttribute(_T("headerbkimage"), _T("file='Downloader/lbl.png'"));
+ newlist->SetFixedHeight(31);
+ newlist->Add(item1);
+ newlist->Add(item2);
+ newlist->Add(item3);
+ newlist->Add(item4);
+ newlist->Add(item5);
+ newlist->Add(item6);
+ newlist->Add(item7);
+}
+
+void CLogUI::InsertLogInfoToList()
+{
+ //m_pList->RemoveAll();
+ for (int i = 0; i < 10; i++)
+ {
+ CListTextElementUI* pListElement = new CListTextElementUI;
+ pListElement->SetTag(i);
+ m_pList->Add(pListElement);
+ pListElement->SetAttribute(_T("font"), _T("1"));
+ pListElement->SetFixedHeight(30);
+ pListElement->SetText(0, _T("WHO1753"));
+ pListElement->SetText(1, _T(""));
+ pListElement->SetText(2, _T("100"));
+ }
+
+ //for (UINT i = 0; i < m_LogInfo.size(); i++)
+ //{
+ // CListTextElementUI* pListElement = new CListTextElementUI;
+ // pListElement->SetTag(i);
+ // m_pList->Add(pListElement);
+ // pListElement->SetFixedHeight(30);
+ // pListElement->SetText(0, m_LogInfo[i].Time.c_str());
+ // pListElement->SetText(1, m_LogInfo[i].Handle.c_str());
+ // pListElement->SetText(2, m_LogInfo[i].Description.c_str());
+ //}
+}
+
+void CLogUI::InsertCaseInfoToList()
+{
+ m_pList->RemoveAll();
+ TListInfoUI* List_Info = m_pList->GetListInfo();
+ for (int i = 0; i < 10; i++)
+ {
+ CListTextElementUI* pListElement = new CListTextElementUI;
+ pListElement->SetTag(i);
+ m_pList->Add(pListElement);
+ pListElement->SetFixedHeight(30);
+ pListElement->SetText(0, _T("WHO1753"));
+ pListElement->SetText(1, _T(""));
+ pListElement->SetText(2, _T("100"));
+ pListElement->SetText(3, _T("WHO1753"));
+ pListElement->SetText(4, _T(""));
+ pListElement->SetText(5, _T("100"));
+ pListElement->SetText(6, _T("100"));
+ }
+}
+
+
+void CLogUI::exportLog()
+{
+ TCHAR szBuffer[MAX_PATH] = { 0 };
+
+ OPENFILENAME ofn = { 0 };
+ ofn.lStructSize = sizeof(ofn);
+ ofn.hwndOwner = m_hWnd;
+ ofn.lpstrFilter = _T("TXTļ(*.txt)\0*.txt\0ļ(*.*)\0*.*\0");//Ҫѡļ
+ ofn.lpstrInitialDir = _T("D:\\");//Ĭϵļ·
+ ofn.lpstrFile = szBuffer;//ļĻ
+ ofn.nMaxFile = sizeof(szBuffer) / sizeof(*szBuffer);
+ ofn.nFilterIndex = 0;
+ ofn.Flags = OFN_CREATEPROMPT | OFN_OVERWRITEPROMPT ;//־ǶѡҪOFN_ALLOWMULTISELECT
+ BOOL bSel = GetOpenFileName(&ofn);
+
+}
+
+void CLogUI::OnSelectStartTime(TNotifyUI& msg)
+{
+ CalendarUI* pDlg = new CalendarUI();
+ assert(pDlg);
+ pDlg->Create(this->GetHWND(), NULL, UI_WNDSTYLE_EX_DIALOG, 0L, 0, 0, 350, 380);
+ pDlg->CenterWindow();
+ pDlg->ShowModal();
+}
+
+void CLogUI::OnSelectStopTime(TNotifyUI& msg)
+{
+ CalendarUI* pDlg = new CalendarUI();
+ assert(pDlg);
+ pDlg->Create(this->GetHWND(), NULL, UI_WNDSTYLE_EX_DIALOG, 0L, 0, 0, 350, 380);
+ pDlg->CenterWindow();
+ pDlg->ShowModal();
+}
\ No newline at end of file
diff --git a/demo/Downloader/LogUI.h b/demo/Downloader/LogUI.h
new file mode 100644
index 0000000..6616942
--- /dev/null
+++ b/demo/Downloader/LogUI.h
@@ -0,0 +1,59 @@
+#pragma once
+#include
+#include
+
+#define BT_SearchLog (_T("search"))
+#define BT_OnStartTime (_T("DataTime1"))
+#define BT_OnStopTime (_T("DataTime2"))
+
+typedef struct
+{
+ STDSTRING Time;
+ STDSTRING Handle;
+ STDSTRING Description;
+}Log_Search;
+
+typedef struct
+{
+ STDSTRING Time;
+ STDSTRING Address;
+ STDSTRING Collect_people;
+ STDSTRING CaseName;
+ STDSTRING Case_description;
+ STDSTRING EquipmentIP;
+ STDSTRING Remark;
+}Case_Search;
+
+class CLogUI :
+ public WindowImplBase
+{
+public:
+ CLogUI();
+ ~CLogUI();
+ virtual void OnFinalMessage(HWND /*hWnd*/);
+ virtual void Notify(TNotifyUI& msg);
+ DUI_DECLARE_MESSAGE_MAP();
+ void OnBeginSearch(TNotifyUI& msg);
+
+ void OnSearchLog();
+ void OnSearchCaseLog();
+
+ void CreateLogList();
+ void CreateCaseList();
+
+ void InsertLogInfoToList();
+ void InsertCaseInfoToList();
+
+ void OnSelectStartTime(TNotifyUI& msg);
+ void OnSelectStopTime(TNotifyUI& msg);
+ void exportLog();
+protected:
+ vector m_LogInfo;
+ vector m_CaseInfo;
+ CListUI* m_pList;
+ BOOL m_bInit;
+protected:
+ virtual LPCTSTR GetWindowClassName() const;
+ virtual CDuiString GetSkinFolder();
+ virtual CDuiString GetSkinFile();
+};
diff --git a/demo/Downloader/MainWnd.cpp b/demo/Downloader/MainWnd.cpp
new file mode 100644
index 0000000..80259ad
--- /dev/null
+++ b/demo/Downloader/MainWnd.cpp
@@ -0,0 +1,93 @@
+#include "stdafx.h"
+#include "MainWnd.h"
+#include "DownLoadWnd.h"
+#include "LogUI.h"
+#include "VideoLoginUI.h"
+
+CMainWnd::CMainWnd()
+{
+
+}
+
+
+CMainWnd::~CMainWnd()
+{
+
+}
+
+
+DUI_BEGIN_MESSAGE_MAP(CMainWnd, WindowImplBase)
+DUI_ON_CLICK_CTRNAME(BT_CLOSE, OnClose)
+DUI_ON_CLICK_CTRNAME(BT_MINWIND, OnMin)
+DUI_ON_CLICK_CTRNAME(BT_DOWNLOAD, OnDownLoadWnd)
+DUI_ON_CLICK_CTRNAME(BT_LogWnd, OnLogWnd)
+DUI_END_MESSAGE_MAP()
+
+LPCTSTR CMainWnd::GetWindowClassName() const
+{
+ return _T("MainWnd");
+}
+
+CDuiString CMainWnd::GetSkinFolder()
+{
+ return _T("..//x86");
+}
+
+CDuiString CMainWnd::GetSkinFile()
+{
+ return _T("MainWnd.xml");
+}
+
+void CMainWnd::OnFinalMessage(HWND hWnd)
+{
+ WindowImplBase::OnFinalMessage(hWnd);
+ delete this;
+}
+
+void CMainWnd::OnClose(TNotifyUI& msg)
+{
+ ::PostQuitMessage(0L);
+}
+
+void CMainWnd::OnMin(TNotifyUI& msg)
+{
+ SendMessage(WM_SYSCOMMAND, SC_MINIMIZE);
+}
+
+void CMainWnd::OnDownLoadWnd(TNotifyUI& msg)
+{
+ DownLoadWnd* pDlg = new DownLoadWnd();
+ assert(pDlg);
+ pDlg->Create(this->GetHWND(), NULL, UI_WNDSTYLE_DIALOG, 0L, 0, 0, 1024, 768);
+ pDlg->CenterWindow();
+ pDlg->ShowModal();
+}
+
+void CMainWnd::OnLogWnd(TNotifyUI& msg)
+{
+ CLogUI* pDlg = new CLogUI();
+ assert(pDlg);
+ pDlg->Create(this->GetHWND(), NULL, UI_WNDSTYLE_DIALOG, 0L, 0, 0, 1024, 768);
+ pDlg->CenterWindow();
+ pDlg->ShowModal();
+}
+
+//void CMainWnd::OnVideoLonginWnd(TNotifyUI& msg)
+//{
+// VideoLoginUI* pDlg = new VideoLoginUI();
+// assert(pDlg);
+// pDlg->Create(this->GetHWND(), NULL, UI_WNDSTYLE_DIALOG, 0L, 0, 0, 1024, 768);
+// pDlg->CenterWindow();
+// pDlg->ShowModal();
+//}
+
+void CMainWnd::Notify(TNotifyUI& msg)
+{
+ if (msg.sType == DUI_MSGTYPE_CLICK) {
+ if (msg.pSender->GetName() == BT_VideoPlay)
+ {
+
+ }
+ }
+ return WindowImplBase::NotifyPump(msg);
+}
diff --git a/demo/Downloader/MainWnd.h b/demo/Downloader/MainWnd.h
new file mode 100644
index 0000000..0622bc7
--- /dev/null
+++ b/demo/Downloader/MainWnd.h
@@ -0,0 +1,32 @@
+#pragma once
+#include
+
+#define BT_CLOSE (_T("closebtn"))
+#define BT_MINWIND (_T("minbtn"))
+#define BT_DOWNLOAD (_T("download"))
+#define BT_LogWnd (_T("Log_manager"))
+#define BT_VideoPlay (_T("VideoPlay"))
+
+class CMainWnd :
+ public WindowImplBase
+{
+public:
+ CMainWnd();
+ ~CMainWnd();
+
+ virtual void OnFinalMessage(HWND hWnd);
+ virtual void Notify(TNotifyUI& msg);
+
+ DUI_DECLARE_MESSAGE_MAP();
+
+ void OnMin(TNotifyUI& msg);
+ void OnClose(TNotifyUI& msg);
+ void OnDownLoadWnd(TNotifyUI& msg);
+ void OnLogWnd(TNotifyUI& msg);
+ void OnVideoLonginWnd(TNotifyUI& msg);
+
+protected:
+ virtual LPCTSTR GetWindowClassName() const;
+ virtual CDuiString GetSkinFolder();
+ virtual CDuiString GetSkinFile();
+};
\ No newline at end of file
diff --git a/demo/Downloader/ReadMe.txt b/demo/Downloader/ReadMe.txt
new file mode 100644
index 0000000..80e6d26
--- /dev/null
+++ b/demo/Downloader/ReadMe.txt
@@ -0,0 +1,30 @@
+========================================================================
+ 控制台应用程序:Downloader 项目概述
+========================================================================
+
+应用程序向导已为您创建了此 Downloader 应用程序。
+
+本文件概要介绍组成 Downloader 应用程序的每个文件的内容。
+
+
+Downloader.vcxproj
+ 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
+
+Downloader.vcxproj.filters
+ 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。
+
+Downloader.cpp
+ 这是主应用程序源文件。
+
+/////////////////////////////////////////////////////////////////////////////
+其他标准文件:
+
+StdAfx.h, StdAfx.cpp
+ 这些文件用于生成名为 Downloader.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。
+
+/////////////////////////////////////////////////////////////////////////////
+其他注释:
+
+应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。
+
+/////////////////////////////////////////////////////////////////////////////
diff --git a/demo/Downloader/SearchFileUI.cpp b/demo/Downloader/SearchFileUI.cpp
new file mode 100644
index 0000000..6976f59
--- /dev/null
+++ b/demo/Downloader/SearchFileUI.cpp
@@ -0,0 +1,135 @@
+#include "stdafx.h"
+#include "SearchFileUI.h"
+
+
+SearchFileUI::SearchFileUI()
+{
+}
+
+
+SearchFileUI::~SearchFileUI()
+{
+}
+
+DUI_BEGIN_MESSAGE_MAP(SearchFileUI, WindowImplBase)
+DUI_END_MESSAGE_MAP()
+
+STDSTRING SearchFileUI::intToString(int num)
+{
+ char Tmp[10] = { 0 };
+ _itoa(num, Tmp, 10);
+ STDSTRING result(Tmp);
+ return result;
+}
+
+LPCTSTR SearchFileUI::GetWindowClassName() const
+{
+ return _T("SearchFileUI");
+}
+
+CDuiString SearchFileUI::GetSkinFolder()
+{
+ return _T("..//x86");
+}
+
+CDuiString SearchFileUI::GetSkinFile()
+{
+ return _T("VideoSearch.xml");
+}
+
+void SearchFileUI::OnFinalMessage(HWND hWnd)
+{
+ WindowImplBase::OnFinalMessage(hWnd);
+ delete this;
+}
+
+void SearchFileUI::Notify(TNotifyUI& msg)
+{
+ if (msg.sType == DUI_MSGTYPE_CLICK){
+ STDSTRING SendName = msg.pSender->GetName();
+ if (msg.pSender->GetName() == _T("close"))
+ {
+ Close();
+ }
+ if (msg.pSender->GetName() == _T("test"))
+ {
+ SearchTest();
+ }
+ if (msg.pSender->GetName() == _T("All"))
+ {
+ CListUI* pList = static_cast(m_PaintManager.FindControl(_T("domainlist")));
+ COptionUI* option_All = static_cast(m_PaintManager.FindSubControlByName(pList, _T("All")));
+ int nCount = pList->GetCount();
+ for (int i = 1; i <= nCount; i++)
+ {
+ COptionUI* option = static_cast(m_PaintManager.FindSubControlByClass(pList, DUI_CTR_OPTION, i));
+ if (!option_All->IsSelected()){
+ option->Selected(true);
+ }
+ else{
+ option->Selected(false);
+ }
+ }
+ }
+ }
+
+ WindowImplBase::Notify(msg);
+}
+
+
+void SearchFileUI::SearchTest()
+{
+ CListUI* pList = static_cast(m_PaintManager.FindControl(_T("domainlist")));
+// pList->RemoveAll();
+ CListContainerElementUI* SubList = new CListContainerElementUI;
+ int filesize = 10;
+ for (int i = 1; i <= filesize; i++)
+ {
+ SubList = Add_FileInfoList(i);
+ pList->Add(SubList);
+ }
+}
+
+CListContainerElementUI* SearchFileUI::Add_FileInfoList(int n)
+{
+ CListContainerElementUI* Sublist = new CListContainerElementUI;
+ CHorizontalLayoutUI* hLyt = new CHorizontalLayoutUI;
+ COptionUI* option = new COptionUI;
+ CLabelUI* Lab_Name = new CLabelUI;
+ CLabelUI* Lab_Channel = new CLabelUI;
+ CLabelUI* Lab_Stime = new CLabelUI;
+ CLabelUI* Lab_Etime = new CLabelUI;
+ CLabelUI* Lab_Size = new CLabelUI;
+ CButtonUI* BT_Play = new CButtonUI;
+
+ Sublist->SetFixedHeight(30);
+ Sublist->Add(hLyt);
+ hLyt->Add(option);
+ hLyt->Add(Lab_Name);
+ hLyt->Add(Lab_Channel);
+ hLyt->Add(Lab_Stime);
+ hLyt->Add(Lab_Etime);
+ hLyt->Add(Lab_Size);
+ hLyt->Add(BT_Play);
+
+ STDSTRING optionName = STDSTRING(_T("option")) + intToString(n);
+ option->SetAttributeList(_T("width=\"22\" height=\"22\" padding=\"10,4,42,4\" normalimage=\"file='Downloader/quanxuan.png'\" selectedimage=\"file='Downloader/quanxuanzhuangtai.png'\""));
+ option->SetName(optionName.c_str());
+
+ Lab_Name->SetAttributeList("width=\"240\" align=\"center\" font=\"2\"");
+ Lab_Name->SetText(_T("123412"));
+ Lab_Channel->SetAttributeList("width=\"100\" align=\"center\" font=\"2\"");
+ Lab_Channel->SetText(_T("text"));
+ Lab_Stime->SetAttributeList("width=\"200\" align=\"center\" font=\"2\"");
+ Lab_Stime->SetText(_T("text"));
+ Lab_Etime->SetAttributeList("width=\"200\" align=\"center\" font=\"2\"");
+ Lab_Etime->SetText(_T("text"));
+ Lab_Size->SetAttributeList("width=\"100\" align=\"center\" font=\"2\"");
+ Lab_Size->SetText(_T("text"));
+
+ STDSTRING buttonName = STDSTRING(_T("BT_Play")) + intToString(n);
+ BT_Play->SetAttributeList(_T("width=\"40\" height=\"30\" padding=\"30,0,30,0\" foreimage=\"file='Downloader/play.png' dest='5,0,35,30'\" hotimage=\"file='Downloader/Button_Hot.png'\""));
+ BT_Play->SetName(buttonName.c_str());
+
+ return Sublist;
+}
\ No newline at end of file
diff --git a/demo/Downloader/SearchFileUI.h b/demo/Downloader/SearchFileUI.h
new file mode 100644
index 0000000..b441a2b
--- /dev/null
+++ b/demo/Downloader/SearchFileUI.h
@@ -0,0 +1,25 @@
+#pragma once
+#include
+
+
+class SearchFileUI :
+ public WindowImplBase
+{
+public:
+ SearchFileUI();
+ ~SearchFileUI();
+ virtual void OnFinalMessage(HWND hWnd);
+ virtual void Notify(TNotifyUI& msg);
+
+ DUI_DECLARE_MESSAGE_MAP();
+
+ STDSTRING intToString(int num);
+ void SearchTest();
+
+ CListContainerElementUI* Add_FileInfoList(int n);
+
+protected:
+ virtual LPCTSTR GetWindowClassName() const;
+ virtual CDuiString GetSkinFolder();
+ virtual CDuiString GetSkinFile();
+};
\ No newline at end of file
diff --git a/demo/Downloader/Vendor.cpp b/demo/Downloader/Vendor.cpp
new file mode 100644
index 0000000..0e0b34f
--- /dev/null
+++ b/demo/Downloader/Vendor.cpp
@@ -0,0 +1,22 @@
+#include "stdafx.h"
+#include "Vendor.h"
+
+
+CVendor::CVendor()
+:ppm(nullptr)
+{
+}
+
+CVendor::~CVendor()
+{
+}
+
+DUI_BEGIN_MESSAGE_MAP(CVendor, CNotifyPump)
+
+DUI_END_MESSAGE_MAP()
+
+void CVendor::SetPaintMagager(CPaintManagerUI* pPaintMgr)
+{
+ assert(pPaintMgr);
+ ppm = pPaintMgr;
+}
diff --git a/demo/Downloader/Vendor.h b/demo/Downloader/Vendor.h
new file mode 100644
index 0000000..75ed34a
--- /dev/null
+++ b/demo/Downloader/Vendor.h
@@ -0,0 +1,19 @@
+#pragma once
+#include
+
+class CVendor
+ :public CNotifyPump
+{
+public:
+ CVendor();
+ ~CVendor();
+
+ void SetPaintMagager(CPaintManagerUI* pPaintMgr);
+ DUI_DECLARE_MESSAGE_MAP();
+
+
+
+private:
+ CPaintManagerUI* ppm;
+
+};
diff --git a/demo/Downloader/VideoLoginUI.cpp b/demo/Downloader/VideoLoginUI.cpp
new file mode 100644
index 0000000..aef5c91
--- /dev/null
+++ b/demo/Downloader/VideoLoginUI.cpp
@@ -0,0 +1,49 @@
+#include "stdafx.h"
+#include "VideoLoginUI.h"
+
+
+VideoLoginUI::VideoLoginUI()
+{
+}
+
+
+VideoLoginUI::~VideoLoginUI()
+{
+}
+
+DUI_BEGIN_MESSAGE_MAP(VideoLoginUI, WindowImplBase)
+DUI_END_MESSAGE_MAP()
+
+LPCTSTR VideoLoginUI::GetWindowClassName() const
+{
+ return _T("CLogUI");
+}
+
+CDuiString VideoLoginUI::GetSkinFolder()
+{
+ return _T("..//x86");
+}
+
+CDuiString VideoLoginUI::GetSkinFile()
+{
+ return _T("VideoLoginUI.xml");
+}
+
+void VideoLoginUI::OnFinalMessage(HWND hWnd)
+{
+ WindowImplBase::OnFinalMessage(hWnd);
+ delete this;
+}
+
+void VideoLoginUI::Notify(TNotifyUI& msg)
+{
+ if (msg.sType == DUI_MSGTYPE_CLICK)
+ {
+ if (msg.pSender->GetName() == _T("IP_match"))
+ {
+ POINT pt = { msg.ptMouse.x, msg.ptMouse.y };
+ int x = pt.x;
+ }
+ }
+ WindowImplBase::Notify(msg);
+}
\ No newline at end of file
diff --git a/demo/Downloader/VideoLoginUI.h b/demo/Downloader/VideoLoginUI.h
new file mode 100644
index 0000000..dcc92c9
--- /dev/null
+++ b/demo/Downloader/VideoLoginUI.h
@@ -0,0 +1,24 @@
+#pragma once
+#include
+
+#define BT_Calendar1 (_T("DataTime1"))
+#define BT_Calendar2 (_T("DataTime2"))
+
+class VideoLoginUI :
+ public WindowImplBase
+{
+public:
+ VideoLoginUI();
+ ~VideoLoginUI();
+ virtual void OnFinalMessage(HWND /*hWnd*/);
+ virtual void Notify(TNotifyUI& msg);
+ DUI_DECLARE_MESSAGE_MAP();
+ void OnSelectTimeType();
+ void OnSelectCalendar();
+ void Set(STDSTRING& text);
+
+protected:
+ virtual LPCTSTR GetWindowClassName() const;
+ virtual CDuiString GetSkinFolder();
+ virtual CDuiString GetSkinFile();
+};
\ No newline at end of file
diff --git a/demo/Downloader/resource.h b/demo/Downloader/resource.h
new file mode 100644
index 0000000..f53a8fb
Binary files /dev/null and b/demo/Downloader/resource.h differ
diff --git a/demo/Downloader/stdafx.cpp b/demo/Downloader/stdafx.cpp
new file mode 100644
index 0000000..79228f6
--- /dev/null
+++ b/demo/Downloader/stdafx.cpp
@@ -0,0 +1,15 @@
+// stdafx.cpp : source file that includes just the standard includes
+// App.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+#if defined _M_IX86
+#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#elif defined _M_IA64
+#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#elif defined _M_X64
+#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#else
+#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#endif
diff --git a/demo/Downloader/stdafx.h b/demo/Downloader/stdafx.h
new file mode 100644
index 0000000..fbab9af
--- /dev/null
+++ b/demo/Downloader/stdafx.h
@@ -0,0 +1,54 @@
+#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
+#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
+
+#pragma once
+
+#define WIN32_LEAN_AND_MEAN
+#define _CRT_SECURE_NO_DEPRECATE
+
+#include
+#include
+#include
+
+#include "resource.h"
+#include "DuiLib\UIlib.h"
+
+#include "document.h"
+#include "prettywriter.h"
+#include "stringbuffer.h"
+#include
+
+#include "ostreamwrapper.h"
+#include "istreamwrapper.h"
+
+
+using namespace DuiLib;
+
+#ifdef _DEBUG
+# ifdef _UNICODE
+# pragma comment(lib, "DuiLib_ud.lib")
+# else
+# pragma comment(lib, "DuiLib_d.lib")
+# endif
+#else
+# ifdef _UNICODE
+# pragma comment(lib, "DuiLib_u.lib")
+# else
+# pragma comment(lib, "DuiLib.lib")
+# endif
+#endif
+
+
+#ifdef _UNICODE
+# define STDSTRING std::wstring
+#else
+# define STDSTRING std::string
+#endif
+
+
+
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
diff --git a/demo/Downloader/targetver.h b/demo/Downloader/targetver.h
new file mode 100644
index 0000000..7a7d2c8
--- /dev/null
+++ b/demo/Downloader/targetver.h
@@ -0,0 +1,8 @@
+#pragma once
+
+// SDKDDKVer.h õ߰汾 Windows ƽ̨
+
+// ҪΪǰ Windows ƽ̨Ӧó WinSDKVer.h
+// WIN32_WINNT ΪҪֵ֧ƽ̨Ȼٰ SDKDDKVer.h
+
+#include
diff --git a/demo/Launcher.iss b/demo/Launcher.iss
index 748070a..dd38d8a 100644
--- a/demo/Launcher.iss
+++ b/demo/Launcher.iss
@@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "Launcher"
-#define MyAppVersion "1.0.0.0.8"
+#define MyAppVersion "1.0.0.1.2"
#define MyAppPublisher "sisec"
#define MyAppURL "http://www.sisec.com.cn/"
@@ -10,7 +10,7 @@
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
-AppId={{6F882F56-62C3-4609-AB7D-33C335207E39}
+AppId=FC1004DE-2231-4194-9991-4E36E3155B76
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
diff --git a/demo/Launcher/App.cpp b/demo/Launcher/App.cpp
index e2efdfb..736e8bc 100644
--- a/demo/Launcher/App.cpp
+++ b/demo/Launcher/App.cpp
@@ -1,40 +1,26 @@
// App.cpp : Defines the entry point for the application.
//
-
#include "stdafx.h"
-#include "Launcher.h"
-
-static void LoadConfiguration();
-static void SaveConfiguration();
+#include "MainWnd.h"
+#include "resource.h"
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nCmdShow)
{
- CPaintManagerUI::SetInstance(hInstance);
- CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + _T("skin") );
- LoadConfiguration();
- HRESULT Hr = ::CoInitialize(NULL);
- if( FAILED(Hr) ) return 0;
+ CPaintManagerUI::SetInstance(hInstance);
+ CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + _T("skin"));
- Launcher* pFrame = new Launcher();
- if( pFrame == NULL ) return 0;
- pFrame->Create(NULL, NULL, UI_WNDSTYLE_DIALOG | UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE | WS_EX_ACCEPTFILES | WS_EX_STATICEDGE | WS_EX_APPWINDOW);
- pFrame->SetIcon(IDI_ICON);
- pFrame->CenterWindow();
- pFrame->ShowWindow(true);
- CPaintManagerUI::MessageLoop();
- SaveConfiguration();
- ::CoUninitialize();
- return 0;
-}
+ HRESULT Hr = ::CoInitialize(NULL);
+ if (FAILED(Hr)) return 0;
-void LoadConfiguration()
-{
- //Load configuration from json file
- //configuration is path of shortcut
-}
+ CMainWnd* pFrame = new CMainWnd();
+ pFrame->Create(NULL, NULL, UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE | WS_EX_ACCEPTFILES);
+ pFrame->SetIcon(IDI_ICON);
+ pFrame->CenterWindow();
+ pFrame->ShowWindow(true);
-void SaveConfiguration()
-{
+ CPaintManagerUI::MessageLoop();
-}
\ No newline at end of file
+ ::CoUninitialize();
+ return 0;
+}
diff --git a/demo/Launcher/Launcher.cpp b/demo/Launcher/Launcher.cpp
deleted file mode 100644
index 342d49c..0000000
--- a/demo/Launcher/Launcher.cpp
+++ /dev/null
@@ -1,784 +0,0 @@
-#include "stdafx.h"
-#include "Launcher.h"
-#include "document.h"
-#include "prettywriter.h"
-#include "stringbuffer.h"
-#include "ostreamwrapper.h"
-#include "istreamwrapper.h"
-#include
-#include
-#include
-#include
-#include
-
-using namespace std;
-
-#define CONTROL_LAYOUT_OUT 68
-#define BUTTON_WIDTH 48
-#define BUTTON_HEIGHT 48
-#define LABLE_WIDTH 48
-#define LABLE_HEIGHT 15
-#define FONT_SIZE 12
-#define BORD_WIDTH 35
-#define LYT_WIDTH 135
-#define LYT_HEIGHT 110
-
-#define BMPBITCOUNT 32
-
-Launcher::Launcher()
-{
- TCHAR PATH[MAX_PATH] = { 0 };
- STDSTRING AppPath = STDSTRING(PATH, ::GetModuleFileName(NULL, PATH, MAX_PATH));
- WriteablePath = AppPath.substr(0,AppPath.find_last_of(_T('\\')) + 1);
- AppLetter = AppPath.substr(0, AppPath.find_first_of(_T('\\')) );
- configfile = WriteablePath + "config.json";
-}
-
-Launcher::~Launcher()
-{
-}
-
-void Launcher::Notify(TNotifyUI& msg)
-{
- if (msg.sType == DUI_MSGTYPE_CLICK) {
- if (msg.pSender->GetName() == _T("closebtn")) {
- SaveLytToJsonFile();
- PostQuitMessage(0);
- }
- else if (msg.pSender->GetName() == _T("minbtn")) {
- SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0);
- }
- else {
- m_xyPos = { msg.ptMouse.x, msg.ptMouse.y };
- OpenExeFile(m_xyPos.x, m_xyPos.y);
- }
- }
- else if (msg.sType == DUI_MSGTYPE_MENU)
- {
- PopMenu(msg);
- }
- else if (msg.sType == _T("menu_Delete")) {
- DeleteLyt();
- }
- else if (msg.sType == _T("menu_Open")) {
- OpenExeFile(m_MenuPt.x, m_MenuPt.y);
- }
- else if (msg.sType == _T("menu_Rename")){
- }
- else if (msg.sType == DUI_MSGTYPE_TABSELECT){
- OnMouseMove(msg.ptMouse.x, msg.ptMouse.y);
- }
- else if (msg.sType == DUI_MSGTYPE_SELECTCHANGED){
- CNewVerticalLayoutUI* cLyt = new CNewVerticalLayoutUI;
- for (UINT j = 0; j < m_AllLyt.size(); j++)
- {
- cLyt = m_AllLyt[j].Layout;
- cLyt->SetBkColor(NULL);
-
- }
- }
-}
-
-using namespace rapidjson;
-
-void Launcher::SaveLytToJsonFile()
-{
- Document document;
- //STDSTRING path(WriteablePath + "test.json");
- document.Parse(configfile.c_str());
- ofstream ofs(configfile);
- OStreamWrapper osw(ofs);
- Document::AllocatorType& alloc = document.GetAllocator();
- Value root(rapidjson::kObjectType);
-
- for (auto& var : m_AllLyt)
- {
- STDSTRING absPath, relPath, name, extension, path, letter, display;
- path = var.FilePath;
- display = var.Display;
-
- name = path.substr(path.find_last_of(_T('\\')) + 1);
- absPath = path.substr(0, path.find_last_of(_T('\\')) + 1);
- extension = name.substr(name.find_last_of(_T('.')) + 1);
- relPath = absPath.substr(absPath.find_first_of(_T(':')) + 1);
- letter = absPath.substr(0, absPath.find_first_of(_T(':')) + 1);
-
- Value a(rapidjson::kArrayType);
- Value n(name.c_str(), name.length(), alloc);
- Value r(relPath.c_str(), relPath.length(), alloc);
- Value p(absPath.c_str(), absPath.length(), alloc);
- Value e(extension.c_str(), extension.length(), alloc);
- Value l(letter.c_str(), letter.length(), alloc);
- Value d(display.c_str(), display.length(), alloc);
-
- a.PushBack(p, alloc).PushBack(l, alloc).PushBack(r, alloc).PushBack(e, alloc).PushBack(d, alloc);
-
- root.AddMember(n.Move(), a.Move(), alloc);
- }
-
- Writer writer(osw);
- root.Accept(writer);
-
-}
-
-void Launcher::PopMenu(TNotifyUI& msg)
-{
- CMenuWnd* pMenu = new CMenuWnd();
- if (pMenu == NULL) { return; }
- m_MenuPt = { msg.ptMouse.x, msg.ptMouse.y };
- POINT pt = m_MenuPt;
- ::ClientToScreen(m_hWnd, &pt);
- pMenu->Init(msg.pSender, pt);
-}
-
-void Launcher::DeleteLyt()
-{
- CHorizontalLayoutUI* cListLyt = static_cast(mpm.FindControl(_T("ListLayout")));
- CNewVerticalLayoutUI* cLyt = new CNewVerticalLayoutUI;
- POINT pt = m_MenuPt;
- int xPos = pt.x;
- int yPos = pt.y;
-
- UINT n = xPos / LYT_WIDTH + (yPos - BORD_WIDTH) / LYT_HEIGHT * 4;
- if (n > m_AllLyt.size() || m_AllLyt.size() == 0)
- return;
- cLyt = m_AllLyt[n].Layout;
- cListLyt->Remove(cLyt);
- m_AllLyt.erase(m_AllLyt.begin() + n);
-}
-
-void Launcher::OpenExeFile(int xPos, int yPos)
-{
- UINT n = xPos / LYT_WIDTH + (yPos - BORD_WIDTH) / LYT_HEIGHT * 4;
- if (m_AllLyt.size() == 0 || m_AllLyt.size() - 1 < n)
- return;
- if (xPos < 5 || yPos < BORD_WIDTH || n > m_AllLyt.size() - 1 || xPos - 16 < 0 || (xPos - 16) % LYT_WIDTH > 95
- || yPos - BORD_WIDTH < 0 || (yPos - BORD_WIDTH) % LYT_HEIGHT > 90)
- {
- return;
- }
- DUITRACE("%s", m_AllLyt[n].FilePath.c_str());
- HINSTANCE hIns = ShellExecute(NULL, _T("Open"), m_AllLyt[n].FilePath.c_str(), NULL, NULL, SW_SHOWNORMAL);
- int dret = (int)hIns;
- if (dret < 32)
- MessageBox(NULL, _T("无法打开"), _T("提示"), MB_OK);
-}
-
-void Launcher::OnMouseMove(int xPos, int yPos)
-{
- UINT n = xPos / LYT_WIDTH + (yPos - BORD_WIDTH) / LYT_HEIGHT * 4;
- CNewVerticalLayoutUI* cLyt = new CNewVerticalLayoutUI;
- if (n >= m_AllLyt.size()) return;
- cLyt = m_AllLyt[n].Layout;
- cLyt->SetBkColor(0xFFFF9999);
-}
-
-void Launcher::c2w(wchar_t *pwstr, size_t len, const char *str)
-{
- if (str)
- {
- size_t nu = strlen(str);
- size_t n = (size_t)MultiByteToWideChar(CP_ACP, 0, (const char *)str, (int)nu, NULL, 0);
- if (n >= len)n = len - 1;
- MultiByteToWideChar(CP_ACP, 0, (const char *)str, (int)nu, pwstr, (int)n);
- pwstr[n] = 0;
- }
-}
-
-void Launcher::w2c(char *pcstr, const wchar_t *pwstr, int len)
-{
- int nlength = wcslen(pwstr);
- int nbytes = WideCharToMultiByte(0, 0, pwstr, nlength, NULL, 0, NULL, NULL);
- if (nbytes>len) nbytes = len;
- WideCharToMultiByte(0, 0, pwstr, nlength, pcstr, nbytes, NULL, NULL);
-}
-
-LRESULT Launcher::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
-{
- LONG styleValue = ::GetWindowLong(*this, GWL_STYLE);
- styleValue &= ~WS_CAPTION;
- ::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
-
- mpm.Init(m_hWnd);
- CDialogBuilder builder;
- CControlUI* pRoot = builder.Create(_T("launcher.xml"), (UINT)0, NULL, &mpm);
- ASSERT(pRoot && "Failed to parse XML");
- mpm.AttachDialog(pRoot);
- mpm.AddNotifier(this);
- if (m_Nbmp == 1)
- MapInit();
-
- return 0;
-}
-
-LRESULT Launcher::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
-{
- ::PostQuitMessage(0L);
-
- bHandled = FALSE;
- return 0;
-}
-
-LRESULT Launcher::OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
-{
- if (::IsIconic(*this)) bHandled = FALSE;
- return (wParam == 0) ? TRUE : FALSE;
-}
-
-LRESULT Launcher::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
-{
- POINT pt; pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam);
- ::ScreenToClient(*this, &pt);
-
- RECT rcClient;
- ::GetClientRect(*this, &rcClient);
-
- if (!::IsZoomed(*this)) {
- RECT rcSizeBox = mpm.GetSizeBox();
- if (pt.y < rcClient.top + rcSizeBox.top) {
- if (pt.x < rcClient.left + rcSizeBox.left) return HTTOPLEFT;
- if (pt.x > rcClient.right - rcSizeBox.right) return HTTOPRIGHT;
- return HTTOP;
- }
- else if (pt.y > rcClient.bottom - rcSizeBox.bottom) {
- if (pt.x < rcClient.left + rcSizeBox.left) return HTBOTTOMLEFT;
- if (pt.x > rcClient.right - rcSizeBox.right) return HTBOTTOMRIGHT;
- return HTBOTTOM;
- }
- if (pt.x < rcClient.left + rcSizeBox.left) return HTLEFT;
- if (pt.x > rcClient.right - rcSizeBox.right) return HTRIGHT;
- }
-
- RECT rcCaption = mpm.GetCaptionRect();
- if (pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right \
- && pt.y >= rcCaption.top && pt.y < rcCaption.bottom) {
- CControlUI* pControl = static_cast(mpm.FindControl(pt));
- if (pControl && _tcscmp(pControl->GetClass(), DUI_CTR_BUTTON) != 0 &&
- _tcscmp(pControl->GetClass(), DUI_CTR_OPTION) != 0 &&
- _tcscmp(pControl->GetClass(), DUI_CTR_TEXT) != 0)
- return HTCAPTION;
- }
- return HTCLIENT;
-}
-
-LRESULT Launcher::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
-{
- SIZE szRoundCorner = mpm.GetRoundCorner();
- if (!::IsIconic(*this) && (szRoundCorner.cx != 0 || szRoundCorner.cy != 0)) {
- CDuiRect rcWnd;
- ::GetWindowRect(*this, &rcWnd);
- rcWnd.Offset(-rcWnd.left, -rcWnd.top);
- rcWnd.right++; rcWnd.bottom++;
- HRGN hRgn = ::CreateRoundRectRgn(rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom, szRoundCorner.cx, szRoundCorner.cy);
- ::SetWindowRgn(*this, hRgn, TRUE);
- ::DeleteObject(hRgn);
- }
-
- bHandled = FALSE;
- return 0;
-}
-
-LRESULT Launcher::OnDropFiles(UINT uMsg, HDROP hDrop, LPARAM lParam, BOOL& bHandled)
-{
- //获取拖动文件松开鼠标时的x坐标
- POINT* ptDropPos = new POINT;
- DragQueryPoint(hDrop, ptDropPos); //把文件拖动到的位置存到ptDropPos中
- int iDropPos = ptDropPos->x;
- int yDropPos = ptDropPos->y;
- delete(ptDropPos);
-
- WORD wNumFilesDropped = DragQueryFile(hDrop, -1, NULL, 0);
-
- if (m_AllLyt.size() + wNumFilesDropped > 21){
- MessageBox(NULL, _T("can't drop too many files!"), _T("message"), MB_OK);
- return 0;
- }
-
- for (unsigned short i = 0; i < wNumFilesDropped; i++)
- {
- HICON hIcon = NULL;
- char strTmp[20] = { 0 };
- _itoa(m_Nbmp, strTmp, 10);
- strcat_s(strTmp, "tem.bmp");
- m_Nbmp++;
-
- LPCTSTR pBmpFilename = NULL;
-#ifdef _UNICODE
- wchar_t strFileName[MAX_PATH] = { 0 };
- wchar_t pBmpFilenameTmp[100] = { 0 };
- c2w(pBmpFilenameTmp, 100, strTmp);
- pBmpFilename = pBmpFilenameTmp;
- DragQueryFile(hDrop, i, strFileName, MAX_PATH);
-#else
- char strFileName[MAX_PATH] = { 0 };
- pBmpFilename = strTmp;
- DragQueryFile(hDrop, i, strFileName, MAX_PATH);
-#endif
-
-
- hIcon = QueryFileIcon(strFileName);
- HBITMAP IconHbmp = IconToBitmap(hIcon);
- SaveBmp(IconHbmp, strTmp);
- AddLayout(iDropPos, yDropPos, pBmpFilename, strFileName);
- }
- return 0;
-}
-
-LRESULT Launcher::OnGetMinMaxInfo(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
-{
- MONITORINFO oMonitor = {};
- oMonitor.cbSize = sizeof(oMonitor);
- ::GetMonitorInfo(::MonitorFromWindow(*this, MONITOR_DEFAULTTOPRIMARY), &oMonitor);
- CDuiRect rcWork = oMonitor.rcWork;
- LPMINMAXINFO lpMMI = (LPMINMAXINFO)lParam;
- lpMMI->ptMaxPosition.x = rcWork.left;
- lpMMI->ptMaxPosition.y = rcWork.top;
- lpMMI->ptMaxSize.x = rcWork.right - rcWork.left;
- lpMMI->ptMaxSize.y = rcWork.bottom - rcWork.top;
- bHandled = FALSE;
- return 0;
-}
-
-LRESULT Launcher::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- LRESULT lRes = 0;
- BOOL bHandled = TRUE;
- switch (uMsg) {
- case WM_CREATE: lRes = OnCreate(uMsg, wParam, lParam, bHandled); break;
- case WM_DESTROY: lRes = OnDestroy(uMsg, wParam, lParam, bHandled); break;
- case WM_NCACTIVATE: lRes = OnNcActivate(uMsg, wParam, lParam, bHandled); break;
- case WM_DROPFILES: lRes = OnDropFiles(uMsg, HDROP(wParam), lParam, bHandled); break;
- case WM_NCHITTEST: lRes = OnNcHitTest(uMsg, wParam, lParam, bHandled); break;
- case WM_SIZE: lRes = OnSize(uMsg, wParam, lParam, bHandled); break;
- case WM_GETMINMAXINFO: lRes = OnGetMinMaxInfo(uMsg, wParam, lParam, bHandled); break;
- default:
- bHandled = FALSE;
- }
- if (bHandled) return lRes;
- if (mpm.MessageHandler(uMsg, wParam, lParam, lRes)) return lRes;
- return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
-}
-
-HICON Launcher::QueryFileIcon(LPCTSTR lpszFilePath)
-{
- HICON hIcon = NULL;
- SHFILEINFO FileInfo;
- DWORD_PTR dwRet = ::SHGetFileInfo(lpszFilePath, 0, &FileInfo, sizeof(SHFILEINFO), SHGFI_ICON);
- if (dwRet)
- {
- hIcon = FileInfo.hIcon;
- }
- return hIcon;
-}
-
-void Launcher::MapInit()
-{
- ifstream ifs(configfile);
- rapidjson::IStreamWrapper isw(ifs);
- rapidjson::Document d;
- d.ParseStream(isw);
- size_t file_size = isw.Tell();
- if (isw.Tell() == 0)
- return;
-
- typedef rapidjson::Value::ConstMemberIterator Iter;
- for (Iter it = d.MemberBegin(); it != d.MemberEnd(); it++)
- {
- STDSTRING TypeName = it->name.GetString();
- const rapidjson::Value& a = d[TypeName.c_str()];
- assert(a.IsArray());
- if (!a.IsArray() || a.Size() < 5)
- continue;
- STDSTRING letter = a[1].GetString();
- STDSTRING relPath = a[2].GetString();
- STDSTRING display = a[4].GetString();
-
- display.empty() ? (display = TypeName) : display ;
-
- STDSTRING str = AppLetter + relPath + TypeName;
-
- GetIcon(str.c_str());
- }
-}
-
-void Launcher::GetIcon(const char* strPath)
-{
- char strTmp[20] = { 0 };
- _itoa(m_Nbmp, strTmp, 10);
- strcat_s(strTmp, "tem.bmp");
- m_Nbmp++;
-
- LPCTSTR strFilePath = NULL;
- LPCTSTR pBmpFilename = NULL;
-#ifdef _UNICODE
- wchar_t strFilePathTmp[100] = { 0 };
- wchar_t pBmpFilenameTmp[100] = { 0 };
- c2w(strFilePathTmp, 100, strPath);
- c2w(pBmpFilenameTmp, 100, strTmp);
- strFilePath = strFilePathTmp;
- pBmpFilename = pBmpFilenameTmp;
-#else
- strFilePath = strPath;
- pBmpFilename = strTmp;
-#endif
- HICON hIcon = QueryFileIcon(strFilePath);
- HBITMAP IconHbmp = IconToBitmap(hIcon);
- SaveBmp(IconHbmp, strTmp);
-
- CNewVerticalLayoutUI* cLyt = new CNewVerticalLayoutUI;
- InitLayOut(cLyt, pBmpFilename, strFilePath);
-
- LayOut_Info Lyt_info = { 0 };
- Lyt_info.Layout = cLyt;
- Lyt_info.FilePath = strPath;
- //memcpy(Lyt_info.FilePath.data(), strPath, strlen(strPath));
-
- m_AllLyt.push_back(Lyt_info);
-
- ShowLayOut();
-}
-
-void Launcher::AddToMap(LPCTSTR LayoutName)
-{
-}
-
-void Launcher::AddLayout(int nPosX, int nPosY, LPCTSTR pFileName, LPCTSTR strName)
-{
- CNewVerticalLayoutUI* cLyt = new CNewVerticalLayoutUI;
- InitLayOut(cLyt, pFileName, strName);
- Push_LayOut(nPosX, nPosY, cLyt, strName);
- ShowLayOut();
-}
-
-void Launcher::InitLayOut(CNewVerticalLayoutUI* cLyt, LPCTSTR pFileName, LPCTSTR strName)
-{
- CNewButtonUI* cBtn = new CNewButtonUI;
- CLabelUI* Lab = new CLabelUI;
- CHorizontalLayoutUI* cListLyt = static_cast(mpm.FindControl(_T("ListLayout")));
- cListLyt->Add(cLyt);
- cLyt->Add(cBtn);
- cLyt->Add(Lab);
- cBtn->SetContextMenuUsed(true);
- cBtn->SetFixedHeight(BUTTON_HEIGHT);
- cBtn->SetFixedWidth(BUTTON_WIDTH);
- STDSTRING ImagePath = WriteablePath + pFileName;
- cBtn->SetBkImage(ImagePath.c_str());
- cBtn->SetToolTip(strName);
-
- RECT r;
- r.left = 25;
- r.right = 22;
- r.bottom = 0;
- r.top = 10;
-
- cBtn->SetPadding(r);
-
- STDSTRING path, displayName;
- path = strName;
- displayName = path.substr(path.find_last_of(_T('\\')) + 1);
-
- Lab->SetText(displayName.c_str());
- Lab->SetFont(FONT_SIZE);
- Lab->SetMultiLine(true);
- RECT rect;
- rect.left = 25;
- rect.right = 22;
- rect.bottom = 40;
- rect.top = 5;
- Lab->SetPadding(rect);
- Lab->SetToolTip(strName);
- Lab->SetMultiLine(true);
-}
-
-void Launcher::Push_LayOut(int xPos, int yPos, CNewVerticalLayoutUI* cLyt, LPCTSTR strName)
-{
- LayOut_Info Lyt_info = { 0 };
- Lyt_info.Layout = cLyt;
-
- Lyt_info.FilePath = strName;
- //memcpy(Lyt_info.FilePath, strFilePath, 100);
- UINT Xnum = xPos / LYT_WIDTH + 1;
- UINT Ynum = (yPos - BORD_WIDTH) / LYT_HEIGHT;
- UINT n = Ynum * 4 + Xnum;
- if (n > m_AllLyt.size()){
- m_AllLyt.push_back(Lyt_info);
- }
- else{
- m_AllLyt.insert(m_AllLyt.begin() + n - 1, Lyt_info);
- }
-}
-
-void Launcher::ShowLayOut()
-{
- CHorizontalLayoutUI* cListLyt = static_cast(mpm.FindControl(_T("ListLayout")));
- CNewVerticalLayoutUI* cLyt = new CNewVerticalLayoutUI;
-
- for (auto& var : m_AllLyt)
- {
- cListLyt->Remove(var.Layout, true);
-
- cLyt = var.Layout; cLyt->SetContextMenuUsed(true);
- cLyt->SetToolTip(var.FilePath.c_str());
-
- RECT rect;
- rect.left = rect.right = 10;
- rect.bottom = rect.top = 5;
- cLyt->SetPadding(rect);
- cListLyt->Add(cLyt);
- }
-}
-
-HBITMAP Launcher::IconToBitmap(HICON hIcon, SIZE* pTargetSize)
-{
- ICONINFO info = { 0 };
- if (hIcon == NULL
- || !GetIconInfo(hIcon, &info)
- || !info.fIcon)
- {
- return NULL;
- }
-
- INT nWidth = 0;
- INT nHeight = 0;
- if (pTargetSize != NULL)
- {
- nWidth = pTargetSize->cx;
- nHeight = pTargetSize->cy;
- }
- else
- {
- if (info.hbmColor != NULL)
- {
- BITMAP bmp = { 0 };
- GetObject(info.hbmColor, sizeof(bmp), &bmp);
-
- nWidth = bmp.bmWidth;
- nHeight = bmp.bmHeight;
- }
- }
-
- if (info.hbmColor != NULL)
- {
- DeleteObject(info.hbmColor);
- info.hbmColor = NULL;
- }
-
- if (info.hbmMask != NULL)
- {
- DeleteObject(info.hbmMask);
- info.hbmMask = NULL;
- }
-
- if (nWidth <= 0
- || nHeight <= 0)
- {
- return NULL;
- }
-
- INT nPixelCount = nWidth * nHeight;
-
- HDC dc = GetDC(NULL);
- INT* pData = NULL;
- HDC dcMem = NULL;
- HBITMAP hBmpOld = NULL;
- bool* pOpaque = NULL;
- HBITMAP dib = NULL;
- BOOL bSuccess = FALSE;
-
- do
- {
- BITMAPINFOHEADER bi = { 0 };
- bi.biSize = sizeof(BITMAPINFOHEADER);
- bi.biWidth = nWidth;
- bi.biHeight = -nHeight;
- bi.biPlanes = 1;
- bi.biBitCount = BMPBITCOUNT;
- bi.biCompression = BI_RGB;
- dib = CreateDIBSection(dc, (BITMAPINFO*)&bi, DIB_RGB_COLORS, (VOID**)&pData, NULL, 0);
- if (dib == NULL) break;
-
- memset(pData, 0, nPixelCount * 4);
-
- dcMem = CreateCompatibleDC(dc);
- if (dcMem == NULL) break;
-
- hBmpOld = (HBITMAP)SelectObject(dcMem, dib);
- ::DrawIconEx(dcMem, 0, 0, hIcon, nWidth, nHeight, 0, NULL, DI_MASK);
-
- pOpaque = new(std::nothrow) bool[nPixelCount];
- if (pOpaque == NULL) break;
- for (INT i = 0; i < nPixelCount; ++i)
- {
- pOpaque[i] = !pData[i];
- }
-
- memset(pData, 0, nPixelCount * 4);
- ::DrawIconEx(dcMem, 0, 0, hIcon, nWidth, nHeight, 0, NULL, DI_NORMAL);
-
- BOOL bPixelHasAlpha = FALSE;
- UINT* pPixel = (UINT*)pData;
- for (INT i = 0; i < nPixelCount; ++i, ++pPixel)
- {
- if ((*pPixel & 0xff000000) != 0)
- {
- bPixelHasAlpha = TRUE;
- break;
- }
- }
-
- if (!bPixelHasAlpha)
- {
- pPixel = (UINT*)pData;
- for (INT i = 0; i < nPixelCount; ++i, ++pPixel)
- {
- if (pOpaque[i])
- {
- *pPixel |= 0xFF000000;
- }
- else
- {
- *pPixel &= 0x00FFFFFF;
- }
- }
- }
-
- bSuccess = TRUE;
-
- } while (FALSE);
-
-
- if (pOpaque != NULL)
- {
- delete[]pOpaque;
- pOpaque = NULL;
- }
-
- if (dcMem != NULL)
- {
- SelectObject(dcMem, hBmpOld);
- DeleteDC(dcMem);
- }
-
- ReleaseDC(NULL, dc);
-
- if (!bSuccess)
- {
- if (dib != NULL)
- {
- DeleteObject(dib);
- dib = NULL;
- }
- }
-
- return dib;
-}
-
-BOOL Launcher::SaveBmp(HBITMAP hBitmap, LPCSTR FileName)
-{
-// hBitmap = TransparentImage(hBitmap);
- HDC hDC;
- //当前分辨率下每象素所占字节数
- int iBits;
- //位图中每象素所占字节数
- WORD wBitCount;
- //定义调色板大小, 位图中像素字节大小 ,位图文件大小 , 写入文件字节数
- DWORD dwPaletteSize = 0, dwBmBitsSize = 0, dwDIBSize = 0, dwWritten = 0;
- //位图属性结构
- BITMAP Bitmap;
- //位图文件头结构
- BITMAPFILEHEADER bmfHdr;
- //位图信息头结构
- BITMAPINFOHEADER bi;
- //指向位图信息头结构
- LPBITMAPINFOHEADER lpbi;
- //定义文件,分配内存句柄,调色板句柄
- HANDLE fh, hDib, hPal, hOldPal = NULL;
-
- //计算位图文件每个像素所占字节数
- hDC = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
- iBits = GetDeviceCaps(hDC, BITSPIXEL) * GetDeviceCaps(hDC, PLANES);
- DeleteDC(hDC);
- if (iBits <= 1)
- wBitCount = 1;
- else if (iBits <= 4)
- wBitCount = 4;
- else if (iBits <= 8)
- wBitCount = 8;
- else
- wBitCount = BMPBITCOUNT;
-
- GetObject(hBitmap, sizeof(Bitmap), (LPSTR)&Bitmap);
- bi.biSize = sizeof(BITMAPINFOHEADER);
- bi.biWidth = Bitmap.bmWidth;
- bi.biHeight = Bitmap.bmHeight;
- bi.biPlanes = 1;
- bi.biBitCount = wBitCount;
- bi.biCompression = BI_RGB;
- bi.biSizeImage = 0;
- bi.biXPelsPerMeter = 0;
- bi.biYPelsPerMeter = 0;
- bi.biClrImportant = 0;
- bi.biClrUsed = 0;
-
- dwBmBitsSize = ((Bitmap.bmWidth *wBitCount + 31) / 32) * 4 * Bitmap.bmHeight;
-
- //为位图内容分配内存
- hDib = GlobalAlloc(GHND, dwBmBitsSize + dwPaletteSize + sizeof(BITMAPINFOHEADER));
- lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDib);
- *lpbi = bi;
-
- // 处理调色板
- hPal = GetStockObject(DEFAULT_PALETTE);
- if (hPal)
- {
- hDC = ::GetDC(NULL);
- hOldPal = ::SelectPalette(hDC, (HPALETTE)hPal, FALSE);
- RealizePalette(hDC);
- }
-
- // 获取该调色板下新的像素值
- GetDIBits(hDC, hBitmap, 0, (UINT)Bitmap.bmHeight,
- (LPSTR)lpbi + sizeof(BITMAPINFOHEADER)+dwPaletteSize,
- (BITMAPINFO *)lpbi, DIB_RGB_COLORS);
-
- //恢复调色板
- if (hOldPal)
- {
- ::SelectPalette(hDC, (HPALETTE)hOldPal, TRUE);
- RealizePalette(hDC);
- ::ReleaseDC(NULL, hDC);
- }
-
- //创建位图文件
- LPCTSTR strFileName = NULL;
-#ifdef _UNICODE
- wchar_t strT[100] = { 0 };
- c2w(strT, 100, FileName);
- strFileName = strT;
-#else
- strFileName = FileName;
-#endif
- STDSTRING path = WriteablePath + strFileName;
- fh = CreateFile(path.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
- FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
-
- if (fh == INVALID_HANDLE_VALUE) return FALSE;
-
- // 设置位图文件头
- bmfHdr.bfType = 0x4D42; // "BM"
- dwDIBSize = sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+dwPaletteSize + dwBmBitsSize;
- bmfHdr.bfSize = dwDIBSize;
- bmfHdr.bfReserved1 = 0;
- bmfHdr.bfReserved2 = 0;
- bmfHdr.bfOffBits = (DWORD)sizeof(BITMAPFILEHEADER)+(DWORD)sizeof(BITMAPINFOHEADER)+dwPaletteSize;
- // 写入位图文件头
- WriteFile(fh, (LPSTR)&bmfHdr, sizeof(BITMAPFILEHEADER), &dwWritten, NULL);
- // 写入位图文件其余内容
- WriteFile(fh, (LPSTR)lpbi, dwDIBSize, &dwWritten, NULL);
- //清除
- GlobalUnlock(hDib);
- GlobalFree(hDib);
- CloseHandle(fh);
-
- return TRUE;
-}
diff --git a/demo/Launcher/Launcher.h b/demo/Launcher/Launcher.h
deleted file mode 100644
index ec7ce92..0000000
--- a/demo/Launcher/Launcher.h
+++ /dev/null
@@ -1,79 +0,0 @@
-#pragma once
-#include