├── .gitattributes ├── .gitignore ├── AccListMgr.cpp ├── AccListMgr.h ├── BrowserTabUI.cpp ├── BrowserTabUI.h ├── CefWndWrapManager.cpp ├── CefWndWrapManager.h ├── CircleImageUI.cpp ├── CircleImageUI.h ├── ClassLive.cpp ├── DBClickLabelUI.cpp ├── DBClickLabelUI.h ├── HelpWebWindow.cpp ├── HelpWebWindow.h ├── Include ├── ByteFreqChecker.h ├── Common.h ├── CommonMsgDef.h ├── DDBUtil.h ├── FontMgr.h ├── IMDataDef.h ├── SendUserDataType.h ├── StarDataDef.h ├── UICommonDef.h ├── URLDetector.h ├── XDictIMRTFParser.h └── clipboard.h ├── LoginUserDataMgr.cpp ├── LoginUserDataMgr.h ├── LoginWindow.cpp ├── LoginWindow.h ├── Mainframe.cpp ├── Mainframe.h ├── MessageUserdefine.h ├── MsgBox ├── CommonPopupWindow.cpp ├── CommonPopupWindow.h ├── DuiCloseMessageBox.cpp ├── DuiCommMessageBox.cpp ├── DuiCommMessageBox.h ├── DuiMessageBoxDefine.h └── duiclosemessagebox.h ├── NetTask ├── PicTransServ.cpp ├── PicTransServ.h ├── PicTransTask.cpp └── PicTransTask.h ├── ReadMe.md ├── Resource.h ├── Rocket.h ├── Rocket.ico ├── Rocket.rc ├── Rocket.sln ├── Rocket.vcxproj ├── Rocket.vcxproj.filters ├── RoomWindow.cpp ├── RoomWindow.h ├── SACModule.cpp ├── SACModule.h ├── TimeMgr.h ├── TroyControls.h ├── UICef3Web.cpp ├── UICef3Web.h ├── UIImageAnimate.cpp ├── UIImageAnimate.h ├── UIListItemCust.cpp ├── UIListItemCust.h ├── UIVerticalLayoutBK.cpp ├── UIVerticalLayoutBK.h ├── UIVideo.cpp ├── UIVideo.h ├── UserDatMgr.cpp ├── UserDataMgr.h ├── VideoWnd.cpp ├── VideoWnd.h ├── small.ico ├── stdafx.cpp ├── stdafx.h └── targetver.h /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | [Aa][Rr][Mm]/ 24 | [Aa][Rr][Mm]64/ 25 | bld/ 26 | [Bb]in/ 27 | [Oo]bj/ 28 | [Ll]og/ 29 | 30 | # Visual Studio 2015/2017 cache/options directory 31 | .vs/ 32 | # Uncomment if you have tasks that create the project's static files in wwwroot 33 | #wwwroot/ 34 | 35 | # Visual Studio 2017 auto generated files 36 | Generated\ Files/ 37 | 38 | # MSTest test Results 39 | [Tt]est[Rr]esult*/ 40 | [Bb]uild[Ll]og.* 41 | 42 | # NUNIT 43 | *.VisualState.xml 44 | TestResult.xml 45 | 46 | # Build Results of an ATL Project 47 | [Dd]ebugPS/ 48 | [Rr]eleasePS/ 49 | dlldata.c 50 | 51 | # Benchmark Results 52 | BenchmarkDotNet.Artifacts/ 53 | 54 | # .NET Core 55 | project.lock.json 56 | project.fragment.lock.json 57 | artifacts/ 58 | 59 | # StyleCop 60 | StyleCopReport.xml 61 | 62 | # Files built by Visual Studio 63 | *_i.c 64 | *_p.c 65 | *_h.h 66 | *.ilk 67 | *.meta 68 | *.obj 69 | *.iobj 70 | *.pch 71 | *.pdb 72 | *.ipdb 73 | *.pgc 74 | *.pgd 75 | *.rsp 76 | *.sbr 77 | *.tlb 78 | *.tli 79 | *.tlh 80 | *.tmp 81 | *.tmp_proj 82 | *_wpftmp.csproj 83 | *.log 84 | *.vspscc 85 | *.vssscc 86 | .builds 87 | *.pidb 88 | *.svclog 89 | *.scc 90 | 91 | # Chutzpah Test files 92 | _Chutzpah* 93 | 94 | # Visual C++ cache files 95 | ipch/ 96 | *.aps 97 | *.ncb 98 | *.opendb 99 | *.opensdf 100 | *.sdf 101 | *.cachefile 102 | *.VC.db 103 | *.VC.VC.opendb 104 | 105 | # Visual Studio profiler 106 | *.psess 107 | *.vsp 108 | *.vspx 109 | *.sap 110 | 111 | # Visual Studio Trace Files 112 | *.e2e 113 | 114 | # TFS 2012 Local Workspace 115 | $tf/ 116 | 117 | # Guidance Automation Toolkit 118 | *.gpState 119 | 120 | # ReSharper is a .NET coding add-in 121 | _ReSharper*/ 122 | *.[Rr]e[Ss]harper 123 | *.DotSettings.user 124 | 125 | # JustCode is a .NET coding add-in 126 | .JustCode 127 | 128 | # TeamCity is a build add-in 129 | _TeamCity* 130 | 131 | # DotCover is a Code Coverage Tool 132 | *.dotCover 133 | 134 | # AxoCover is a Code Coverage Tool 135 | .axoCover/* 136 | !.axoCover/settings.json 137 | 138 | # Visual Studio code coverage results 139 | *.coverage 140 | *.coveragexml 141 | 142 | # NCrunch 143 | _NCrunch_* 144 | .*crunch*.local.xml 145 | nCrunchTemp_* 146 | 147 | # MightyMoose 148 | *.mm.* 149 | AutoTest.Net/ 150 | 151 | # Web workbench (sass) 152 | .sass-cache/ 153 | 154 | # Installshield output folder 155 | [Ee]xpress/ 156 | 157 | # DocProject is a documentation generator add-in 158 | DocProject/buildhelp/ 159 | DocProject/Help/*.HxT 160 | DocProject/Help/*.HxC 161 | DocProject/Help/*.hhc 162 | DocProject/Help/*.hhk 163 | DocProject/Help/*.hhp 164 | DocProject/Help/Html2 165 | DocProject/Help/html 166 | 167 | # Click-Once directory 168 | publish/ 169 | 170 | # Publish Web Output 171 | *.[Pp]ublish.xml 172 | *.azurePubxml 173 | # Note: Comment the next line if you want to checkin your web deploy settings, 174 | # but database connection strings (with potential passwords) will be unencrypted 175 | *.pubxml 176 | *.publishproj 177 | 178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 179 | # checkin your Azure Web App publish settings, but sensitive information contained 180 | # in these scripts will be unencrypted 181 | PublishScripts/ 182 | 183 | # NuGet Packages 184 | *.nupkg 185 | # The packages folder can be ignored because of Package Restore 186 | **/[Pp]ackages/* 187 | # except build/, which is used as an MSBuild target. 188 | !**/[Pp]ackages/build/ 189 | # Uncomment if necessary however generally it will be regenerated when needed 190 | #!**/[Pp]ackages/repositories.config 191 | # NuGet v3's project.json files produces more ignorable files 192 | *.nuget.props 193 | *.nuget.targets 194 | 195 | # Microsoft Azure Build Output 196 | csx/ 197 | *.build.csdef 198 | 199 | # Microsoft Azure Emulator 200 | ecf/ 201 | rcf/ 202 | 203 | # Windows Store app package directories and files 204 | AppPackages/ 205 | BundleArtifacts/ 206 | Package.StoreAssociation.xml 207 | _pkginfo.txt 208 | *.appx 209 | 210 | # Visual Studio cache files 211 | # files ending in .cache can be ignored 212 | *.[Cc]ache 213 | # but keep track of directories ending in .cache 214 | !?*.[Cc]ache/ 215 | 216 | # Others 217 | ClientBin/ 218 | ~$* 219 | *~ 220 | *.dbmdl 221 | *.dbproj.schemaview 222 | *.jfm 223 | *.pfx 224 | *.publishsettings 225 | orleans.codegen.cs 226 | 227 | # Including strong name files can present a security risk 228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 229 | #*.snk 230 | 231 | # Since there are multiple workflows, uncomment next line to ignore bower_components 232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 233 | #bower_components/ 234 | 235 | # RIA/Silverlight projects 236 | Generated_Code/ 237 | 238 | # Backup & report files from converting an old project file 239 | # to a newer Visual Studio version. Backup files are not needed, 240 | # because we have git ;-) 241 | _UpgradeReport_Files/ 242 | Backup*/ 243 | UpgradeLog*.XML 244 | UpgradeLog*.htm 245 | ServiceFabricBackup/ 246 | *.rptproj.bak 247 | 248 | # SQL Server files 249 | *.mdf 250 | *.ldf 251 | *.ndf 252 | 253 | # Business Intelligence projects 254 | *.rdl.data 255 | *.bim.layout 256 | *.bim_*.settings 257 | *.rptproj.rsuser 258 | *- Backup*.rdl 259 | 260 | # Microsoft Fakes 261 | FakesAssemblies/ 262 | 263 | # GhostDoc plugin setting file 264 | *.GhostDoc.xml 265 | 266 | # Node.js Tools for Visual Studio 267 | .ntvs_analysis.dat 268 | node_modules/ 269 | 270 | # Visual Studio 6 build log 271 | *.plg 272 | 273 | # Visual Studio 6 workspace options file 274 | *.opt 275 | 276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 277 | *.vbw 278 | 279 | # Visual Studio LightSwitch build output 280 | **/*.HTMLClient/GeneratedArtifacts 281 | **/*.DesktopClient/GeneratedArtifacts 282 | **/*.DesktopClient/ModelManifest.xml 283 | **/*.Server/GeneratedArtifacts 284 | **/*.Server/ModelManifest.xml 285 | _Pvt_Extensions 286 | 287 | # Paket dependency manager 288 | .paket/paket.exe 289 | paket-files/ 290 | 291 | # FAKE - F# Make 292 | .fake/ 293 | 294 | # JetBrains Rider 295 | .idea/ 296 | *.sln.iml 297 | 298 | # CodeRush personal settings 299 | .cr/personal 300 | 301 | # Python Tools for Visual Studio (PTVS) 302 | __pycache__/ 303 | *.pyc 304 | 305 | # Cake - Uncomment if you are using it 306 | # tools/** 307 | # !tools/packages.config 308 | 309 | # Tabs Studio 310 | *.tss 311 | 312 | # Telerik's JustMock configuration file 313 | *.jmconfig 314 | 315 | # BizTalk build output 316 | *.btp.cs 317 | *.btm.cs 318 | *.odx.cs 319 | *.xsd.cs 320 | 321 | # OpenCover UI analysis results 322 | OpenCover/ 323 | 324 | # Azure Stream Analytics local run output 325 | ASALocalRun/ 326 | 327 | # MSBuild Binary and Structured Log 328 | *.binlog 329 | 330 | # NVidia Nsight GPU debugger configuration file 331 | *.nvuser 332 | 333 | # MFractors (Xamarin productivity tool) working folder 334 | .mfractor/ 335 | 336 | # Local History for Visual Studio 337 | .localhistory/ 338 | 339 | # BeatPulse healthcheck temp database 340 | healthchecksdb -------------------------------------------------------------------------------- /AccListMgr.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "AccListMgr.h" 3 | #include 4 | #include "../../baseclass/AESDecoder.h" 5 | #include "../../baseclass/AESPWD.h" 6 | #include "Base.h" 7 | #include "../../baseclass/PathBase.h" 8 | #include 9 | 10 | CAccListMgr::CAccListMgr(void) 11 | { 12 | } 13 | 14 | CAccListMgr::~CAccListMgr(void) 15 | { 16 | ReleaseList(); 17 | } 18 | 19 | HRESULT CAccListMgr::LoadAcc(LPCWSTR lpwsFile) 20 | { 21 | if(NULL == lpwsFile || !PathFileExists(lpwsFile)) 22 | return E_INVALIDARG; 23 | 24 | HANDLE hFile = CreateFile(lpwsFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); 25 | if(INVALID_HANDLE_VALUE == hFile) 26 | return E_FAIL; 27 | 28 | ACAccountFileHeader header = {0}; 29 | HRESULT hr = ReadHeader(hFile, &header); 30 | if(FAILED(hr)) 31 | return hr; 32 | 33 | ReleaseList(); 34 | 35 | if(S_OK == hr) 36 | hr = LoadAcc(hFile, &header); 37 | 38 | CloseHandle(hFile); 39 | return hr; 40 | } 41 | 42 | 43 | HRESULT CAccListMgr::LoadAcc(HANDLE hFile, ACAccountFileHeader* lpHeader) 44 | { 45 | ATLASSERT(INVALID_HANDLE_VALUE != hFile); 46 | ATLASSERT(lpHeader); 47 | 48 | SetFilePointer(hFile, sizeof(ACAccountFileHeader) + lpHeader->dwOffset, NULL, FILE_BEGIN); 49 | 50 | DWORD dwSize = GetFileSize(hFile, NULL); 51 | if( dwSize == 0 || dwSize==INVALID_FILE_SIZE) 52 | return E_FAIL; 53 | 54 | CAutoVectorPtr spEncBuf; 55 | spEncBuf.Allocate(dwSize); 56 | 57 | DWORD dwReaded = 0; 58 | if(!ReadFile(hFile, spEncBuf, dwSize-sizeof(ACAccountFileHeader), &dwReaded, NULL)) 59 | return E_FAIL; 60 | 61 | if (lpHeader &&lpHeader->dwVersion!= SAC_ACCOUNT_FILE_VER) 62 | { 63 | return E_FAIL; 64 | } 65 | 66 | CAESDecoder cd; 67 | std::unique_ptr spbyBuf; 68 | 69 | DWORD dwDecLen = 0; 70 | if(!cd.AESDecode((LPBYTE)spEncBuf, dwReaded, AESPWD_KEY, (LPBYTE*)&spbyBuf, &dwDecLen)) 71 | return E_FAIL; 72 | 73 | CDataStreamEx data; 74 | data.Attach(spbyBuf.get(), dwDecLen, dwDecLen); 75 | 76 | HRESULT hr = E_FAIL; 77 | do 78 | { 79 | DWORD dwItemCount = 0; 80 | if(!data.GetUINT((UINT&)dwItemCount)) 81 | break; 82 | 83 | DWORD dwAdded = 0; 84 | for(DWORD i = 0; i < dwItemCount; ++i) 85 | { 86 | PACCATTI pItem = new ACCATTI; 87 | HRESULT hr1 = ParseItem(data, pItem); 88 | if(SUCCEEDED(hr1)) 89 | { 90 | m_vecAccList.push_back(pItem); 91 | ++ dwAdded; 92 | } 93 | else 94 | { 95 | delete pItem; 96 | ATLASSERT(FALSE); 97 | } 98 | } 99 | if(dwAdded > 0) 100 | { 101 | hr = S_OK; 102 | } 103 | } while (FALSE); 104 | 105 | data.Detach(); 106 | 107 | return hr ; 108 | } 109 | 110 | HRESULT CAccListMgr::ParseItem(CDataStreamEx& data, PACCATTI lpItem) 111 | { 112 | bool bRtn = CDataStreamEx::ParseStringW(data, lpItem->strAcc); 113 | bRtn = bRtn && CDataStreamEx::ParseStringW(data, lpItem->strPasswd); 114 | return bRtn ? S_OK : E_FAIL; 115 | } 116 | 117 | HRESULT CAccListMgr::SaveAcc(CDataStreamEx& data) 118 | { 119 | UINT uCount = (UINT)m_vecAccList.size(); 120 | data.AppendUINT(uCount); 121 | 122 | DWORD dwAdd = 0; 123 | for(size_t i = 0; i < m_vecAccList.size(); ++i) 124 | { 125 | PACCATTI pItem = m_vecAccList.at(i); 126 | if(pItem) 127 | { 128 | UINT uOffset = data.GetPointer(); 129 | bool bRtn = data.AppendTextW(pItem->strAcc); 130 | bRtn = bRtn && data.AppendTextW(pItem->strPasswd); 131 | if(!bRtn) 132 | { 133 | ATLASSERT(FALSE); 134 | data.SetPointer(uOffset); 135 | } 136 | else 137 | { 138 | ++dwAdd; 139 | } 140 | } 141 | } 142 | return dwAdd == (DWORD)m_vecAccList.size() ? S_OK : S_FALSE; 143 | } 144 | //================================================================================================= 145 | 146 | HRESULT CAccListMgr::SaveAcc(LPCWSTR lpwsFile) 147 | { 148 | if(NULL == lpwsFile) 149 | return E_INVALIDARG; 150 | 151 | CPathHelperBase::MakeDirExist(lpwsFile, true); 152 | 153 | CHandle hFile(CreateFile(lpwsFile, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)); 154 | if(INVALID_HANDLE_VALUE == hFile) 155 | return E_FAIL; 156 | 157 | ACAccountFileHeader header = {0}; 158 | header.dwFileFlag = SAC_ACCOUNT_FILE_FLAG; 159 | header.dwVersion = SAC_ACCOUNT_FILE_VER; 160 | 161 | HRESULT hr = E_FAIL; 162 | DWORD dwWrited = 0; 163 | do 164 | { 165 | if(!WriteFile(hFile, &header, sizeof(header), &dwWrited, NULL)) 166 | break; 167 | 168 | CDataStreamEx data; 169 | hr = SaveAcc(data); 170 | if(FAILED(hr)) 171 | break; 172 | 173 | LPBYTE pby = NULL; 174 | DWORD dwEncLen = 0; 175 | CAESDecoder cd; 176 | if(!cd.AESEncode(data.GetBuffer(0), data.GetPointer(), AESPWD_KEY, &pby, &dwEncLen)) 177 | { 178 | hr = E_FAIL; 179 | break; 180 | } 181 | std::unique_ptr spEncBuf(pby); 182 | if(!WriteFile(hFile, (LPBYTE)spEncBuf.get(), dwEncLen, &dwWrited, NULL)) 183 | { 184 | hr = E_FAIL; 185 | break; 186 | } 187 | } while (FALSE); 188 | 189 | return hr; 190 | } 191 | 192 | HRESULT CAccListMgr::AddAccount(PACCATTI lpAcc) 193 | { 194 | if(NULL == lpAcc) 195 | return E_INVALIDARG; 196 | 197 | //todo check data valid 198 | 199 | RemoveAccount(lpAcc->strAcc); 200 | AccArray::iterator it = m_vecAccList.begin(); 201 | m_vecAccList.insert(it, lpAcc); 202 | 203 | return S_OK; 204 | } 205 | 206 | HRESULT CAccListMgr::RemoveAccount(LPCWSTR lpwsAccount) 207 | { 208 | if(NULL == lpwsAccount) 209 | return E_INVALIDARG; 210 | 211 | AccArray::iterator it = m_vecAccList.begin(); 212 | for(; it != m_vecAccList.end(); ++it) 213 | { 214 | if((*it)->strAcc.CompareNoCase(lpwsAccount) == 0) 215 | { 216 | PACCATTI* p = (PACCATTI*)(*it); 217 | if (p) 218 | { 219 | delete p; 220 | p = NULL; 221 | } 222 | m_vecAccList.erase(it); 223 | break; 224 | } 225 | } 226 | return S_OK; 227 | } 228 | 229 | size_t CAccListMgr::GetAccountCount() 230 | { 231 | return m_vecAccList.size(); 232 | } 233 | 234 | PACCATTI CAccListMgr::GetAccount(size_t index) 235 | { 236 | if(m_vecAccList.size() <= index) 237 | return NULL; 238 | 239 | return m_vecAccList.at(index); 240 | } 241 | 242 | PACCATTI CAccListMgr::FindByAccount(LPCWSTR lpwsAccount) 243 | { 244 | for(size_t i = 0; i < m_vecAccList.size(); ++i) 245 | { 246 | PACCATTI pItem = m_vecAccList.at(i); 247 | if(pItem && pItem->strAcc.CompareNoCase(lpwsAccount) == 0) 248 | { 249 | return pItem; 250 | } 251 | } 252 | return NULL; 253 | } 254 | 255 | PACCATTI CAccListMgr::FindByAccountPart(LPCWSTR lpwsAccount) 256 | { 257 | for(size_t i = 0; i < m_vecAccList.size(); ++i) 258 | { 259 | PACCATTI pItem = m_vecAccList.at(i); 260 | if(pItem) 261 | { 262 | if(pItem->strAcc.Find(lpwsAccount) == 0) 263 | return pItem; 264 | } 265 | } 266 | return NULL; 267 | } 268 | 269 | //================================================================================================= 270 | HRESULT CAccListMgr::ReadHeader(HANDLE hFile, ACAccountFileHeader* lpHeader) 271 | { 272 | ATLASSERT(INVALID_HANDLE_VALUE != hFile); 273 | 274 | DWORD dwReaded = 0; 275 | DWORD dwSizeHigh = 0; 276 | DWORD dwSizeLow = GetFileSize(hFile, &dwSizeHigh); 277 | if(dwSizeHigh != 0 || INVALID_FILE_SIZE == dwSizeLow) 278 | { 279 | ATLASSERT(FALSE); 280 | return E_OUTOFMEMORY; 281 | } 282 | 283 | if(dwSizeLow >= sizeof(DWORD)) 284 | { 285 | DWORD dwFlag = 0; 286 | if(!ReadFile(hFile, &dwFlag, sizeof(dwFlag), &dwReaded, NULL)) 287 | return E_FAIL; 288 | 289 | if(dwFlag != SAC_ACCOUNT_FILE_FLAG) 290 | return S_FALSE; 291 | } 292 | else 293 | { 294 | ATLASSERT(FALSE); 295 | return E_FAIL; 296 | } 297 | 298 | if(dwSizeLow < sizeof(ACAccountFileHeader)) 299 | { 300 | //Version Check 301 | return E_FAIL; 302 | } 303 | 304 | SetFilePointer(hFile, 0, NULL, FILE_BEGIN); 305 | if(!ReadFile(hFile, lpHeader, sizeof(ACAccountFileHeader), &dwReaded, NULL)) 306 | return E_FAIL; 307 | 308 | return S_OK; 309 | } 310 | 311 | //================================================================================================= 312 | 313 | void CAccListMgr::ReleaseList() 314 | { 315 | if (m_vecAccList.size() == 0 ) 316 | { 317 | return; 318 | } 319 | 320 | for (UINT i=0; i 3 | #include "../../baseclass/DataStream.h" 4 | 5 | #define SAC_ACCOUNT_FILE_FLAG 0x41434147 6 | 7 | #define SAC_ACCOUNT_FILE_VER 2 8 | 9 | struct ACAccountFileHeader 10 | { 11 | DWORD dwFileFlag; 12 | DWORD dwVersion; 13 | DWORD dwReserved; 14 | DWORD dwOffset; 15 | }; 16 | 17 | typedef struct _tagAccattri 18 | { 19 | CString strAcc; 20 | CString strPasswd; 21 | }ACCATTI, *PACCATTI; 22 | 23 | typedef std::vector AccArray; 24 | 25 | class CAccListMgr 26 | { 27 | public: 28 | CAccListMgr(void); 29 | virtual ~CAccListMgr(void); 30 | 31 | public: 32 | HRESULT LoadAcc(LPCWSTR lpwsFile); 33 | HRESULT SaveAcc(LPCWSTR lpwsFile); 34 | 35 | private: 36 | HRESULT LoadAcc(HANDLE hFile, ACAccountFileHeader* lpHeader); 37 | HRESULT ParseItem(CDataStreamEx& data, PACCATTI lpItem); 38 | 39 | private: 40 | HRESULT SaveAcc(CDataStreamEx& data); 41 | 42 | public: 43 | HRESULT AddAccount(PACCATTI lpAcc); 44 | HRESULT RemoveAccount(LPCWSTR lpwsAccount); 45 | 46 | size_t GetAccountCount(); 47 | PACCATTI GetAccount(size_t index); 48 | 49 | PACCATTI FindByAccount(LPCWSTR lpwsAccount); 50 | PACCATTI FindByAccountPart(LPCWSTR lpwsAccount); 51 | 52 | private: 53 | HRESULT ReadHeader(HANDLE hFile, ACAccountFileHeader* lpHeader); 54 | void ReleaseList(); 55 | 56 | private: 57 | AccArray m_vecAccList; 58 | }; 59 | 60 | -------------------------------------------------------------------------------- /BrowserTabUI.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "BrowserTabUI.h" 3 | 4 | 5 | CBrowserTabUI::CBrowserTabUI() 6 | { 7 | } 8 | 9 | 10 | CBrowserTabUI::~CBrowserTabUI() 11 | { 12 | } 13 | 14 | LPCTSTR CBrowserTabUI::GetClass() const 15 | { 16 | return L"BrowserTabUI"; 17 | } 18 | 19 | LPVOID CBrowserTabUI::GetInterface(LPCTSTR pstrName) 20 | { 21 | if (_tcscmp(pstrName, _T("BrowserTabUI")) == 0) 22 | return static_cast(this); 23 | 24 | return COptionUI::GetInterface(pstrName); 25 | } 26 | 27 | void CBrowserTabUI::DoEvent(TEventUI& event) 28 | { 29 | if (!IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND) { 30 | if (m_pParent != NULL) m_pParent->DoEvent(event); 31 | else COptionUI::DoEvent(event); 32 | return; 33 | } 34 | 35 | if (event.Type == UIEVENT_BUTTONDOWN ) 36 | { 37 | if (::PtInRect(&m_rcClose, event.ptMouse)) { 38 | Invalidate(); 39 | } 40 | } 41 | if (event.Type == UIEVENT_MOUSEMOVE) 42 | { 43 | if (::PtInRect(&m_rcClose, event.ptMouse)) 44 | { 45 | if ((m_uCloseButtonState & UISTATE_HOT) == 0) 46 | { 47 | m_uCloseButtonState |= UISTATE_HOT; 48 | Invalidate(); 49 | } 50 | } 51 | else 52 | { 53 | if ((m_uCloseButtonState & UISTATE_HOT) != 0) { 54 | m_uCloseButtonState &= ~UISTATE_HOT; 55 | Invalidate(); 56 | } 57 | } 58 | } 59 | if (event.Type == UIEVENT_BUTTONUP) 60 | { 61 | if (::PtInRect(&m_rcClose, event.ptMouse)) 62 | { 63 | m_pManager->SendNotify(this, DUI_MSGTYPE_BROWSERBAR_CLOSETAB, event.wParam, event.lParam); 64 | } 65 | } 66 | 67 | COptionUI::DoEvent(event); 68 | } 69 | 70 | void CBrowserTabUI::DoInit() 71 | { 72 | m_uCloseButtonState = 0; 73 | } 74 | 75 | void CBrowserTabUI::DoPaint(HDC hDC, const RECT& rcPaint) 76 | { 77 | COptionUI::DoPaint(hDC, rcPaint); 78 | PaintIcon(hDC, rcPaint); 79 | PaintClose(hDC, rcPaint); 80 | } 81 | 82 | void CBrowserTabUI::DoPostPaint(HDC hDC, const RECT& rcPaint) 83 | { 84 | return; 85 | } 86 | 87 | void CBrowserTabUI::PaintStatusImage(HDC hDC) 88 | { 89 | COptionUI::PaintStatusImage(hDC); 90 | } 91 | 92 | void CBrowserTabUI::PaintIcon(HDC hDC, const RECT& rcpaint) 93 | { 94 | RECT rc; 95 | rc.left = m_rcItem.left + m_rcIconPadding.left; 96 | rc.top = m_rcItem.top + m_rcIconPadding.top; 97 | rc.right = rc.left + m_szIcon.cx; 98 | rc.bottom = rc.top + m_szIcon.cy; 99 | 100 | CRenderEngine::DrawImageString(hDC, m_pManager, rc, m_rcPaint, m_sIconImage, L""); 101 | } 102 | 103 | void CBrowserTabUI::PaintClose(HDC hDC, const RECT& rcpaint) 104 | { 105 | RECT rc; 106 | rc.right = m_rcItem.right - m_rcClosePadding.right; 107 | rc.top = m_rcItem.top + m_rcClosePadding.top; 108 | rc.left = rc.right - m_szClose.cx; 109 | rc.bottom = rc.top + m_szClose.cy; 110 | 111 | m_rcClose = rc; 112 | 113 | if ((m_uCloseButtonState & UISTATE_HOT) != 0) { 114 | CRenderEngine::DrawImageString(hDC, m_pManager, rc, m_rcPaint, m_sCloseHotImge, L""); 115 | } 116 | else 117 | { 118 | CRenderEngine::DrawImageString(hDC, m_pManager, rc, m_rcPaint, m_sCloseImage, L""); 119 | } 120 | } 121 | 122 | void CBrowserTabUI::SetIconSize(SIZE szIcon) 123 | { 124 | m_szIcon = szIcon; 125 | } 126 | 127 | void CBrowserTabUI::SetIconPadding(RECT rcPadding) 128 | { 129 | m_rcIconPadding = rcPadding; 130 | } 131 | 132 | void CBrowserTabUI::SetIconImage(LPCTSTR pStrCursor) 133 | { 134 | m_sIconImage = pStrCursor; 135 | } 136 | 137 | void CBrowserTabUI::SetCloseSize(SIZE szIcon) 138 | { 139 | m_szClose = szIcon; 140 | } 141 | 142 | void CBrowserTabUI::SetClosePadding(RECT rcPadding) 143 | { 144 | m_rcClosePadding = rcPadding; 145 | } 146 | 147 | void CBrowserTabUI::SetCloseImage(LPCTSTR pStrCursor) 148 | { 149 | m_sCloseImage = pStrCursor; 150 | } 151 | 152 | void CBrowserTabUI::SetCloseHotImage(LPCTSTR pStrCloseHotImage) 153 | { 154 | m_sCloseHotImge = pStrCloseHotImage; 155 | } 156 | 157 | void CBrowserTabUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) 158 | { 159 | if (_tcscmp(pstrName, _T("iconImage")) == 0) 160 | { 161 | SetIconImage(pstrValue); 162 | } 163 | else if (_tcscmp(pstrName, _T("closeImage")) == 0) 164 | { 165 | SetCloseImage(pstrValue); 166 | } 167 | else if (_tcscmp(pstrName, _T("closehotImage")) == 0) 168 | { 169 | SetCloseHotImage(pstrValue); 170 | } 171 | else if (_tcscmp(pstrName, _T("closePadding")) == 0) 172 | { 173 | RECT rcTextPadding = { 0 }; 174 | LPTSTR pstr = NULL; 175 | rcTextPadding.left = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); 176 | rcTextPadding.top = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); 177 | rcTextPadding.right = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); 178 | rcTextPadding.bottom = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); 179 | SetClosePadding(rcTextPadding); 180 | } 181 | else if (_tcscmp(pstrName, _T("iconPadding")) == 0) 182 | { 183 | RECT rcTextPadding = { 0 }; 184 | LPTSTR pstr = NULL; 185 | rcTextPadding.left = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); 186 | rcTextPadding.top = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); 187 | rcTextPadding.right = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); 188 | rcTextPadding.bottom = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); 189 | SetIconPadding(rcTextPadding); 190 | } 191 | else if (_tcscmp(pstrName, _T("closesize")) == 0) 192 | { 193 | SIZE rcs = {0}; 194 | LPTSTR pstr = NULL; 195 | rcs.cx = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); 196 | rcs.cy = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); 197 | 198 | SetCloseSize(rcs); 199 | } 200 | else if (_tcscmp(pstrName, _T("iconsize")) == 0) 201 | { 202 | SIZE rcs = { 0 }; 203 | LPTSTR pstr = NULL; 204 | rcs.cx = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); 205 | rcs.cy = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); 206 | 207 | SetIconSize(rcs); 208 | } 209 | else 210 | { 211 | COptionUI::SetAttribute(pstrName, pstrValue); 212 | } 213 | } 214 | 215 | bool CBrowserTabUI::TestClose(POINT ptMouse) 216 | { 217 | return true; 218 | } 219 | -------------------------------------------------------------------------------- /BrowserTabUI.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CBrowserTabUI : public COptionUI 4 | { 5 | public: 6 | CBrowserTabUI(); 7 | virtual ~CBrowserTabUI(); 8 | 9 | public: 10 | LPCTSTR GetClass() const; 11 | LPVOID GetInterface(LPCTSTR pstrName); 12 | void DoEvent(TEventUI& event); 13 | 14 | void DoInit(); 15 | void DoPaint(HDC hDC, const RECT& rcPaint); 16 | void DoPostPaint(HDC hDC, const RECT& rcPaint); 17 | void PaintStatusImage(HDC hDC); 18 | void PaintIcon(HDC hDC, const RECT& rcpaint); 19 | void PaintClose(HDC hDC, const RECT& rcpaint); 20 | 21 | void SetIconSize(SIZE szIcon); 22 | void SetIconPadding(RECT rcPadding); 23 | void SetIconImage(LPCTSTR pStrCursor); 24 | 25 | void SetCloseSize(SIZE szIcon); 26 | void SetClosePadding(RECT rcPadding); 27 | void SetCloseImage(LPCTSTR pStrCursor); 28 | 29 | void SetCloseHotImage(LPCTSTR pStrCloseHotImage); 30 | 31 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 32 | 33 | protected: 34 | bool TestClose(POINT ptMouse); 35 | 36 | protected: 37 | bool m_bHitClose; 38 | RECT m_rcOldTextPadding; 39 | SIZE m_szIcon; 40 | RECT m_rcIconPadding; 41 | CDuiString m_sIconImage; 42 | 43 | SIZE m_szClose; 44 | RECT m_rcClosePadding; 45 | CDuiString m_sCloseImage; 46 | CDuiString m_sCloseHotImge; 47 | POINT m_ptMouse; 48 | RECT m_rcClose; 49 | 50 | UINT m_uCloseButtonState; 51 | }; 52 | 53 | -------------------------------------------------------------------------------- /CefWndWrapManager.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/CefWndWrapManager.cpp -------------------------------------------------------------------------------- /CefWndWrapManager.h: -------------------------------------------------------------------------------- 1 | /************************************************************************/ 2 | /* Cef3 Window manager */ */ 3 | /************************************************************************/ 4 | #pragma once 5 | 6 | class CCefContainerWnd; 7 | 8 | class CCefUIBase : public CControlUI, public IBrowserEvent 9 | { 10 | protected: 11 | static CString MakeSafeJSString(LPCWSTR szStr); 12 | 13 | public: 14 | CCefUIBase(); 15 | virtual ~CCefUIBase(); 16 | 17 | void AttachContainer(CCefContainerWnd * pContainer); 18 | virtual bool CreateBrowser(LPCTSTR szName = NULL, LPRECT rcBrowser = NULL, LPCWSTR lpcookiepath = NULL, LPCWSTR lpcookieServer = NULL, LPCWSTR lpdomain = NULL ); 19 | virtual bool CloseBrowser(); 20 | const HWND GetBrowserHWND() const; 21 | bool CloseBrowserOther(); 22 | bool IsCalledClose() { return m_bCalledClose; }; 23 | 24 | void GetCookie(LPCTSTR lpurl, LPCTSTR strcookiepath); 25 | 26 | protected: 27 | void NotifyCreated(); 28 | void NotifyClosed(); 29 | 30 | protected: 31 | HWND m_hBrowerWnd; 32 | CComPtr m_spCefWebBrowser; 33 | DWORD m_nTimeCreate; 34 | __int64 m_nLoadSize; 35 | 36 | private: 37 | CCefContainerWnd * m_pContainer; 38 | bool m_bCalledClose; 39 | }; 40 | 41 | class CCefContainerWnd : public WindowImplBase 42 | { 43 | public: 44 | CCefContainerWnd(bool bAutoDelete = true); 45 | virtual ~CCefContainerWnd(); 46 | 47 | virtual void OnCefCreated(CCefUIBase * pCef); 48 | //如果为子窗口的话,只有父窗口销毁后才会触发此消息 49 | virtual void OnCefClosed(CCefUIBase * pCef); 50 | //正在关闭 51 | virtual bool IsClosing(); 52 | //安全关闭,关闭成功后会有回调通知 53 | virtual void SafeClose(std::function funClosed); 54 | 55 | void AddCef(CCefUIBase * pCef); 56 | bool RemoveCef(CCefUIBase * pCef, bool bEnumChild = false); 57 | //这里面的父子关系都是逻辑父子关系,其窗口并无父子关联,如果窗口存在父子关系,则bRealChild参数为true 58 | void AddChildCefContainer(CCefContainerWnd* pChild, bool bRealChild = false); 59 | void RemoveChildCefContainer(CCefContainerWnd* pChild); 60 | 61 | void WaitLastMessageLoop(int iCount, int iDelay); 62 | 63 | // override WindowImplBase 64 | virtual LRESULT OnClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) override; 65 | virtual LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)override; 66 | virtual void OnFinalMessage(HWND hWnd)override; 67 | virtual CControlUI* CreateControl(LPCTSTR pstrClass)override; 68 | protected: 69 | virtual void DoClose() {}; 70 | virtual void OnChildClosed(CCefContainerWnd* pChild, bool bReal); 71 | 72 | private: 73 | void _SetFather(CCefContainerWnd* pFather, bool bReal = false); 74 | bool _EnumAndCloseCef(bool bEnumChild = false); 75 | CCefUIBase * _EnumUnCloseCef(bool bEnumChild = false); 76 | CCefUIBase * _GetUnCloseCef(); 77 | bool _IsRealFather(CCefContainerWnd* pFather); 78 | void _TryFinalClose(); 79 | 80 | private: 81 | enum SafeCloseStep 82 | { 83 | sc_nomal = 0, 84 | sc_doClose, 85 | sc_closing, 86 | }; 87 | 88 | private: 89 | friend class CCefWndWrapManager; 90 | std::vector m_vCefList; 91 | std::vector m_vChilds; 92 | bool m_bFatherReal; //真父窗口 93 | bool m_bAutoDelete; 94 | CCefContainerWnd * m_pFather; 95 | std::function m_funClosed; 96 | 97 | protected: 98 | SafeCloseStep m_eCloseStep; 99 | }; 100 | 101 | class CCefWndWrapManager 102 | { 103 | public: 104 | CCefWndWrapManager(void); 105 | virtual ~CCefWndWrapManager(void); 106 | 107 | static void Init(); 108 | static void UnInit(); 109 | 110 | static void AddItem(CCefContainerWnd * pItem, bool bAsyn = true); 111 | static void RemoveItem(CCefContainerWnd * pItem, bool bAsyn = true); 112 | 113 | private: 114 | static LRESULT __stdcall _MsgWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 115 | static const HWND _CreateWnd(const WNDPROC pfnWndProc, void * pData, const wchar_t * pwszWndName = NULL, const wchar_t * pwszClassName = NULL); 116 | static void _AddItem(CCefContainerWnd * pItem); 117 | static void _RemoveItem(CCefContainerWnd * pItem); 118 | 119 | private: 120 | static HWND m_hMgrWnd; 121 | static std::vector m_vWrapList; 122 | }; 123 | -------------------------------------------------------------------------------- /CircleImageUI.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "CircleImageUI.h" 3 | 4 | #include 5 | #include 6 | 7 | CCircleImageUI::CCircleImageUI() 8 | { 9 | m_pImagePathBitmap = NULL; 10 | } 11 | 12 | CCircleImageUI::~CCircleImageUI() 13 | { 14 | if (m_pImagePathBitmap) 15 | { 16 | delete m_pImagePathBitmap; 17 | m_pImagePathBitmap = NULL; 18 | } 19 | } 20 | 21 | LPCTSTR CCircleImageUI::GetClass() const 22 | { 23 | return _T("CircleImageUI"); 24 | } 25 | 26 | LPVOID CCircleImageUI::GetInterface(LPCTSTR pstrName) 27 | { 28 | if (_tcscmp(pstrName, _T("CircleImage")) == 0) return static_cast(this); 29 | return CLabelUI::GetInterface(pstrName); 30 | } 31 | 32 | void CCircleImageUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) 33 | { 34 | if( _tcsicmp(pstrName, _T("imagepath")) == 0 ) { 35 | TImageInfo * pInfo = CRenderEngine::LoadImage(pstrValue); 36 | if (pInfo) 37 | { 38 | 39 | if (m_pImagePathBitmap) 40 | { 41 | delete m_pImagePathBitmap; 42 | m_pImagePathBitmap = NULL; 43 | } 44 | m_pImagePathBitmap = Gdiplus::Bitmap::FromHBITMAP(pInfo->hBitmap,NULL); 45 | if (pInfo->hBitmap) 46 | { 47 | DeleteObject(pInfo->hBitmap); 48 | } 49 | delete pInfo; 50 | } 51 | Invalidate(); 52 | } 53 | else 54 | CLabelUI::SetAttribute(pstrName, pstrValue); 55 | } 56 | 57 | void CCircleImageUI::PaintBkImage(HDC hDC) 58 | { 59 | CLabelUI::PaintBkImage(hDC); 60 | Gdiplus::Graphics graphics(hDC); 61 | if (m_pImagePathBitmap) 62 | { 63 | Gdiplus::TextureBrush tBrush2(m_pImagePathBitmap); 64 | Gdiplus::REAL cx = (Gdiplus::REAL)(m_rcItem.right - m_rcItem.left); 65 | Gdiplus::REAL cy = (Gdiplus::REAL)(m_rcItem.bottom - m_rcItem.top); 66 | Gdiplus::RectF rc((Gdiplus::REAL)m_rcItem.left, (Gdiplus::REAL)m_rcItem.top, cx, cy); 67 | graphics.SetClip(rc); 68 | tBrush2.SetWrapMode(Gdiplus::WrapModeTile); 69 | graphics.SetSmoothingMode(Gdiplus::SmoothingMode::SmoothingModeAntiAlias); 70 | tBrush2.TranslateTransform(rc.GetLeft(), rc.GetTop()); 71 | tBrush2.ScaleTransform(cx / m_pImagePathBitmap->GetWidth(), cy / m_pImagePathBitmap->GetHeight()); 72 | graphics.FillEllipse(&tBrush2, rc); 73 | } 74 | } -------------------------------------------------------------------------------- /CircleImageUI.h: -------------------------------------------------------------------------------- 1 | #ifndef __CircleImage_H__ 2 | #define __CircleImage_H__ 3 | #pragma once 4 | 5 | class CCircleImageUI : public CLabelUI 6 | { 7 | public: 8 | CCircleImageUI(); 9 | ~CCircleImageUI(); 10 | 11 | LPCTSTR GetClass() const; 12 | LPVOID GetInterface(LPCTSTR pstrName); 13 | 14 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 15 | void PaintBkImage(HDC hDC); 16 | 17 | protected: 18 | CDuiString m_sImagePath; 19 | Gdiplus::Bitmap* m_pImagePathBitmap; 20 | }; 21 | 22 | #endif // __CircleImage_H__ 23 | -------------------------------------------------------------------------------- /ClassLive.cpp: -------------------------------------------------------------------------------- 1 | // Rocket.cpp : 定义应用程序的入口点。 2 | // 3 | // 4 | //#include "stdafx.h" 5 | //#include "Rocket.h" 6 | //#include "loginWindow.h" 7 | // 8 | //#define MAX_LOADSTRING 100 9 | // 10 | //// 全局变量: 11 | //HINSTANCE hInst; // 当前实例 12 | //WCHAR szTitle[MAX_LOADSTRING]; // 标题栏文本 13 | //WCHAR szWindowClass[MAX_LOADSTRING]; // 主窗口类名 14 | // 15 | //int APIENTRY wWinMain(_In_ HINSTANCE hInstance, 16 | // _In_opt_ HINSTANCE hPrevInstance, 17 | // _In_ LPWSTR lpCmdLine, 18 | // _In_ int nCmdShow) 19 | //{ 20 | // UNREFERENCED_PARAMETER(hPrevInstance); 21 | // UNREFERENCED_PARAMETER(lpCmdLine); 22 | // 23 | // // TODO: 在此处放置代码。 24 | // 25 | // //add code 26 | // CPaintManagerUI::SetInstance(hInstance); 27 | // 28 | // CPaintManagerUI::SetDefLang(L"zh_cn"); 29 | // 30 | // CLoginWindow LoginWindow; 31 | // { 32 | // DWORD dwStyle = WS_VISIBLE | WS_THICKFRAME; 33 | // LoginWindow.Create(NULL, L"", dwStyle, 0L); 34 | // 35 | // LoginWindow.ShowWindow(true); 36 | // LoginWindow.CenterWindow(); 37 | // } 38 | // 39 | // 40 | // 41 | // int nRet = 0; 42 | // MSG msg = { 0 }; 43 | // while ((nRet = ::GetMessage(&msg, NULL, 0, 0)) >= 0) { 44 | // 45 | // if (!CPaintManagerUI::TranslateMessage(&msg)) { 46 | // ::TranslateMessage(&msg); 47 | // ::DispatchMessage(&msg); 48 | // } 49 | // } 50 | // return 0; 51 | // 52 | //} 53 | // 54 | 55 | 56 | #include "stdafx.h" 57 | #include "Rocket.h" 58 | 59 | #include "SACModule.h" 60 | #include 61 | 62 | CAppModule _Module; 63 | CSACModule g_SACMoudleApp; 64 | 65 | #define SAC_MUTEX_STRING L"{F5503400-290A-40C7-A9EF-F08F8FC37D8A}" 66 | 67 | eProcessType GetProcessType(LPCWSTR lpwsCmdLine) 68 | { 69 | eProcessType eType = eBrowserProcess; 70 | CCommandParse cmd; 71 | cmd.Parse(GetCommandLine()); 72 | CCommand* pCmd = cmd.FindCommand(L"-type"); 73 | if (NULL == pCmd) 74 | { 75 | eType = eBrowserProcess; 76 | } 77 | else 78 | { 79 | LPCWSTR pwsType = pCmd->GetArg(0); 80 | if (StrCmpI(pwsType, L"renderer") == 0) 81 | { 82 | eType = eRendererProcess; 83 | } 84 | else 85 | { 86 | eType = eOtherProcess; 87 | } 88 | } 89 | return eType; 90 | } 91 | 92 | #define MAIN_MUTEX_NAMEL L"D0632876-F7F3-4410-804A-D53C8BFDDA5F" 93 | HANDLE hSACMutex = NULL; 94 | int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstrCmdLine, int nCmdShow) 95 | { 96 | eProcessType eType = GetProcessType(GetCommandLine()); 97 | if (eType == eBrowserProcess) 98 | { 99 | //if (lstrlen(lpCmdLine) > 0) 100 | { 101 | hSACMutex = ::CreateMutexW(NULL, FALSE, MUTEX_SAC_STRING); 102 | if (GetLastError() == ERROR_ALREADY_EXISTS) 103 | { 104 | #ifndef DEBUG 105 | return 0; 106 | #endif // DEBUG 107 | 108 | } 109 | } 110 | 111 | HRESULT hRes = OleInitialize(NULL); 112 | ATLASSERT(SUCCEEDED(hRes)); 113 | ::DefWindowProc(NULL, 0, 0, 0L); 114 | 115 | AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls 116 | srand(GetTickCount()); 117 | hRes = _Module.Init(NULL, hInstance); 118 | ATLASSERT(SUCCEEDED(hRes)); 119 | AtlAxWinInit(); 120 | } 121 | 122 | HRESULT hRes = OleInitialize(NULL); 123 | ATLASSERT(SUCCEEDED(hRes)); 124 | ::DefWindowProc(NULL, 0, 0, 0L); 125 | 126 | AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls 127 | srand(GetTickCount()); 128 | hRes = _Module.Init(NULL, hInstance); 129 | ATLASSERT(SUCCEEDED(hRes)); 130 | AtlAxWinInit(); 131 | 132 | g_SACMoudleApp.Init(eType); 133 | 134 | CComPtr spCefMgr; 135 | HMODULE hMoudle = g_SACMoudleApp.GetCefModuleHandle(); 136 | DllCreateObject(hMoudle, CLSID_CefManager, &spCefMgr); 137 | if (!spCefMgr) 138 | { 139 | ::MessageBox(NULL, L"LoadCEF3MoudleFailed!!!", NULL, MB_OK); 140 | } 141 | else 142 | { 143 | spCefMgr->Init(hInstance, NULL); 144 | 145 | if (eBrowserProcess == eType) 146 | { 147 | g_SACMoudleApp.SetCefInstance(spCefMgr); 148 | CCefWndWrapManager::Init(); 149 | int nRet = g_SACMoudleApp.DUIMain(hInstance, lpstrCmdLine, nCmdShow); 150 | CCefWndWrapManager::UnInit(); 151 | CloseHandle(hSACMutex); 152 | hSACMutex = NULL; 153 | } 154 | spCefMgr->Shutdown(); 155 | } 156 | 157 | //声网SDK也有卡死过,加上强杀保险一点, 158 | TerminateProcess(GetCurrentProcess(), 0); 159 | 160 | if (eBrowserProcess == eType) 161 | { 162 | g_SACMoudleApp.Uninit(); 163 | CloseHandle(hSACMutex); 164 | hSACMutex = NULL; 165 | _Module.Term(); 166 | OleUninitialize(); 167 | } 168 | 169 | //TerminateProcess(GetCurrentProcess(), 0); 170 | 171 | return 0; 172 | } -------------------------------------------------------------------------------- /DBClickLabelUI.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "DBClickLabelUI.h" 3 | 4 | #include 5 | 6 | CDBClickLabelUI::CDBClickLabelUI() 7 | { 8 | 9 | } 10 | 11 | CDBClickLabelUI::~CDBClickLabelUI() 12 | { 13 | 14 | } 15 | LPCTSTR CDBClickLabelUI::GetClass() const 16 | { 17 | return _T("DBClickLabelUI"); 18 | } 19 | 20 | LPVOID CDBClickLabelUI::GetInterface(LPCTSTR pstrName) 21 | { 22 | if (_tcscmp(pstrName, L"DBClickLabelUI") == 0) return static_cast(this); 23 | return CLabelUI::GetInterface(pstrName); 24 | } 25 | 26 | void CDBClickLabelUI::DoEvent(TEventUI& event) 27 | { 28 | if (!IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND) { 29 | if (m_pParent != NULL) m_pParent->DoEvent(event); 30 | else CLabelUI::DoEvent(event); 31 | return; 32 | } 33 | 34 | if (event.Type == UIEVENT_DBLCLICK && IsEnabled()) { 35 | if (m_pManager != NULL) 36 | { 37 | m_pManager->SendNotify(this, DUI_MSGTYPE_DBCLICK); 38 | } 39 | } 40 | CLabelUI::DoEvent(event); 41 | } 42 | -------------------------------------------------------------------------------- /DBClickLabelUI.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CDBClickLabelUI : public CLabelUI 4 | { 5 | public: 6 | CDBClickLabelUI(); 7 | ~CDBClickLabelUI(); 8 | 9 | LPCTSTR GetClass() const; 10 | LPVOID GetInterface(LPCTSTR pstrName); 11 | 12 | void DoEvent(TEventUI& event); 13 | 14 | }; 15 | 16 | -------------------------------------------------------------------------------- /HelpWebWindow.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/HelpWebWindow.cpp -------------------------------------------------------------------------------- /HelpWebWindow.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/HelpWebWindow.h -------------------------------------------------------------------------------- /Include/ByteFreqChecker.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/Include/ByteFreqChecker.h -------------------------------------------------------------------------------- /Include/Common.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "stringHelper.h" 4 | #include "PathHelper.h" 5 | #include "fileHelper.h" 6 | 7 | #include "../../../baseclass/MD5.h" 8 | 9 | #include "IMDataDef.h" 10 | 11 | #define MAKEINT64(a, b) \ 12 | ((((__int64)(a) & 0xFFFFFFFF)) | (((__int64)(b) << 32) & 0xFFFFFFFF00000000)) 13 | #define LOINT64(i64) \ 14 | ((int)(i64)) 15 | #define HIINT64(i64) \ 16 | ((int)((__int64)(i64) >> 32)) 17 | 18 | -------------------------------------------------------------------------------- /Include/CommonMsgDef.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/Include/CommonMsgDef.h -------------------------------------------------------------------------------- /Include/DDBUtil.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | 5 | struct CDDBUtil 6 | { 7 | static HBITMAP CreateDDBFromDC(HDC hDC, int nX, int nY, int nWidth, int nHeight) 8 | { 9 | if (NULL == hDC) 10 | return NULL; 11 | HDC hBmpDC = ::CreateCompatibleDC(hDC); 12 | if (NULL == hBmpDC) 13 | return NULL; 14 | HBITMAP hBitmap = ::CreateCompatibleBitmap(hDC, nWidth, nHeight); 15 | if (NULL == hBitmap) 16 | { 17 | ::DeleteDC(hBmpDC); 18 | return NULL; 19 | } 20 | HBITMAP hOldBmp = (HBITMAP)::SelectObject(hBmpDC, hBitmap); 21 | ::BitBlt(hBmpDC, 0, 0, nWidth, nHeight, hDC, nX, nY, SRCCOPY); 22 | ::SelectObject(hBmpDC, hOldBmp); 23 | ::DeleteDC(hBmpDC); 24 | return hBitmap; 25 | } 26 | 27 | static HBITMAP CreateDDBFromDC(HDC hDC, int nX, int nY, int nWidth, int nHeight 28 | , int nDstWidth, int nDstHeight) 29 | { 30 | if (NULL == hDC) 31 | return NULL; 32 | HDC hBmpDC = ::CreateCompatibleDC(hDC); 33 | if (NULL == hBmpDC) 34 | return NULL; 35 | HBITMAP hBitmap = ::CreateCompatibleBitmap(hDC, nDstWidth, nDstHeight); 36 | if (NULL == hBitmap) 37 | { 38 | ::DeleteDC(hBmpDC); 39 | return NULL; 40 | } 41 | HBITMAP hOldBmp = (HBITMAP)::SelectObject(hBmpDC, hBitmap); 42 | ::SetStretchBltMode(hBmpDC, STRETCH_HALFTONE); 43 | ::StretchBlt(hBmpDC, 0, 0, nDstWidth, nDstHeight, hDC, nX, nY 44 | , nWidth, nHeight, SRCCOPY); 45 | ::SelectObject(hBmpDC, hOldBmp); 46 | ::DeleteDC(hBmpDC); 47 | return hBitmap; 48 | } 49 | 50 | static bool CopyDDBToDC(HDC hDC, int nX, int nY, int nWidth, int nHeight 51 | , HBITMAP hBitmap, int nSrcX, int nSrcY) 52 | { 53 | if (NULL == hDC || NULL == hBitmap) 54 | return false; 55 | HDC hBmpDC = ::CreateCompatibleDC(hDC); 56 | if (NULL == hBmpDC) 57 | return false; 58 | HBITMAP hOldBmp = (HBITMAP)::SelectObject(hBmpDC, hBitmap); 59 | ::BitBlt(hDC, nX, nY, nWidth, nHeight, hBmpDC, nSrcX, nSrcY, SRCCOPY); 60 | ::SelectObject(hBmpDC, hOldBmp); 61 | ::DeleteDC(hBmpDC); 62 | return true; 63 | } 64 | 65 | static HBITMAP CopyDDB(HBITMAP hBitmap, HWND hRefWnd = ::GetDesktopWindow()) 66 | { 67 | if (NULL == hBitmap) 68 | return NULL; 69 | 70 | BITMAP bmp = {0}; 71 | ::GetObject(hBitmap, sizeof(bmp), &bmp); 72 | HDC hRefDC = ::GetDC(hRefWnd); 73 | HDC hBmpDC = ::CreateCompatibleDC(hRefDC); 74 | HDC hBmpDC2 = ::CreateCompatibleDC(hRefDC); 75 | HBITMAP hBitmap2 = ::CreateCompatibleBitmap(hRefDC, bmp.bmWidth, bmp.bmHeight); 76 | HBITMAP hOldBmp = (HBITMAP)::SelectObject(hBmpDC, hBitmap); 77 | HBITMAP hOldBmp2 = (HBITMAP)::SelectObject(hBmpDC2, hBitmap2); 78 | ::BitBlt(hBmpDC2, 0, 0, bmp.bmWidth, bmp.bmHeight, hBmpDC, 0, 0, SRCCOPY); 79 | ::SelectObject(hBmpDC, hOldBmp); 80 | ::SelectObject(hBmpDC2, hOldBmp2); 81 | ::ReleaseDC(hRefWnd, hRefDC); 82 | ::DeleteObject(hBmpDC); 83 | ::DeleteObject(hBmpDC2); 84 | return hBitmap2; 85 | } 86 | 87 | static bool SaveHBitmapToFile(HBITMAP hBitmap, LPCWSTR lpstrFile) 88 | { 89 | return false; 90 | // if (NULL == hBitmap || NULL == lpstrFile) 91 | // return false; 92 | // NS_FILE_HELPER::InsureDirExists(lpstrFile); 93 | // CImage img; 94 | // img.Attach(hBitmap); 95 | // HRESULT hR = img.Save(lpstrFile); 96 | // img.Detach(); 97 | // return SUCCEEDED(hR); 98 | } 99 | }; -------------------------------------------------------------------------------- /Include/FontMgr.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/Include/FontMgr.h -------------------------------------------------------------------------------- /Include/IMDataDef.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/Include/IMDataDef.h -------------------------------------------------------------------------------- /Include/SendUserDataType.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | /* 3 | /* 音视频定义头文件 4 | /* 5 | /************************************************************************/ 6 | #pragma once 7 | 8 | enum SendUserDataType 9 | { 10 | SendUserDataType_MAGIC=1, 11 | SendUserDataType_AUDIO=2, 12 | SendUserDataType_VIDEO=3, 13 | SendUserDataType_BEAN=4, 14 | SendUserDataType_DING=5, 15 | 16 | SendUserDataType_B2S_STU_Show=10, 17 | SendUserDataType_B2S_STU_Close=11, 18 | SendUserDataType_B2S_STU_Show_Other=12, 19 | 20 | SendUserDataType_AddClass=20, 21 | SendUserDataType_AddClass_Accept=21, 22 | 23 | SendUserDataType_ClassFix_Info = 33, 24 | SendUserDataType_ClassFix_Remote = 34, 25 | 26 | SendUserDataType_SWITCHAUDIO = 40, 27 | 28 | SendUserDataType_ChangePDF = 51, 29 | SendUserDataType_SyncCanvas = 52, 30 | SendUserDataType_ChangeInteract = 53, 31 | SendUserDataType_RemoteUserSDKSwitched = 54, 32 | 33 | //换教材通知 34 | SendStuChangeBookComplete=80, 35 | SendTeaChangeBookComplete=81, 36 | 37 | //上墙通知 38 | SendVideoOnWall=90, 39 | //下墙通知 40 | SendVideoOffWall=91, 41 | //自己录屏失败,通知对方录屏 42 | SendSnapShot=100, 43 | 44 | //1v1视频放大还原 45 | SendUserDataType_1V1ideoZoomIn = 110, 46 | SendUserDataType_1V1VideoZoomOut = 111, 47 | 48 | //1v1白板魔法表情 49 | SendUserDataType_1V1WBMagic_Play = 120, 50 | SendUserDataType_1V1WBMagic_Stop = 121, 51 | SendUserDataType_1V1WBMagic_Close = 122, 52 | SendUserDataType_1V1WBMagic_DownloadComplete = 123, 53 | 54 | //Demo 音频控制 55 | 56 | SendUserDataType_Demo_Audio_mute = 130, 57 | SenduserDataType_Demo_Audio_unmute = 131 58 | }; 59 | -------------------------------------------------------------------------------- /Include/StarDataDef.h: -------------------------------------------------------------------------------- 1 | #ifndef __STAR_DATA_DEF_H__ 2 | #define __STAR_DATA_DEF_H__ 3 | #pragma once 4 | 5 | #include 6 | #include 7 | 8 | 9 | enum EStarType 10 | { 11 | EST_PERSON = 0, 12 | EST_GROUP, 13 | // EST_CLASS, 14 | EST_B2S, 15 | }; 16 | 17 | struct StarInfo { 18 | StarInfo() : id(0), count(0) {}; 19 | 20 | ULONGLONG id; 21 | CString name; 22 | UINT32 count; 23 | }; 24 | 25 | struct GroupStarInfo 26 | { 27 | StarInfo info; 28 | std::list subs; 29 | }; 30 | 31 | struct IStarData 32 | { 33 | virtual void GetAllStarData(std::list& groupDatas, std::list& userDatas) const = 0; 34 | virtual CString FormatJsonString() const = 0; 35 | }; 36 | 37 | #endif -------------------------------------------------------------------------------- /Include/UICommonDef.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define WHITEBOARD_MSG_BASE (WM_USER + 1986) 4 | #define MSG_SHAPEEIDT (WHITEBOARD_MSG_BASE + 1) 5 | #define MSG_FONTHEIGHT_CHANGED (WHITEBOARD_MSG_BASE + 2) 6 | #define MSG_TEXTCOLOR_CHANGED (WHITEBOARD_MSG_BASE + 3) 7 | #define MSG_TOOLBARWND_FTRIGGER (WHITEBOARD_MSG_BASE + 4) 8 | #define MSG_SEL_COLOR (WHITEBOARD_MSG_BASE + 11) 9 | 10 | #define TOOLBARWND_CLASSNAME L"$ciba_screencapture_toolbar_window$" 11 | 12 | // toolbar window 13 | #define DISP_SELCOLOR_POS_L 116 14 | #define DISP_SELCOLOR_POS_T 47 15 | #define DISP_SELCOLOR_POS_R 140 16 | #define DISP_SELCOLOR_POS_B 71 17 | #define FIRST_COLORCELL_L 145 18 | #define FIRST_COLORCELL_T 44 19 | #define COLORCELL_WIDTH 15 20 | #define COLORCELL_HEIGHT 15 21 | #define COLORCELL_INNERBORDER_COLOR (RGB(255, 255, 255)) 22 | #define COLORCELL_OUTERBORDER_COLOR (RGB(37, 117, 188)) 23 | #define TOOLBARWND_BGCOLOR (RGB(242, 242, 242)) 24 | 25 | // graphic 26 | #define SHAPE_DEF_COLOR (RGB(255, 0, 0)) 27 | #define TEXT_DEF_COLOR SHAPE_DEF_COLOR 28 | #define TEXT_DEF_FONTNAME L"Arial" 29 | #define TEXT_DEF_FONT_HEIGHT 18 30 | #define TEXT_CTRL_DEF_WIDTH 60 31 | #define TEXT_CTRL_TEXT_EX_WIDTH 20 32 | struct PenWidth{enum{ 33 | Thin = 1, 34 | Medium = 3, 35 | Bold = 5};}; -------------------------------------------------------------------------------- /Include/URLDetector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | using namespace std; 5 | //#include "../CommonUtil/Common.h" 6 | 7 | #define COURSE_URL_KEYWORD L"chuanke.com/" 8 | #define COURSE_URL_KEYWORD_LEN 12 9 | 10 | struct URLType {enum { 11 | Common = 0, 12 | Course = 1, 13 | VideoCus = 2, 14 | SeriesCus = 3 15 | };}; 16 | 17 | struct URLCssType {enum { 18 | Chat = 0, 19 | ClassChat = 1 20 | };}; 21 | 22 | struct URLItem 23 | { 24 | UINT m_uType; 25 | UINT m_uCssType; 26 | UINT64 m_iSID; 27 | UINT64 m_iCID; 28 | UINT64 m_iTerm; 29 | CString m_strURL; 30 | wstring m_wstrGUID; 31 | 32 | URLItem() : m_uType(URLType::Common), m_uCssType(URLCssType::Chat) 33 | , m_iSID(0), m_iCID(0), m_iTerm(0) {} 34 | URLItem(LPCWSTR lpstrURL) 35 | { 36 | m_uType = URLType::Common; 37 | m_uCssType = URLCssType::Chat; 38 | m_iSID = 0; 39 | m_iCID = 0; 40 | m_iTerm = 0; 41 | if (NULL != lpstrURL) 42 | m_strURL = lpstrURL; 43 | } 44 | //operator LPCWSTR () {return m_strURL;} 45 | //operator CString& (){return m_strURL;} 46 | bool IsTokenURL() {return (URLType::Common != m_uType);} 47 | bool IsCourseURL() {return (URLType::Common != m_uType);} 48 | }; 49 | 50 | 51 | struct CURLDetector 52 | { 53 | static void PeekURL(IN const CString& strText, OUT list>& lstPair) 54 | { 55 | PeekURL1(strText, lstPair); 56 | PeekURL2(lstPair, L"www."); 57 | // detect url type 58 | list>::iterator iter = lstPair.begin(); 59 | for (; iter != lstPair.end(); ++iter) 60 | { 61 | if (iter->first) 62 | DetectURLType(iter->second); 63 | } 64 | } 65 | 66 | static void PeekURL1(IN const CString& strText, OUT list>& lstPair) 67 | { 68 | static std::vector s_arrayProtocol; 69 | if (true == s_arrayProtocol.empty()) 70 | { 71 | s_arrayProtocol.push_back(L"https"); 72 | s_arrayProtocol.push_back(L"http"); 73 | s_arrayProtocol.push_back(L"ftp"); 74 | } 75 | 76 | int nTotalLen = strText.GetLength(); 77 | int nB = -1, nE = -1, nLastPos = 0; 78 | while (true) 79 | { 80 | nB = strText.Find(L"://", nLastPos); 81 | if (-1 == nB) 82 | break; 83 | int nProtoPos = -1; 84 | for (size_t i = 0; i < s_arrayProtocol.size(); ++i) 85 | { 86 | CString& strItem = s_arrayProtocol.at(i); 87 | int nItemLen = strItem.GetLength(); 88 | if (nB - nItemLen < 0) 89 | continue; 90 | if (strText.Mid(nB - nItemLen, nItemLen) == strItem) 91 | { 92 | nProtoPos = nB - nItemLen; 93 | break; 94 | } 95 | } 96 | 97 | if (-1 != nProtoPos) 98 | { 99 | nE = nB + 3; 100 | while (nE < nTotalLen) 101 | { 102 | if (IsValidURLChar(strText[nE])) 103 | ++nE; 104 | else 105 | break; 106 | } 107 | lstPair.push_back(make_pair(false, URLItem(strText.Mid(nLastPos, nProtoPos - nLastPos)))); 108 | // url here 109 | lstPair.push_back(make_pair(true, URLItem(strText.Mid(nProtoPos, nE - nProtoPos)))); 110 | nLastPos = nE; 111 | } 112 | else 113 | { 114 | lstPair.push_back(make_pair(false, URLItem(strText.Mid(nLastPos, nB + 3 - nLastPos)))); 115 | nLastPos = nB + 3; 116 | } 117 | } 118 | if ((-1 != nLastPos) && (nLastPos < nTotalLen)) 119 | lstPair.push_back(make_pair(false, URLItem(strText.Mid(nLastPos)))); 120 | } 121 | 122 | static void PeekURL2(IN OUT list>& lstPair, IN LPCWSTR lpstrURLKey) 123 | { 124 | if (NULL == lpstrURLKey) 125 | return; 126 | int nURLKeyLen = ::wcslen(lpstrURLKey); 127 | if (nURLKeyLen <= 0) 128 | return; 129 | 130 | list>::iterator iter = lstPair.begin(); 131 | for (; iter != lstPair.end(); ) 132 | { 133 | if (iter->first || iter->second.m_strURL.IsEmpty()) 134 | { 135 | ++iter; 136 | continue; 137 | } 138 | 139 | list>::iterator nextIter = iter; 140 | ++nextIter; 141 | list> pairList2; 142 | PeekURL2(iter->second.m_strURL, lpstrURLKey, nURLKeyLen, pairList2); 143 | if (!pairList2.empty()) 144 | { 145 | list>::iterator iter2 = pairList2.begin(); 146 | for (; iter2 != pairList2.end(); ++iter2) 147 | lstPair.insert(iter, *iter2); 148 | lstPair.erase(iter); 149 | } 150 | iter = nextIter; 151 | } 152 | } 153 | 154 | static void PeekURL2(IN const CString& strText, IN LPCWSTR lpstrURLKey, IN int nURLKeyLen 155 | , OUT list>& lstPair) 156 | { 157 | CString strTextLower = strText; 158 | strTextLower.MakeLower(); 159 | int nTotalLen = strText.GetLength(); 160 | int nB = -1, nE = -1, nLastPos = 0; 161 | while (true) 162 | { 163 | nB = strTextLower.Find(lpstrURLKey, nLastPos); 164 | if (-1 == nB) 165 | break; 166 | nE = nB + nURLKeyLen; 167 | while (nE < nTotalLen) 168 | { 169 | if (IsValidURLChar(strText[nE])) 170 | ++nE; 171 | else 172 | break; 173 | } 174 | int nLen = nB - nLastPos; 175 | if (nLen > 0) 176 | lstPair.push_back(make_pair(false, URLItem(strText.Mid(nLastPos, nLen)))); 177 | // url here 178 | lstPair.push_back(make_pair(true, URLItem(strText.Mid(nB, nE - nB)))); 179 | nLastPos = nE; 180 | } 181 | if ((-1 != nLastPos) && (nLastPos < nTotalLen)) 182 | lstPair.push_back(make_pair(false, URLItem(strText.Mid(nLastPos)))); 183 | } 184 | 185 | inline static bool IsValidURLChar(wchar_t ch) 186 | { 187 | if ((ch >= 0x21 && ch <= 0x5a) 188 | || (ch == L'\\') 189 | || (ch >= 0x5e && ch <= 0x7a)) 190 | return true; 191 | return false; 192 | } 193 | 194 | //#define COURSE_URL_KEYWORD L"www.chuanke.com/" 195 | //#define COURSE_URL_KEYWORD_LEN 16 196 | //Course : http://www.chuanke.com/{$sid}-{$courseid}.html 197 | //直播课程: http://www.chuanke.com/s{$sid}-{$cid}.html 198 | // http://www.chuanke.com/s{$sid}-{$cid}-{$ts}.html 199 | //视频课程: http://www.chuanke.com/v{$cid}.html 200 | //系列课程:http://www.chuanke.com/zhuanji-2-{$cid}-{$page}.html 201 | static void DetectURLType(URLItem& ui) 202 | { 203 | if (ui.m_strURL.IsEmpty()) 204 | return; 205 | CString strTmp = ui.m_strURL; 206 | strTmp.MakeLower(); 207 | int nPos = strTmp.Find(COURSE_URL_KEYWORD); 208 | if (-1 == nPos) 209 | return; 210 | LPCWSTR lpstr = strTmp; 211 | lpstr += (nPos + COURSE_URL_KEYWORD_LEN); 212 | // course 213 | ui.m_iSID = ui.m_iCID = 0; 214 | swscanf_s(lpstr, L"%I64d-%I64d-%I64d", &ui.m_iSID, &ui.m_iCID, &ui.m_iTerm); 215 | if ((0 != ui.m_iSID) && (0 != ui.m_iCID)) 216 | { 217 | ui.m_uType = URLType::Course; 218 | NS_COMMON::GenerateGUID(ui.m_wstrGUID); 219 | return; 220 | } 221 | /// 222 | return; 223 | /// 224 | // video course 225 | ui.m_iCID = 0; 226 | swscanf_s(lpstr, L"v%I64d.", &ui.m_iCID); 227 | if (0 != ui.m_iCID) 228 | { 229 | ui.m_uType = URLType::VideoCus; 230 | NS_COMMON::GenerateGUID(ui.m_wstrGUID); 231 | return; 232 | } 233 | // series course 234 | ui.m_iCID = 0; 235 | swscanf_s(lpstr, L"zhuanji-2-%I64d-%I64d", &ui.m_iCID, &ui.m_iTerm); 236 | if (0 != ui.m_iCID) 237 | { 238 | ui.m_uType = URLType::SeriesCus; 239 | NS_COMMON::GenerateGUID(ui.m_wstrGUID); 240 | return; 241 | } 242 | } 243 | }; 244 | -------------------------------------------------------------------------------- /Include/XDictIMRTFParser.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | using namespace std; 5 | #include "clipboard.h" 6 | 7 | #define IMG_PREFIX_A "[Image:{" 8 | #define IMG_POSTFIX_A "}]" 9 | 10 | struct CXDictIMRTFItem 11 | { 12 | enum 13 | { 14 | Unknown = 0x00, 15 | Text = 0x01, 16 | Emote = 0x02, 17 | Image = 0x04 18 | }; 19 | 20 | UINT m_uType; 21 | int m_nEmoteID; 22 | CString m_strText; 23 | CString m_strImgMD5; 24 | 25 | CXDictIMRTFItem(UINT uType, int nEmoteID) : m_uType(uType), m_nEmoteID(nEmoteID) {} 26 | CXDictIMRTFItem(UINT uType, const wchar_t* pText) : m_uType(uType) {if (NULL != pText) m_strText = pText;} 27 | CXDictIMRTFItem(UINT uType, const wchar_t* pText, const wchar_t* pImgMD5) : m_uType(uType) 28 | { 29 | if (NULL != pText) m_strText = pText; 30 | if (NULL != pImgMD5) m_strImgMD5 = pImgMD5; 31 | } 32 | }; 33 | 34 | typedef list rtfitem_list; 35 | typedef rtfitem_list::iterator rtf_iterator; 36 | 37 | 38 | struct CXDictIMRTFParser 39 | { 40 | inline static UINT GetXDictIMRTFID() 41 | { 42 | static UINT s_uXDictIMRTF = 0; 43 | if (0 == s_uXDictIMRTF) 44 | s_uXDictIMRTF = CClipboard::RegisterClipboardFormat(L"CHUANKE_RTF"); 45 | return s_uXDictIMRTF; 46 | } 47 | 48 | #define IMG_PREFIX L"[Image:{" 49 | #define IMG_POSTFIX L"}]" 50 | #define EMOTE_PREFIX L"[Emote:{" 51 | #define EMOTE_POSTFIX L"}]" 52 | 53 | static void ParseItem(IN const CString& strText, OUT rtfitem_list& itemList) 54 | { 55 | ParseEmoteItem(strText, itemList); 56 | rtf_iterator iter = itemList.begin(); 57 | for (; iter != itemList.end(); ) 58 | { 59 | if (CXDictIMRTFItem::Emote == iter->m_uType || iter->m_strText.IsEmpty()) 60 | { 61 | ++iter; 62 | continue; 63 | } 64 | 65 | rtf_iterator nextIter = iter; 66 | ++nextIter; 67 | rtfitem_list itemList2; 68 | ParseImageItem(iter->m_strText, itemList2); 69 | if (!itemList2.empty()) 70 | { 71 | //rtf_iterator iter2 = itemList2.begin(); 72 | //for (; iter2 != itemList2.end(); ++iter2) 73 | // itemList.insert(iter, *iter2); 74 | itemList.insert(iter, itemList2.begin(), itemList2.end()); 75 | itemList.erase(iter); 76 | } 77 | iter = nextIter; 78 | } 79 | } 80 | 81 | static void ParseEmoteItem(IN const CString& strText, OUT rtfitem_list& itemList) 82 | { 83 | CString strItem; 84 | int nB = -1, nE = -1, nLast = 0; 85 | while (true) 86 | { 87 | nB = strText.Find(EMOTE_PREFIX, nLast); 88 | if (-1 == nB) 89 | break; 90 | nE = strText.Find(EMOTE_POSTFIX, nB); 91 | if (-1 == nE) 92 | break; 93 | if (nE - nB < 9) 94 | break; 95 | int nLen = nB - nLast; 96 | if (nLen > 0) 97 | { 98 | strItem = strText.Mid(nLast, nLen); 99 | itemList.push_back(CXDictIMRTFItem(CXDictIMRTFItem::Text, strItem)); 100 | } 101 | strItem = strText.Mid(nB + 8, nE - nB - 8); 102 | itemList.push_back(CXDictIMRTFItem(CXDictIMRTFItem::Emote, ::_wtoi(strItem))); 103 | nLast = nE + 2; 104 | } 105 | 106 | if (nLast < strText.GetLength()) 107 | { 108 | strItem = strText.Mid(nLast); 109 | itemList.push_back(CXDictIMRTFItem(CXDictIMRTFItem::Text, strItem)); 110 | } 111 | } 112 | 113 | static void ParseImageItem(IN const CString& strText, OUT rtfitem_list& itemList) 114 | { 115 | CString strItem, strImgMD5; 116 | int nB = -1, nE = -1, nLast = 0; 117 | while (true) 118 | { 119 | nB = strText.Find(IMG_PREFIX, nLast); 120 | if (-1 == nB) 121 | break; 122 | nE = strText.Find(IMG_POSTFIX, nB); 123 | if (-1 == nE) 124 | break; 125 | if (nE - nB < 41) 126 | break; 127 | int nLen = nB - nLast; 128 | if (nLen > 0) 129 | { 130 | strItem = strText.Mid(nLast, nLen); 131 | itemList.push_back(CXDictIMRTFItem(CXDictIMRTFItem::Text, strItem)); 132 | } 133 | if (strText[nB + 40] == L'.') 134 | { 135 | strImgMD5 = strText.Mid(nB + 8, 32); 136 | strItem = strText.Mid(nB + 8, nE - nB - 8); 137 | nLast = nE + 2; 138 | itemList.push_back(CXDictIMRTFItem(CXDictIMRTFItem::Image, strItem, strImgMD5)); 139 | } 140 | else 141 | { 142 | nLast = nB + 8; 143 | strItem = strText.Mid(nB, 8); 144 | itemList.push_back(CXDictIMRTFItem(CXDictIMRTFItem::Text, strItem)); 145 | } 146 | } 147 | 148 | if (nLast < strText.GetLength()) 149 | { 150 | strItem = strText.Mid(nLast); 151 | itemList.push_back(CXDictIMRTFItem(CXDictIMRTFItem::Text, strItem)); 152 | } 153 | } 154 | }; -------------------------------------------------------------------------------- /Include/clipboard.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | /* 3 | /* Operate the Clipboard 4 | /* 5 | /************************************************************************/ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "../../../baseclass/StringHelper.h" 13 | 14 | 15 | class CClipboard 16 | { 17 | #define assert_false_return_false \ 18 | {assert(false); return false;} 19 | 20 | public: 21 | static bool GetTextFromClipboard(wstring& wstrText, HWND hOwnerWnd = ::GetDesktopWindow()) 22 | { 23 | if (FALSE == ::IsClipboardFormatAvailable(CF_UNICODETEXT)) 24 | return false; 25 | if (FALSE == ::OpenClipboard(hOwnerWnd)) 26 | assert_false_return_false 27 | HGLOBAL hGlobal = ::GetClipboardData(CF_UNICODETEXT); 28 | if (NULL == hGlobal) 29 | goto exit_f1; 30 | LPVOID pGlobal = ::GlobalLock(hGlobal); 31 | if (NULL == pGlobal) 32 | goto exit_f2; 33 | size_t siLen = ::GlobalSize(hGlobal); 34 | #define STACK_BUF_SIZE 1024 35 | if (siLen <= STACK_BUF_SIZE - 2) 36 | { 37 | BYTE szBuf[STACK_BUF_SIZE]; 38 | ::memcpy(szBuf, pGlobal, siLen); 39 | szBuf[siLen] = szBuf[siLen + 1] = '\0'; 40 | wstrText = (wchar_t*)szBuf; 41 | } 42 | else 43 | { 44 | LPBYTE pBuf = (LPBYTE)malloc(siLen + 2); 45 | if (NULL != pBuf) 46 | { 47 | ::memcpy(pBuf, pGlobal, siLen); 48 | pBuf[siLen] = pBuf[siLen + 1] = '\0'; 49 | wstrText = (wchar_t*)pBuf; 50 | free(pBuf); 51 | pBuf = NULL; 52 | } 53 | } 54 | ::GlobalUnlock(hGlobal); 55 | ::CloseClipboard(); 56 | return true; 57 | 58 | exit_f2: 59 | ::GlobalUnlock(hGlobal); 60 | exit_f1: 61 | ::CloseClipboard(); 62 | assert_false_return_false 63 | } 64 | 65 | static bool GetTextFromClipboard(string& strText, HWND hOwnerWnd = ::GetDesktopWindow()) 66 | { 67 | wstring wstrText; 68 | if (!GetTextFromClipboard(wstrText, hOwnerWnd)) 69 | return false; 70 | return NS_STRING_HELPER::UnicodeToANSI(wstrText, strText); 71 | } 72 | 73 | inline static bool SetTextToClipboard(const wchar_t* pText, size_t siLen 74 | , bool bClear = true, HWND hOwnerWnd = ::GetDesktopWindow()) 75 | { 76 | if (NULL == pText || siLen <= 0) 77 | assert_false_return_false; 78 | siLen = min(siLen, wcslen(pText)); 79 | return _SetTextToClipboard(pText, siLen, bClear, hOwnerWnd); 80 | } 81 | 82 | inline static bool SetTextToClipboard(const wchar_t* pText 83 | , bool bClear = true, HWND hOwnerWnd = ::GetDesktopWindow()) 84 | { 85 | if (NULL == pText) 86 | assert_false_return_false 87 | return _SetTextToClipboard(pText, wcslen(pText), bClear, hOwnerWnd); 88 | } 89 | 90 | inline static bool SetTextToClipboard(const wstring& wstrText 91 | , bool bClear = true, HWND hOwnerWnd = ::GetDesktopWindow()) 92 | { 93 | if (wstrText.empty()) 94 | assert_false_return_false 95 | return _SetTextToClipboard(wstrText.c_str(), wstrText.length(), bClear, hOwnerWnd); 96 | } 97 | 98 | inline static bool SetTextToClipboard(const char* pText, size_t siLen 99 | , bool bClear = true, HWND hOwnerWnd = ::GetDesktopWindow()) 100 | { 101 | if (NULL == pText || siLen <= 0) 102 | assert_false_return_false 103 | siLen = min(siLen, strlen(pText)); 104 | return _SetTextToClipboard(pText, siLen, bClear, hOwnerWnd); 105 | } 106 | 107 | inline static bool SetTextToClipboard(const char* pText 108 | , bool bClear = true, HWND hOwnerWnd = ::GetDesktopWindow()) 109 | { 110 | if (NULL == pText) 111 | assert_false_return_false 112 | return _SetTextToClipboard(pText, strlen(pText), bClear, hOwnerWnd); 113 | } 114 | 115 | inline static bool SetTextToClipboard(const string& strText 116 | , bool bClear = true, HWND hOwnerWnd = ::GetDesktopWindow()) 117 | { 118 | if (strText.empty()) 119 | assert_false_return_false 120 | return _SetTextToClipboard(strText.c_str(), strText.length(), bClear, hOwnerWnd); 121 | } 122 | 123 | protected: 124 | static bool _SetTextToClipboard(const wchar_t* pText, size_t siLen 125 | , bool bClear = true, HWND hOwnerWnd = ::GetDesktopWindow()) 126 | { 127 | siLen += siLen; 128 | HGLOBAL hGlobal = ::GlobalAlloc(GHND/*(GMEM_MOVEABLE | GMEM_ZEROINIT)*/, siLen + 2); 129 | if (NULL == hGlobal) 130 | assert_false_return_false 131 | LPVOID pGlobal = ::GlobalLock(hGlobal); 132 | if (NULL == pGlobal) 133 | goto exit_f1; 134 | ::memcpy(pGlobal, pText, siLen); 135 | ((BYTE*)pGlobal)[siLen] = '\0'; 136 | ((BYTE*)pGlobal)[siLen + 1] = '\0'; 137 | ::GlobalUnlock(hGlobal); 138 | 139 | if (FALSE == ::OpenClipboard(hOwnerWnd)) 140 | goto exit_f1; 141 | if (bClear) 142 | ::EmptyClipboard(); 143 | ::SetClipboardData(CF_UNICODETEXT, hGlobal); 144 | ::CloseClipboard(); 145 | return true; 146 | 147 | exit_f1: 148 | if (NULL != pGlobal) 149 | ::GlobalFree(hGlobal); 150 | assert_false_return_false 151 | } 152 | 153 | static bool _SetTextToClipboard(const char* pText, size_t siLen 154 | , bool bClear = true, HWND hOwnerWnd = ::GetDesktopWindow()) 155 | { 156 | HGLOBAL hGlobal = ::GlobalAlloc(GHND/*(GMEM_MOVEABLE | GMEM_ZEROINIT)*/, siLen + 1); 157 | if (NULL == hGlobal) 158 | assert_false_return_false 159 | LPVOID pGlobal = ::GlobalLock(hGlobal); 160 | if (NULL == pGlobal) 161 | goto exit_f1; 162 | ::memcpy(pGlobal, pText, siLen); 163 | ((BYTE*)pGlobal)[siLen] = '\0'; 164 | ::GlobalUnlock(hGlobal); 165 | 166 | if (FALSE == ::OpenClipboard(hOwnerWnd)) 167 | goto exit_f1; 168 | if (bClear) 169 | ::EmptyClipboard(); 170 | ::SetClipboardData(CF_TEXT, hGlobal); 171 | ::CloseClipboard(); 172 | return true; 173 | 174 | exit_f1: 175 | if (NULL != pGlobal) 176 | ::GlobalFree(hGlobal); 177 | assert_false_return_false 178 | } 179 | 180 | public: 181 | inline static bool SetDDBToClipboard(HBITMAP& hBitmap 182 | , bool bClear = true, HWND hOwnerWnd = ::GetDesktopWindow()) 183 | { 184 | if (!_SetHandleToClipboard(hBitmap, CF_BITMAP, false, bClear, hOwnerWnd)) 185 | return false; 186 | hBitmap = NULL; 187 | return true; 188 | } 189 | 190 | static bool GetDDBFromClipboard(HBITMAP& hBitmap, HWND hOwnerWnd = ::GetDesktopWindow()) 191 | { 192 | if (FALSE == ::IsClipboardFormatAvailable(CF_BITMAP)) 193 | return false; 194 | if (FALSE == ::OpenClipboard(hOwnerWnd)) 195 | assert_false_return_false 196 | HBITMAP hBmp = (HBITMAP)::GetClipboardData(CF_BITMAP); 197 | if (NULL == hBmp) 198 | { 199 | ::CloseClipboard(); 200 | assert_false_return_false 201 | } 202 | 203 | BITMAP bmp = {0}; 204 | ::GetObject(hBmp, sizeof(bmp), &bmp); 205 | HDC hDC = ::GetDC(hOwnerWnd); 206 | HDC hBmpDC = ::CreateCompatibleDC(hDC); 207 | HDC hBitmapDC = ::CreateCompatibleDC(hDC); 208 | hBitmap = ::CreateCompatibleBitmap(hDC, bmp.bmWidth, bmp.bmHeight); 209 | HBITMAP hOldBmp = (HBITMAP)::SelectObject(hBmpDC, hBmp); 210 | HBITMAP hOldBitmap = (HBITMAP)::SelectObject(hBitmapDC, hBitmap); 211 | ::BitBlt(hBitmapDC, 0, 0, bmp.bmWidth, bmp.bmHeight, hBmpDC, 0, 0, SRCCOPY); 212 | ::SelectObject(hBmpDC, hOldBmp); 213 | ::SelectObject(hBitmapDC, hOldBitmap); 214 | ::ReleaseDC(hOwnerWnd, hDC); 215 | ::DeleteObject(hBmpDC); 216 | ::DeleteObject(hBitmapDC); 217 | 218 | ::CloseClipboard(); 219 | return true; 220 | } 221 | 222 | public: 223 | static bool SetDropFileListToClipboard(const vector& vecFile 224 | , bool bClear = true, HWND hOwnerWnd = ::GetDesktopWindow()) 225 | { 226 | if (vecFile.empty()) 227 | assert_false_return_false 228 | 229 | DROPFILES df; 230 | df.pFiles = sizeof(df); 231 | df.pt.x = 0; 232 | df.pt.y = 0; 233 | df.fNC = FALSE; 234 | df.fWide = TRUE; 235 | size_t iByteLen = sizeof(df); 236 | for (size_t i = 0; i < vecFile.size(); ++i) 237 | iByteLen += (vecFile[i].size() + 1) * sizeof(wchar_t); 238 | iByteLen += sizeof(wchar_t); 239 | LPBYTE pByte = (LPBYTE)malloc(iByteLen); 240 | if (NULL == pByte) 241 | assert_false_return_false 242 | LPBYTE pCur = pByte; 243 | ::memcpy(pCur, (LPBYTE)&df, sizeof(df)); 244 | pCur += sizeof(df); 245 | for (size_t i = 0; i < vecFile.size(); ++i) 246 | { 247 | size_t iLen = (vecFile[i].size() + 1) * sizeof(wchar_t); 248 | ::memcpy(pCur, (LPBYTE)(vecFile[i].c_str()), iLen); 249 | pCur += iLen; 250 | } 251 | ::memset(pCur, 0, sizeof(wchar_t)); 252 | 253 | bool bRet = _SetByteToClipboard(pByte, iByteLen, CF_HDROP, bClear, hOwnerWnd); 254 | ::free(pByte); 255 | return bRet; 256 | } 257 | 258 | static bool GetDropFileListFromClipboard(OUT vector& vecFile, HWND hOwnerWnd = ::GetDesktopWindow()) 259 | { 260 | if (FALSE == ::IsClipboardFormatAvailable(CF_HDROP)) 261 | return false; 262 | if (FALSE == ::OpenClipboard(hOwnerWnd)) 263 | assert_false_return_false 264 | HDROP hDrop = (HDROP)::GetClipboardData(CF_HDROP); 265 | if (NULL == hDrop) 266 | { 267 | ::CloseClipboard(); 268 | assert_false_return_false 269 | } 270 | bool bRet = GetDropFileListFromHDrop(hDrop, vecFile); 271 | //::DragFinish(hDrop); 272 | ::CloseClipboard(); 273 | return bRet; 274 | } 275 | 276 | static bool GetDropFileListFromHDrop(IN HDROP hDrop, OUT vector& vecFile) 277 | { 278 | if (NULL == hDrop) 279 | assert_false_return_false 280 | UINT uCount = ::DragQueryFile(hDrop, -1, NULL, 0); 281 | if (0 == uCount) 282 | return true; 283 | wchar_t szBuf[MAX_PATH]; 284 | for (UINT i = 0; i < uCount; ++i) 285 | { 286 | UINT uRet = ::DragQueryFile(hDrop, i, szBuf, MAX_PATH); 287 | szBuf[uRet] = L'\0'; 288 | vecFile.push_back(wstring(szBuf)); 289 | } 290 | return true; 291 | } 292 | 293 | public: 294 | inline static UINT RegisterClipboardFormat(LPCTSTR lpszFormat) {return ::RegisterClipboardFormat(lpszFormat);} 295 | 296 | inline static bool SetCustomeFormatDataToClipboard(UINT uFormat, const wchar_t* pTextData 297 | , bool bClear = true, HWND hOwnerWnd = ::GetDesktopWindow()) 298 | { 299 | if (NULL == pTextData) 300 | {assert(false); return false;} 301 | return _SetByteToClipboard((LPBYTE)pTextData, (wcslen(pTextData) + 1) * sizeof(wchar_t) 302 | , uFormat, bClear, hOwnerWnd); 303 | } 304 | 305 | static bool GetCustomeFormateDataFromClipboard(UINT uFormat, wstring& wstrTextData 306 | , HWND hOwnerWnd = ::GetDesktopWindow()) 307 | { 308 | if (FALSE == ::IsClipboardFormatAvailable(uFormat)) 309 | return false; 310 | if (FALSE == ::OpenClipboard(hOwnerWnd)) 311 | assert_false_return_false 312 | HGLOBAL hGlobal = ::GetClipboardData(uFormat); 313 | if (NULL == hGlobal) 314 | goto exit_f1; 315 | LPVOID pGlobal = ::GlobalLock(hGlobal); 316 | if (NULL == pGlobal) 317 | goto exit_f2; 318 | size_t siLen = ::GlobalSize(hGlobal); 319 | #define STACK_BUF_SIZE 1024 320 | if (siLen <= STACK_BUF_SIZE - 2) 321 | { 322 | BYTE szBuf[STACK_BUF_SIZE]; 323 | ::memcpy(szBuf, pGlobal, siLen); 324 | szBuf[siLen] = szBuf[siLen + 1] = '\0'; 325 | wstrTextData = (wchar_t*)szBuf; 326 | } 327 | else 328 | { 329 | LPBYTE pBuf = (LPBYTE)malloc(siLen + 2); 330 | if (NULL != pBuf) 331 | { 332 | ::memcpy(pBuf, pGlobal, siLen); 333 | pBuf[siLen] = pBuf[siLen + 1] = '\0'; 334 | wstrTextData = (wchar_t*)pBuf; 335 | free(pBuf); 336 | pBuf = NULL; 337 | } 338 | } 339 | ::GlobalUnlock(hGlobal); 340 | ::CloseClipboard(); 341 | return true; 342 | 343 | exit_f2: 344 | ::GlobalUnlock(hGlobal); 345 | exit_f1: 346 | ::CloseClipboard(); 347 | assert_false_return_false 348 | } 349 | 350 | protected: 351 | static bool _SetHandleToClipboard(HANDLE hHandle, UINT uFormat 352 | , bool bNewCopy = false, bool bClear = true, HWND hOwnerWnd = ::GetDesktopWindow()) 353 | { 354 | HANDLE hGlobal = hHandle; 355 | if (bNewCopy) 356 | { 357 | if (NULL == (hGlobal = _CopyHandle(hHandle))) 358 | assert_false_return_false 359 | } 360 | 361 | if (FALSE == ::OpenClipboard(hOwnerWnd)) 362 | goto exit_f1; 363 | if (bClear) 364 | ::EmptyClipboard(); 365 | ::SetClipboardData(uFormat, hGlobal); 366 | ::CloseClipboard(); 367 | return true; 368 | 369 | exit_f1: 370 | if (bNewCopy && (NULL != hGlobal)) 371 | ::GlobalFree(hGlobal); 372 | assert_false_return_false 373 | } 374 | 375 | static bool _GetHandleFromClipboard(HANDLE& hHandle, UINT uFormat, HWND hOwnerWnd = ::GetDesktopWindow()) 376 | { 377 | assert_false_return_false 378 | } 379 | 380 | static bool _SetByteToClipboard(LPBYTE pByte, size_t siLen, UINT uFormat 381 | , bool bClear = true, HWND hOwnerWnd = ::GetDesktopWindow()) 382 | { 383 | HGLOBAL hGlobal = ::GlobalAlloc(GHND/*(GMEM_MOVEABLE | GMEM_ZEROINIT)*/, siLen); 384 | if (NULL == hGlobal) 385 | assert_false_return_false 386 | LPVOID pGlobal = ::GlobalLock(hGlobal); 387 | if (NULL == pGlobal) 388 | goto exit_f1; 389 | ::memcpy(pGlobal, pByte, siLen); 390 | ::GlobalUnlock(hGlobal); 391 | 392 | if (FALSE == ::OpenClipboard(hOwnerWnd)) 393 | goto exit_f1; 394 | if (bClear) 395 | ::EmptyClipboard(); 396 | ::SetClipboardData(uFormat, hGlobal); 397 | ::CloseClipboard(); 398 | return true; 399 | 400 | exit_f1: 401 | if (NULL != pGlobal) 402 | ::GlobalFree(hGlobal); 403 | assert_false_return_false 404 | } 405 | 406 | static bool _GetByteFromClipboard(LPBYTE& pByte, UINT uFormat, HWND hOwnerWnd = ::GetDesktopWindow()) 407 | { 408 | assert_false_return_false 409 | } 410 | 411 | static HANDLE _CopyHandle(HANDLE hHandle) 412 | { 413 | size_t siLen = ::GlobalSize(hHandle); 414 | HANDLE hGlobal = ::GlobalAlloc(GHND/*(GMEM_MOVEABLE | GMEM_ZEROINIT)*/, siLen); 415 | if (NULL == hGlobal) 416 | assert_false_return_false; 417 | LPVOID pGlobal = ::GlobalLock(hGlobal); 418 | if (NULL == pGlobal) 419 | goto exit_f1; 420 | LPVOID pHandle = ::GlobalLock(hHandle); 421 | if (NULL == pHandle) 422 | goto exit_f2; 423 | memcpy(pGlobal, pHandle, siLen); 424 | ::GlobalUnlock(hHandle); 425 | ::GlobalUnlock(hGlobal); 426 | return hGlobal; 427 | 428 | exit_f2: 429 | ::GlobalUnlock(hHandle); 430 | exit_f1: 431 | ::GlobalUnlock(hGlobal); 432 | ::GlobalFree(hGlobal); 433 | return NULL; 434 | } 435 | }; 436 | 437 | 438 | /* reference: 439 | GetClipboardOwner() 440 | IsClipboardFormatAvailable() 441 | OpenClipboard() 442 | GetClipboardData() 443 | SetClipboardData() 444 | EmptyClipboard() 445 | CloseClipboard() 446 | 447 | GlobalAlloc() 448 | GlobalFree() 449 | GlobalLock() 450 | GlobalUnLock() 451 | GlobalSize() 452 | GlobalHandle() 453 | */ -------------------------------------------------------------------------------- /LoginUserDataMgr.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/LoginUserDataMgr.cpp -------------------------------------------------------------------------------- /LoginUserDataMgr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class LoginUserDataMgr : public pattern::CSingleton 4 | { 5 | public: 6 | LoginUserDataMgr(); 7 | virtual ~LoginUserDataMgr(); 8 | 9 | void ParseLogindata(Json::Value& dataNode); 10 | 11 | CString GetUserName(); 12 | CString GetWBURL(); 13 | 14 | CString GetToken(); 15 | 16 | private: 17 | CString m_strToken; 18 | CString m_strUserName; 19 | CString m_strHeadImageURL; 20 | 21 | }; 22 | 23 | -------------------------------------------------------------------------------- /LoginWindow.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/LoginWindow.cpp -------------------------------------------------------------------------------- /LoginWindow.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/LoginWindow.h -------------------------------------------------------------------------------- /Mainframe.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/Mainframe.cpp -------------------------------------------------------------------------------- /Mainframe.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/Mainframe.h -------------------------------------------------------------------------------- /MessageUserdefine.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/MessageUserdefine.h -------------------------------------------------------------------------------- /MsgBox/CommonPopupWindow.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/MsgBox/CommonPopupWindow.cpp -------------------------------------------------------------------------------- /MsgBox/CommonPopupWindow.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/MsgBox/CommonPopupWindow.h -------------------------------------------------------------------------------- /MsgBox/DuiCloseMessageBox.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "DuiCloseMessageBox.h" 3 | 4 | Dui_Return_Type DuiMsgBox(HWND hwnd, const wchar_t * pwszMsg, const wchar_t * pwszCaption /*= NULL*/, const int btnType /*= DUI_MBOK*/) 5 | { 6 | if (pwszMsg == NULL || wcslen(pwszMsg) <= 0) 7 | return DUI_MBCLOSE; 8 | 9 | static bool bCreate = false; 10 | if(bCreate) 11 | return DUI_MBCLOSE; 12 | 13 | CDuiCloseMessageBox closeMB; 14 | closeMB.Create(hwnd, L"", WS_VISIBLE|WS_POPUP, WS_EX_TOOLWINDOW|WS_EX_LAYERED); 15 | if(::IsIconic(hwnd)) 16 | { 17 | ::SendMessage(hwnd, WM_SYSCOMMAND, SC_RESTORE, 0); 18 | } 19 | ::SetForegroundWindow(hwnd); 20 | ::SetActiveWindow(hwnd); 21 | ::BringWindowToTop(hwnd); 22 | closeMB.SetMessage(pwszMsg, pwszCaption, btnType, DUI_ICON_CONFIRM); 23 | closeMB.CenterWindow(); 24 | bCreate = true; 25 | Dui_Return_Type res = (Dui_Return_Type)closeMB.ShowModal(); 26 | bCreate = false; 27 | return res; 28 | } 29 | 30 | CDuiCloseMessageBox::CDuiCloseMessageBox() 31 | : m_pLabelCaption(NULL) 32 | , m_pTextMsgText(NULL) 33 | , m_pBtnClose(NULL) 34 | , m_pBtnOK(NULL) 35 | , m_pBtnCancel(NULL) 36 | , m_pBtnContainer(NULL) 37 | , m_rcCancelBtnPadding() 38 | { 39 | } 40 | 41 | CDuiCloseMessageBox::~CDuiCloseMessageBox() 42 | { 43 | } 44 | 45 | void CDuiCloseMessageBox::Notify( TNotifyUI& msg ) 46 | { 47 | if (msg.sType == _T("click")) 48 | { 49 | if (msg.pSender == m_pBtnClose) 50 | { 51 | Close(DUI_MBCLOSE); 52 | } 53 | else if ( msg.pSender == m_pBtnOK ) 54 | { 55 | Close(DUI_MBOK); 56 | } 57 | else if (msg.pSender == m_pBtnCancel) 58 | { 59 | Close(DUI_MBCANCEL); 60 | } 61 | } 62 | } 63 | 64 | LPCTSTR CDuiCloseMessageBox::GetWindowClassName() const 65 | { 66 | return L"MessageBoxWnd"; 67 | } 68 | 69 | DuiLib::CDuiString CDuiCloseMessageBox::GetSkinFile() 70 | { 71 | return L"DuiCloseMessageBox.xml"; 72 | } 73 | 74 | DuiLib::UILIB_RESOURCETYPE CDuiCloseMessageBox::GetResourceType() const 75 | { 76 | return UILIB_ZIPRESOURCE; 77 | } 78 | 79 | DuiLib::CDuiString CDuiCloseMessageBox::GetZIPFileName() const 80 | { 81 | return L"UISkin.zip"; 82 | } 83 | 84 | void CDuiCloseMessageBox::InitWindow() 85 | { 86 | m_pLabelCaption = static_cast(m_PaintManager.FindControl(L"caption")); 87 | m_pTextMsgText = static_cast(m_PaintManager.FindControl(L"msgtext")); 88 | m_pBtnClose = static_cast(m_PaintManager.FindControl(L"closebtn")); 89 | m_pBtnOK = static_cast(m_PaintManager.FindControl(L"btnOK")); 90 | m_pBtnCancel = static_cast(m_PaintManager.FindControl(L"btnCancel")); 91 | m_pBtnContainer = static_cast(m_PaintManager.FindControl(L"btnContainer")); 92 | m_pLabelIcon = static_cast(m_PaintManager.FindControl(L"icon")); 93 | m_pGap = static_cast(m_PaintManager.FindControl(L"gap")); 94 | } 95 | 96 | LRESULT CDuiCloseMessageBox::HandleCustomMessage( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled ) 97 | { 98 | if (uMsg == WM_NCLBUTTONDBLCLK) 99 | { 100 | bHandled = TRUE; 101 | return 0; 102 | } 103 | return 0; 104 | } 105 | 106 | void CDuiCloseMessageBox::SetMessage(const wchar_t * pwszMsg, const wchar_t * pwszCaption, const int btnType, const int msgicon) 107 | { 108 | if (m_pLabelCaption != NULL && pwszCaption != NULL) 109 | m_pLabelCaption->SetText(pwszCaption); 110 | 111 | int nwidth = 0; 112 | if (m_pLabelIcon) 113 | { 114 | CDuiString strIcon; 115 | if (msgicon == DUI_ICON_INFO)strIcon = L"MessageBox\\icon_info.png"; 116 | else if (msgicon == DUI_ICON_ERROR)strIcon = L"MessageBox\\icon_error.png"; 117 | else if (msgicon == DUI_ICON_CONFIRM)strIcon = L"MessageBox\\icon_confirm.png"; 118 | 119 | TImageInfo* ptinfo = CRenderEngine::LoadImage(strIcon.GetData()); 120 | if (ptinfo) 121 | { 122 | nwidth += ptinfo->nX; 123 | m_pLabelIcon->SetFixedWidth(ptinfo->nX); 124 | m_pLabelIcon->SetFixedHeight(ptinfo->nY); 125 | if (ptinfo->hBitmap) 126 | { 127 | DeleteObject(ptinfo->hBitmap); 128 | } 129 | delete ptinfo; 130 | } 131 | m_pLabelIcon->SetBkImage(strIcon); 132 | } 133 | RECT rcText = { 0 }; 134 | 135 | CDuiString strText; 136 | m_PaintManager.GetLangText(pwszMsg, strText); 137 | 138 | if (strText.IsEmpty()) 139 | { 140 | strText = pwszMsg; 141 | } 142 | 143 | CRenderEngine::DrawText(m_PaintManager.GetPaintDC(), &m_PaintManager, rcText, strText, 0, 0, DT_CALCRECT |DT_VCENTER); 144 | nwidth += min(160,max(80,rcText.right)); 145 | if (m_pTextMsgText != NULL && pwszMsg != NULL) 146 | m_pTextMsgText->SetText(pwszMsg); 147 | 148 | SetWindowPos(m_hWnd, NULL, 0, 0, nwidth + 120, 245, SWP_NOMOVE); 149 | 150 | m_pBtnOK->SetVisible(false); 151 | m_pBtnCancel->SetVisible(false); 152 | // m_pBtnCancel->SetPadding(m_rcCancelBtnPadding); 153 | 154 | int iButtonCount = 0; 155 | if ((btnType & DUI_MBOK) == DUI_MBOK) 156 | { 157 | m_pBtnOK->SetVisible(true); 158 | ++iButtonCount; 159 | } 160 | 161 | if ((btnType & DUI_MBCANCEL) == DUI_MBCANCEL) 162 | { 163 | m_pBtnCancel->SetVisible(true); 164 | ++iButtonCount; 165 | } 166 | 167 | if (iButtonCount == 1) 168 | { 169 | m_pGap->SetVisible(false); 170 | } 171 | m_PaintManager.NeedUpdate(); 172 | 173 | CRect rc(0, 0, nwidth + 60, 190); 174 | InvalidateRect(m_hWnd, rc, TRUE); 175 | } 176 | -------------------------------------------------------------------------------- /MsgBox/DuiCommMessageBox.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/MsgBox/DuiCommMessageBox.cpp -------------------------------------------------------------------------------- /MsgBox/DuiCommMessageBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "DuiMessageBoxDefine.h" 3 | 4 | 5 | Dui_Return_Type DuiCommMsgBox(HWND hwnd, LPCWSTR lpXmlPath = NULL, const int btnType = DUI_MBOK, LPCWSTR lpTitle = NULL, LPCWSTR lpText = NULL, LPCWSTR lpOk = NULL, LPCWSTR lpCancel = NULL); 6 | 7 | class CDuiCommMessageBox : public WindowImplBase 8 | { 9 | public: 10 | CDuiCommMessageBox(LPCWSTR lpXmlPath); 11 | ~CDuiCommMessageBox(); 12 | 13 | public://INotifyUI 14 | virtual void Notify(TNotifyUI& msg); 15 | 16 | //CWindowWndc 17 | protected: 18 | virtual LPCTSTR GetWindowClassName() const; 19 | UINT GetClassStyle() const { return CS_VREDRAW; }; 20 | 21 | DuiLib::CDuiString GetSkinFolder(); 22 | DuiLib::CDuiString GetSkinFile(); 23 | UILIB_RESOURCETYPE GetResourceType() const; 24 | virtual CDuiString GetZIPFileName() const; 25 | 26 | public: 27 | virtual void InitWindow(); 28 | virtual LRESULT HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 29 | 30 | public: 31 | void SetText(const int btnType, LPCWSTR lpTitle, LPCWSTR lpText, LPCWSTR lpOk, LPCWSTR lpCancel); 32 | 33 | private: 34 | CDuiString m_strXmlPath; 35 | 36 | private: 37 | CLabelUI *m_pTitleLab; 38 | CTextUI *m_pMsgText; 39 | CButtonUI *m_pCloseBtn; 40 | CButtonUI *m_pOKBtn; 41 | CButtonUI *m_pCancelBtn; 42 | }; 43 | 44 | -------------------------------------------------------------------------------- /MsgBox/DuiMessageBoxDefine.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum Dui_Return_Type 4 | { 5 | DUI_MBCLOSE = 0, 6 | DUI_MBCANCEL, 7 | DUI_MBOK 8 | }; 9 | enum Dui_ICON_Type 10 | { 11 | DUI_ICON_INFO = 0, 12 | DUI_ICON_ERROR, 13 | DUI_ICON_CONFIRM 14 | }; -------------------------------------------------------------------------------- /MsgBox/duiclosemessagebox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "DuiMessageBoxDefine.h" 3 | 4 | Dui_Return_Type DuiMsgBox(HWND hwnd, const wchar_t * pwszMsg, const wchar_t * pwszCaption = NULL, const int btnType = DUI_MBOK); 5 | 6 | struct MsgboxInfo{ 7 | std::wstring _strTitle; 8 | int _nBtnType; 9 | }; 10 | 11 | class CDuiCloseMessageBox : public WindowImplBase 12 | { 13 | public: 14 | CDuiCloseMessageBox(); 15 | ~CDuiCloseMessageBox(); 16 | 17 | public://INotifyUI 18 | virtual void Notify(TNotifyUI& msg); 19 | 20 | //CWindowWndc 21 | protected: 22 | virtual LPCTSTR GetWindowClassName() const; 23 | UINT GetClassStyle() const { return CS_VREDRAW; }; 24 | 25 | DuiLib::CDuiString GetSkinFile(); 26 | UILIB_RESOURCETYPE GetResourceType() const; 27 | // LPCTSTR GetResourceID() const 28 | // { 29 | // return MAKEINTRESOURCE(IDR_SKIN); 30 | // virtual CDuiString GetZIPFileName() const; 31 | 32 | public: 33 | virtual void InitWindow(); 34 | virtual LRESULT HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 35 | 36 | void SetMessage(const wchar_t * pwszMsg, const wchar_t * pwszCaption, const int btnType,const int msgicon = DUI_ICON_CONFIRM); 37 | 38 | 39 | private: 40 | CLabelUI *m_pLabelCaption; 41 | CLabelUI *m_pLabelIcon; 42 | CTextUI *m_pTextMsgText; 43 | CButtonUI *m_pBtnClose; 44 | CButtonUI *m_pBtnOK; 45 | CButtonUI *m_pBtnCancel; 46 | CControlUI*m_pGap; 47 | CHorizontalLayoutUI *m_pBtnContainer; 48 | 49 | RECT m_rcCancelBtnPadding; 50 | }; 51 | 52 | -------------------------------------------------------------------------------- /NetTask/PicTransServ.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "PicTransServ.h" 3 | 4 | CPicTransServ::CPicTransServ() 5 | : CTaskThreadBase(true, 10) 6 | { 7 | Init(); 8 | } 9 | 10 | CPicTransServ::~CPicTransServ() 11 | { 12 | UnInit(); 13 | } 14 | 15 | void CPicTransServ::Init() 16 | { 17 | RECT rcWnd; 18 | rcWnd.left = rcWnd.top = 0; 19 | rcWnd.right = rcWnd.bottom = 1; 20 | CWindowImpl::Create(NULL, rcWnd, NULL 21 | , WS_OVERLAPPEDWINDOW); 22 | } 23 | 24 | void CPicTransServ::UnInit() 25 | { 26 | CWindowImpl::DestroyWindow(); 27 | } 28 | 29 | void CPicTransServ::OnTaskCompleted(CTaskItemBase* pTask) 30 | { 31 | CPicTransTask* pPicTask = dynamic_cast(pTask); 32 | if (NULL == pPicTask) 33 | { 34 | CTaskThreadBase::OnTaskCompleted(pTask); 35 | return; 36 | } 37 | 38 | if (pPicTask->NeedRetry()) 39 | { 40 | AddToRetryList(pPicTask); 41 | } 42 | else 43 | { 44 | CTaskThreadBase::OnTaskCompleted(pTask); 45 | } 46 | } 47 | 48 | void CPicTransServ::AddToRetryList(CPicTransTask* pTask) 49 | { 50 | CMTGurad guard(m_transTaskListLock); 51 | 52 | bool bSetTimer = m_transTaskList.empty(); 53 | m_transTaskList.push_back(pTask); 54 | if (bSetTimer) 55 | SetRetryNetReqTimer(); 56 | } 57 | 58 | bool CPicTransServ::TaskIsExist(LPCWSTR lpFilePath) 59 | { 60 | CMTGurad guard(m_transTaskListLock); 61 | 62 | auto it = std::find_if(m_transTaskList.begin(), m_transTaskList.end(), [lpFilePath](CPicTransTask* pTask) { 63 | return pTask->GetLocalPath() == lpFilePath; 64 | }); 65 | 66 | if (it != m_transTaskList.end()) 67 | return true; 68 | 69 | return false; 70 | } 71 | 72 | void CPicTransServ::RemoveTaskByPath(LPCWSTR lpFilePath) 73 | { 74 | CMTGurad guard(m_transTaskListLock); 75 | 76 | auto it = std::find_if(m_transTaskList.begin(), m_transTaskList.end(), [lpFilePath](CPicTransTask* pTask) { 77 | return pTask->GetLocalPath() == lpFilePath; 78 | }); 79 | 80 | if (it != m_transTaskList.end()) 81 | { 82 | m_transTaskList.erase(it); 83 | } 84 | } 85 | 86 | LRESULT CPicTransServ::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) 87 | { 88 | UINT uTimerID = (UINT)wParam; 89 | if (RETRY_PIC_NET_REQ_TIMERID == uTimerID) 90 | { 91 | OnRetryNetReqTimer(); 92 | } 93 | 94 | return TRUE; 95 | } 96 | 97 | void CPicTransServ::SetRetryNetReqTimer() 98 | { 99 | KillTimer(RETRY_PIC_NET_REQ_TIMERID); 100 | SetTimer(RETRY_PIC_NET_REQ_TIMERID, RETRY_PIC_NET_REQ_TIMEOUT, NULL); 101 | } 102 | 103 | void CPicTransServ::KillRetryNetReqTimer() 104 | { 105 | KillTimer(RETRY_PIC_NET_REQ_TIMERID); 106 | } 107 | 108 | void CPicTransServ::OnRetryNetReqTimer() 109 | { 110 | CMTGurad guard(m_transTaskListLock); 111 | 112 | for (auto& it : m_transTaskList) 113 | { 114 | CTaskThreadBase::AddTask(it); 115 | } 116 | m_transTaskList.clear(); 117 | 118 | bool bSetTimer = m_transTaskList.empty(); 119 | if (bSetTimer) 120 | KillRetryNetReqTimer(); 121 | } -------------------------------------------------------------------------------- /NetTask/PicTransServ.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "PicTransTask.h" 5 | 6 | #define RETRY_PIC_NET_REQ_TIMERID (1006) 7 | #define RETRY_PIC_NET_REQ_TIMEOUT (2*1000) 8 | 9 | class CPicTransServ : public CWindowImpl 10 | , public CTaskThreadBase 11 | { 12 | protected: 13 | CPicTransServ(); 14 | virtual ~CPicTransServ(); 15 | 16 | void Init(); 17 | void UnInit(); 18 | 19 | virtual void OnTaskCompleted(CTaskItemBase* pTask); 20 | void AddToRetryList(CPicTransTask* pTask); 21 | 22 | 23 | BEGIN_MSG_MAP(CPicTransTask) 24 | MESSAGE_HANDLER(WM_TIMER, OnTimer) 25 | END_MSG_MAP() 26 | 27 | LRESULT OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 28 | 29 | void SetRetryNetReqTimer(); 30 | void KillRetryNetReqTimer(); 31 | void OnRetryNetReqTimer(); 32 | 33 | public: 34 | static CPicTransServ& Inst() 35 | { 36 | static CPicTransServ s_inst; 37 | return s_inst; 38 | } 39 | 40 | bool TaskIsExist(LPCWSTR lpFilePath); 41 | void RemoveTaskByPath(LPCWSTR lpFilePath); 42 | 43 | protected: 44 | list m_transTaskList; 45 | CCriticalSect m_transTaskListLock; 46 | }; -------------------------------------------------------------------------------- /NetTask/PicTransTask.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/NetTask/PicTransTask.cpp -------------------------------------------------------------------------------- /NetTask/PicTransTask.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/NetTask/PicTransTask.h -------------------------------------------------------------------------------- /ReadMe.md: -------------------------------------------------------------------------------- 1 | 2 | # Simple live streaming app 3 | 4 | ## Description 5 | 6 | An online live streaming client developed based on Agora. It has basic functions such as collection, encoding live stream. 7 | 8 | - DUILib for software interface design, and cef (browser embedding framework) to implement the software's web page embedding function 9 | 10 | - Access to Agora SDK to realize one-to-one video communication function 11 | 12 | 13 | ## Dependencies 14 | 15 | - Agora SDK 16 | - DUILib 17 | -------------------------------------------------------------------------------- /Resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | 3 | #define IDC_MYICON 2 4 | #define IDD_WEIJIAN_DIALOG 102 5 | #define IDS_APP_TITLE 103 6 | #define IDD_ABOUTBOX 103 7 | #define IDM_ABOUT 104 8 | #define IDM_EXIT 105 9 | #define IDC_WEIJIAN 109 10 | #define IDR_MAINFRAME 128 11 | #define IDI_ICON1 129 12 | #define IDC_STATIC -1 13 | 14 | // Next default values for new objects 15 | // 16 | #ifdef APSTUDIO_INVOKED 17 | #ifndef APSTUDIO_READONLY_SYMBOLS 18 | #define _APS_NO_MFC 1 19 | #define _APS_NEXT_RESOURCE_VALUE 130 20 | #define _APS_NEXT_COMMAND_VALUE 32771 21 | #define _APS_NEXT_CONTROL_VALUE 1000 22 | #define _APS_NEXT_SYMED_VALUE 110 23 | #endif 24 | #endif 25 | -------------------------------------------------------------------------------- /Rocket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "resource.h" 4 | -------------------------------------------------------------------------------- /Rocket.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/Rocket.ico -------------------------------------------------------------------------------- /Rocket.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/Rocket.rc -------------------------------------------------------------------------------- /Rocket.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30717.126 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Rocket", "Rocket.vcxproj", "{BB8E13CD-C854-4BCA-828A-1C1F161AB20A}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {BB8E13CD-C854-4BCA-828A-1C1F161AB20A}.Debug|x64.ActiveCfg = Debug|x64 17 | {BB8E13CD-C854-4BCA-828A-1C1F161AB20A}.Debug|x64.Build.0 = Debug|x64 18 | {BB8E13CD-C854-4BCA-828A-1C1F161AB20A}.Debug|x86.ActiveCfg = Debug|Win32 19 | {BB8E13CD-C854-4BCA-828A-1C1F161AB20A}.Debug|x86.Build.0 = Debug|Win32 20 | {BB8E13CD-C854-4BCA-828A-1C1F161AB20A}.Release|x64.ActiveCfg = Release|x64 21 | {BB8E13CD-C854-4BCA-828A-1C1F161AB20A}.Release|x64.Build.0 = Release|x64 22 | {BB8E13CD-C854-4BCA-828A-1C1F161AB20A}.Release|x86.ActiveCfg = Release|Win32 23 | {BB8E13CD-C854-4BCA-828A-1C1F161AB20A}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {535DD247-7E13-4192-AD8B-52452DE99E8D} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /Rocket.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | {BB8E13CD-C854-4BCA-828A-1C1F161AB20A} 24 | Win32Proj 25 | Rocket 26 | 10.0 27 | ClassLive 28 | 29 | 30 | 31 | Application 32 | true 33 | v142 34 | Unicode 35 | 36 | 37 | Application 38 | false 39 | v142 40 | true 41 | Unicode 42 | 43 | 44 | Application 45 | true 46 | v142 47 | Unicode 48 | 49 | 50 | Application 51 | false 52 | v142 53 | true 54 | Unicode 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | true 76 | ..\..\bin\$(Configuration)\ 77 | 78 | 79 | true 80 | 81 | 82 | false 83 | ../../bin/Release 84 | 85 | 86 | false 87 | 88 | 89 | 90 | Use 91 | Level3 92 | true 93 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 94 | false 95 | ..\..\3rdparty\WTL90\Include;..\..\3rdparty\duilib\Src\DuiLib;..\..\3rdparty\jsoncpp\include;..\..\build\;..\..\include;..\..\baseclass;.\include;..\..\3rdparty\curl\include;..\..\;..\ 96 | $(IntDir)$(TargetName).pch 97 | EditAndContinue 98 | false 99 | 100 | 101 | Windows 102 | true 103 | ..\..\bin\$(Configuration);..\..\3rdparty\curl\Lib\$(Configuration);%(AdditionalLibraryDirectories) 104 | DuiLib.lib;libssl32MDd.lib;libcrypto32MDd.lib 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | Level3 114 | true 115 | _DEBUG;_WINDOWS;%(PreprocessorDefinitions) 116 | true 117 | false 118 | D:\Users\Tan\source\repos\Rocket\3rd\duilib\include;%(AdditionalIncludeDirectories) 119 | 120 | 121 | Windows 122 | true 123 | D:\Users\Tan\source\repos\Rocket\3rd\duilib\Dll\Debug;D:\Users\Tan\source\repos\Rocket\3rd\duilib\Lib;%(AdditionalLibraryDirectories) 124 | DuiLib.dll;%(AdditionalDependencies) 125 | 126 | 127 | 128 | 129 | 130 | 131 | Level3 132 | true 133 | true 134 | true 135 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 136 | true 137 | ..\..\3rd\duilib\include;..\..\include 138 | 139 | 140 | Windows 141 | true 142 | true 143 | true 144 | .3rd\duilib\Lib\Release 145 | DuiLib.dll 146 | 147 | 148 | 149 | 150 | 151 | 152 | Level3 153 | true 154 | true 155 | true 156 | NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 157 | true 158 | 159 | 160 | Windows 161 | true 162 | true 163 | true 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | NotUsing 258 | 259 | 260 | NotUsing 261 | 262 | 263 | NotUsing 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | NotUsing 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | Create 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | -------------------------------------------------------------------------------- /Rocket.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {554f0853-2893-4eaf-ac64-95fd0f59f48d} 18 | 19 | 20 | {bffa2ffa-28e4-494b-af62-faef7458801a} 21 | 22 | 23 | {04445f6e-5983-41ab-bd55-f42a9f094a1c} 24 | 25 | 26 | {0c03546f-28c8-4ac1-a983-48b2020c9da3} 27 | 28 | 29 | {adfd75a4-d69c-443c-9aea-26f4e4e03182} 30 | 31 | 32 | 33 | 34 | 头文件 35 | 36 | 37 | 头文件 38 | 39 | 40 | 头文件 41 | 42 | 43 | 头文件 44 | 45 | 46 | 头文件 47 | 48 | 49 | baseclass 50 | 51 | 52 | baseclass 53 | 54 | 55 | baseclass 56 | 57 | 58 | baseclass 59 | 60 | 61 | baseclass 62 | 63 | 64 | baseclass 65 | 66 | 67 | baseclass 68 | 69 | 70 | baseclass 71 | 72 | 73 | baseclass 74 | 75 | 76 | baseclass 77 | 78 | 79 | baseclass 80 | 81 | 82 | baseclass 83 | 84 | 85 | baseclass 86 | 87 | 88 | baseclass 89 | 90 | 91 | baseclass 92 | 93 | 94 | baseclass 95 | 96 | 97 | baseclass 98 | 99 | 100 | baseclass 101 | 102 | 103 | NetTask 104 | 105 | 106 | NetTask 107 | 108 | 109 | include 110 | 111 | 112 | include 113 | 114 | 115 | json 116 | 117 | 118 | json 119 | 120 | 121 | json 122 | 123 | 124 | json 125 | 126 | 127 | json 128 | 129 | 130 | json 131 | 132 | 133 | json 134 | 135 | 136 | json 137 | 138 | 139 | json 140 | 141 | 142 | json 143 | 144 | 145 | json 146 | 147 | 148 | 头文件 149 | 150 | 151 | 头文件 152 | 153 | 154 | 头文件 155 | 156 | 157 | 头文件 158 | 159 | 160 | 头文件 161 | 162 | 163 | 头文件 164 | 165 | 166 | 头文件 167 | 168 | 169 | 头文件 170 | 171 | 172 | 头文件 173 | 174 | 175 | 头文件 176 | 177 | 178 | 头文件 179 | 180 | 181 | 头文件 182 | 183 | 184 | 头文件 185 | 186 | 187 | 头文件 188 | 189 | 190 | 头文件 191 | 192 | 193 | baseclass 194 | 195 | 196 | baseclass 197 | 198 | 199 | baseclass 200 | 201 | 202 | baseclass 203 | 204 | 205 | baseclass 206 | 207 | 208 | baseclass 209 | 210 | 211 | baseclass 212 | 213 | 214 | baseclass 215 | 216 | 217 | baseclass 218 | 219 | 220 | baseclass 221 | 222 | 223 | baseclass 224 | 225 | 226 | baseclass 227 | 228 | 229 | baseclass 230 | 231 | 232 | baseclass 233 | 234 | 235 | baseclass 236 | 237 | 238 | baseclass 239 | 240 | 241 | baseclass 242 | 243 | 244 | baseclass 245 | 246 | 247 | baseclass 248 | 249 | 250 | baseclass 251 | 252 | 253 | baseclass 254 | 255 | 256 | baseclass 257 | 258 | 259 | baseclass 260 | 261 | 262 | baseclass 263 | 264 | 265 | baseclass 266 | 267 | 268 | baseclass 269 | 270 | 271 | baseclass 272 | 273 | 274 | baseclass 275 | 276 | 277 | baseclass 278 | 279 | 280 | mainUI 281 | 282 | 283 | mainUI 284 | 285 | 286 | mainUI 287 | 288 | 289 | 头文件 290 | 291 | 292 | 头文件 293 | 294 | 295 | 296 | 297 | 源文件 298 | 299 | 300 | 源文件 301 | 302 | 303 | baseclass 304 | 305 | 306 | baseclass 307 | 308 | 309 | baseclass 310 | 311 | 312 | baseclass 313 | 314 | 315 | baseclass 316 | 317 | 318 | baseclass 319 | 320 | 321 | baseclass 322 | 323 | 324 | baseclass 325 | 326 | 327 | baseclass 328 | 329 | 330 | baseclass 331 | 332 | 333 | baseclass 334 | 335 | 336 | NetTask 337 | 338 | 339 | NetTask 340 | 341 | 342 | json 343 | 344 | 345 | json 346 | 347 | 348 | json 349 | 350 | 351 | 源文件 352 | 353 | 354 | 源文件 355 | 356 | 357 | 源文件 358 | 359 | 360 | 源文件 361 | 362 | 363 | 源文件 364 | 365 | 366 | 源文件 367 | 368 | 369 | 源文件 370 | 371 | 372 | 源文件 373 | 374 | 375 | 源文件 376 | 377 | 378 | 源文件 379 | 380 | 381 | 源文件 382 | 383 | 384 | 源文件 385 | 386 | 387 | baseclass 388 | 389 | 390 | baseclass 391 | 392 | 393 | baseclass 394 | 395 | 396 | baseclass 397 | 398 | 399 | baseclass 400 | 401 | 402 | baseclass 403 | 404 | 405 | baseclass 406 | 407 | 408 | baseclass 409 | 410 | 411 | baseclass 412 | 413 | 414 | baseclass 415 | 416 | 417 | baseclass 418 | 419 | 420 | baseclass 421 | 422 | 423 | baseclass 424 | 425 | 426 | baseclass 427 | 428 | 429 | baseclass 430 | 431 | 432 | baseclass 433 | 434 | 435 | baseclass 436 | 437 | 438 | baseclass 439 | 440 | 441 | mainUI 442 | 443 | 444 | mainUI 445 | 446 | 447 | mainUI 448 | 449 | 450 | 源文件 451 | 452 | 453 | 源文件 454 | 455 | 456 | 源文件 457 | 458 | 459 | 460 | 461 | 资源文件 462 | 463 | 464 | 465 | 466 | 资源文件 467 | 468 | 469 | 资源文件 470 | 471 | 472 | 473 | 474 | json 475 | 476 | 477 | 478 | 479 | 480 | -------------------------------------------------------------------------------- /RoomWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "RoomWindow.h" 3 | 4 | CRoomWindow::CRoomWindow() 5 | { 6 | m_pCloseBtn = NULL; 7 | m_meUI = NULL; 8 | m_youUI = NULL; 9 | } 10 | 11 | CRoomWindow::~CRoomWindow() 12 | { 13 | } 14 | 15 | void CRoomWindow::InitWindow() 16 | { 17 | m_pCloseBtn = static_cast(m_PaintManager.FindControl(L"closebtn")); 18 | 19 | m_pMinBtn = static_cast(m_PaintManager.FindControl(L"minbtn")); 20 | m_pMaxBtn = static_cast(m_PaintManager.FindControl(L"maxbtn")); 21 | m_pRefreshBtn = static_cast(m_PaintManager.FindControl(L"refutbtn")); 22 | 23 | m_pWBUI = static_cast(m_PaintManager.FindControl(L"Cef3WebRoom")); 24 | 25 | m_meUI = static_cast(m_PaintManager.FindControl(_T("my"))); 26 | m_youUI = static_cast(m_PaintManager.FindControl(_T("you"))); 27 | 28 | if (m_pWBUI) 29 | { 30 | m_pWBUI->SetCef3CallBack(this); 31 | m_pWBUI->CreateBrowser(BROWSER_BORAD); 32 | } 33 | } 34 | 35 | void CRoomWindow::Notify(TNotifyUI& msg) 36 | { 37 | if (msg.sType == DUI_MSGTYPE_CLICK) 38 | { 39 | if (msg.pSender == m_pCloseBtn) 40 | { 41 | ShowWindow(false); 42 | PostQuitMessage(0); 43 | } 44 | else if (msg.pSender == m_pMinBtn) 45 | { 46 | SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0); 47 | } 48 | else if (msg.pSender == m_pMaxBtn) 49 | { 50 | SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0); 51 | } 52 | 53 | } 54 | } 55 | 56 | LRESULT CRoomWindow::OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) 57 | { 58 | return __super::OnSysCommand(uMsg, wParam, lParam, bHandled); 59 | } 60 | 61 | LRESULT CRoomWindow::HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) 62 | { 63 | return 0; 64 | } 65 | 66 | DuiLib::CControlUI* CRoomWindow::CreateControl(LPCTSTR pstrClass) 67 | { 68 | if (_tcsicmp(pstrClass, _T("Cef3Web")) == 0) 69 | { 70 | return new CCef3WebUI; 71 | } 72 | return NULL; 73 | } 74 | 75 | void CRoomWindow::OnBrowserCreated(void* ThisUI) 76 | { 77 | if (m_pWBUI) 78 | { 79 | CString str = L"D:\\Users\\Tan\\source\\repos\\Rocket\\bin\\Debug\\skin\\room.html"; 80 | m_pWBUI->OpenURL(str); 81 | //m_pCourseWeb->OpenURL(L"http://www.baidu.com"); 82 | } 83 | } 84 | 85 | void CRoomWindow::OnLoadEnd(void* ThisUI) 86 | { 87 | 88 | } 89 | 90 | void CRoomWindow::OnLoadError(int nError, void* ThisUI) 91 | { 92 | 93 | } 94 | 95 | void CRoomWindow::OnJSCallCPlus(LPCWSTR lpwsId, LPCWSTR lpwsContent, void* ThisUI) 96 | { 97 | 98 | } 99 | 100 | DuiLib::UILIB_RESOURCETYPE CRoomWindow::GetResourceType() const 101 | { 102 | return UILIB_FILE; 103 | } 104 | 105 | DuiLib::CDuiString CRoomWindow::GetZIPFileName() const 106 | { 107 | return L"skin.zip"; 108 | } 109 | 110 | 111 | DuiLib::CDuiString CRoomWindow::GetSkinFile() 112 | { 113 | return L"room.xml"; 114 | } 115 | 116 | DuiLib::CDuiString CRoomWindow::GetSkinFolder() 117 | { 118 | return _T("skin\\"); 119 | } 120 | 121 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /RoomWindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "UICef3Web.h" 3 | #include "UIVideo.h" 4 | class CRoomWindow 5 | : public WindowImplBase 6 | , public CCef3CallBack 7 | { 8 | public: 9 | CRoomWindow(); 10 | virtual ~CRoomWindow(void); 11 | 12 | //INotifyUI 13 | public: 14 | virtual void Notify(TNotifyUI& msg); 15 | //CWindowWndc 16 | protected: 17 | virtual LPCTSTR GetWindowClassName() const { return L"room"; }; 18 | UINT GetClassStyle() const { return CS_DBLCLKS; }; 19 | 20 | DuiLib::CDuiString GetSkinFolder(); 21 | DuiLib::CDuiString GetSkinFile(); 22 | UILIB_RESOURCETYPE GetResourceType() const; 23 | virtual CDuiString GetZIPFileName() const; 24 | 25 | public: 26 | virtual void InitWindow(); 27 | virtual LRESULT HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) override; 28 | // virtual LRESULT OnSetFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) override; 29 | // virtual LRESULT OnKillFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) override; 30 | virtual LRESULT OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) override; 31 | virtual CControlUI* CreateControl(LPCTSTR pstrClass)override; 32 | 33 | public: 34 | virtual void OnBrowserCreated(void* ThisUI); // 创建完成,可以navigate 35 | virtual void OnLoadEnd(void* ThisUI); // Navigate完成 js上下文就绪,可以执行js代码 36 | virtual void OnLoadError(int nError, void* ThisUI); // Navigate错误 37 | virtual void OnJSCallCPlus(LPCWSTR lpwsId, LPCWSTR lpwsContent, void* ThisUI); // JS回调接口 38 | virtual void OnBrowserClosed() {}; 39 | virtual void OnRenderProcessTerminated(LPCWSTR lpwsUrl, int nStatus) {}; 40 | virtual void OnTitleChange(LPCWSTR lpTitle, void* ThisUI) {}; 41 | virtual void OnAddressChange(LPCWSTR lpwsaddress, void* ThisUI) {}; 42 | virtual void OnCookie(LPCWSTR cookie, void* ThisUI) {}; 43 | virtual void OnLoadingStateChange(void* ThisUI, bool bisLoading, bool isgoback, bool isgoforure) {}; 44 | 45 | private: 46 | CButtonUI* m_pCloseBtn; 47 | CButtonUI* m_pMinBtn; 48 | CButtonUI* m_pMaxBtn; 49 | CButtonUI* m_pRefreshBtn; 50 | 51 | CCef3WebUI* m_pWBUI; 52 | CVideoUI* m_meUI; 53 | CVideoUI* m_youUI; 54 | }; -------------------------------------------------------------------------------- /SACModule.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "SACModule.h" 3 | #include "Core/DuiLangManager.h" 4 | 5 | #include 6 | 7 | #define MKDIREXIST(x) HELPER::MakeDirExist(x) 8 | #include "MiniDump.h" 9 | #include "IniHelper.h" 10 | #include 11 | 12 | CSACModule::CSACModule(void) 13 | :m_eProcessType(eBrowserProcess) 14 | { 15 | 16 | 17 | } 18 | 19 | CSACModule::~CSACModule(void) 20 | { 21 | 22 | } 23 | 24 | LPCWSTR LogFileName(CString& strName) 25 | { 26 | LPCWSTR pwsPrefix = L""; 27 | 28 | SYSTEMTIME st = {0}; 29 | GetLocalTime(&st); 30 | 31 | CString strFileName; 32 | strFileName.Format(MAIN_PROJECT_NAME L"_clsk12%s_%d_%02d%02d%02d_%02d%02d%02d_%03d.log", 33 | pwsPrefix, GetCurrentProcessId(), 34 | st.wYear, st.wMonth, st.wDay, 35 | st.wHour, st.wMinute, st.wSecond, 36 | st.wMilliseconds); 37 | 38 | WCHAR wszAppData[MAX_PATH] = {0}; 39 | SHGetSpecialFolderPath(NULL, wszAppData, CSIDL_APPDATA, FALSE); 40 | 41 | CString strSubPath; 42 | strSubPath.Format(L"%s\\%s\\", PROGRAM_APPDATA_FLODER_NAME, SAVE_LOGS_FOLDER_NAME); 43 | 44 | PathAppend(wszAppData, strSubPath); 45 | strName = wszAppData + strFileName; 46 | return strName; 47 | } 48 | 49 | 50 | LPCWSTR CrashFileName(eProcessType eType, CString& strName) 51 | { 52 | LPCWSTR pwsPrefix = L""; 53 | switch(eType) 54 | { 55 | case eBrowserProcess: pwsPrefix = L""; break; 56 | case eRendererProcess: pwsPrefix = L"_Render"; break; 57 | case eOtherProcess: pwsPrefix = L"_Other"; break; 58 | case eZygoteProcess: pwsPrefix = L"_Zygote"; break; 59 | default: ATLASSERT(FALSE); break; 60 | } 61 | 62 | strName.Format(MAIN_PROJECT_NAME L"_clsk12%s_%d_%s", 63 | pwsPrefix, GetCurrentProcessId(), VERSION_WSTRING_BUILD); 64 | 65 | return strName; 66 | } 67 | 68 | HRESULT CSACModule::Init(eProcessType eType) 69 | { 70 | CString strName; 71 | HRESULT hr = eBrowserProcess == eType ? InitLog(LogFileName(strName)) : S_FALSE; 72 | if(FAILED(hr)) 73 | return hr; 74 | 75 | hr = InitCrashHandler(CrashFileName(eType, strName)); 76 | if (FAILED(hr)) 77 | return hr; 78 | 79 | InitCefDll(); 80 | 81 | if(eType != eBrowserProcess) 82 | return S_OK; 83 | 84 | InitGDIPlus(); 85 | 86 | return hr; 87 | } 88 | 89 | HRESULT CSACModule::Uninit() 90 | { 91 | HRESULT hr = UninitLog(); 92 | ATLASSERT(SUCCEEDED(hr)); 93 | 94 | UninitCefDll(); 95 | UninitGDIPlus(); 96 | 97 | return S_OK; 98 | } 99 | 100 | HRESULT CSACModule::InitCefDll() 101 | { 102 | return m_hCefDll.Load(L"ACCef.dll"); 103 | } 104 | 105 | HRESULT CSACModule::UninitCefDll() 106 | { 107 | if (m_hCefDll) 108 | { 109 | m_hCefDll.Free(); 110 | } 111 | return S_OK; 112 | } 113 | 114 | HRESULT CSACModule::InitGDIPlus() 115 | { 116 | GdiplusStartup(&m_gdiplusToken, &m_gdiplusStartupInput, NULL); 117 | 118 | return S_OK; 119 | } 120 | 121 | HRESULT CSACModule::UninitGDIPlus() 122 | { 123 | Gdiplus::GdiplusShutdown(m_gdiplusToken); 124 | 125 | return S_OK; 126 | } 127 | 128 | void CSACModule::SetCefInstance(ICefManager* spMgr) 129 | { 130 | m_spCefMgr = spMgr; 131 | } 132 | 133 | ICefManager* CSACModule::GetCefMgrInstance() 134 | { 135 | if (m_spCefMgr) 136 | { 137 | return m_spCefMgr; 138 | } 139 | return nullptr; 140 | } 141 | 142 | HMODULE CSACModule::GetCefModuleHandle() 143 | { 144 | if (m_hCefDll) 145 | { 146 | return m_hCefDll.Attach(GetModuleHandle(L"ACCef.dll")); 147 | } 148 | return nullptr; 149 | } 150 | 151 | CLoginWindow* CSACModule::GetLoginWnd() 152 | { 153 | return m_ploginWnd; 154 | } 155 | 156 | bool CSACModule::IsWinLanguageChinese() 157 | { 158 | LANGID lid = GetSystemDefaultLangID(); 159 | if (lid == 0x0404 || lid == 0x0804 || lid == 0x0c04 || lid == 0x1004) 160 | { 161 | return true; 162 | } 163 | 164 | return false; 165 | } 166 | 167 | LPCTSTR CSACModule::GetLanguage() 168 | { 169 | return g_SACMoudleApp.IsWinLanguageChinese() ? L"cn" : L"en"; 170 | } 171 | 172 | LPCSTR CSACModule::GetLanguageA() 173 | { 174 | return g_SACMoudleApp.IsWinLanguageChinese() ? "cn" : "en"; 175 | } 176 | 177 | int CSACModule::DUIMain(HINSTANCE hInstance, LPTSTR lpstrCmdLine, int nCmdShow) 178 | { 179 | LOGPRINTTIMESTAMP(L"ACRun: DUIMain %d", GetTickCount()); 180 | 181 | CPaintManagerUI::SetInstance(hInstance); 182 | 183 | if (IsWinLanguageChinese()) 184 | { 185 | CPaintManagerUI::SetDefLang(L"zh_cn"); 186 | } 187 | else 188 | { 189 | CPaintManagerUI::SetDefLang(L"en_us"); 190 | } 191 | 192 | CPaintManagerUI::SetLangXml(L"lang.xml", CPaintManagerUI::GetInstancePath()); 193 | 194 | CPaintManagerUI::SetColorXml(CPaintManagerUI::GetInstancePath() + L"\\skin\\color.xml"); 195 | 196 | // CPaintManagerUI::SetResourcePath(SkinManager()->GetWindowXMLFolder()); 197 | // CPaintManagerUI::SetResourceImagePath(SkinManager()->GetSkinFolder()); 198 | // 199 | // CPaintManagerUI::LoadResourceZip(MAKEINTRESOURCE(IDR_SKIN), _T("ZIPRES")); 200 | 201 | // OnFirstCommandLine(lpstrCmdLine); 202 | 203 | CLoginWindow* mainWindow = new CLoginWindow(); 204 | { 205 | mainWindow->Create(NULL, L"loginwindow", UI_WNDSTYLE_FRAME, 0L); 206 | 207 | mainWindow->ShowWindow(true); 208 | mainWindow->CenterWindow(); 209 | } 210 | 211 | m_ploginWnd = mainWindow; 212 | 213 | // CMainframe* mainWindow = new CMainframe(); 214 | // { 215 | // mainWindow->Create(NULL, L"mainframe", UI_WNDSTYLE_FRAME, 0L); 216 | // 217 | // mainWindow->ShowWindow(true); 218 | // mainWindow->CenterWindow(); 219 | // } 220 | 221 | LOGPRINTTIMESTAMP(L"ACRun: RunMessageLoop %d", GetTickCount()); 222 | 223 | BOOL bRet; 224 | MSG msg = { 0 }; 225 | while ((bRet = GetMessage(&msg, NULL, 0, 0)) > 0) 226 | { 227 | TranslateMessage(&msg); 228 | DispatchMessage(&msg); 229 | } 230 | 231 | LOGPRINTTIMESTAMP(L"ACRun: ExitMessageLoop %d", GetTickCount()); 232 | 233 | return 0; 234 | } 235 | 236 | 237 | HRESULT CSACModule::InitLog(LPCWSTR lpwsLogFile) 238 | { 239 | if (NULL == lpwsLogFile) 240 | return E_INVALIDARG; 241 | 242 | CString strName; 243 | 244 | 245 | BOOL bRtn = HELPER::MakeDirExist(lpwsLogFile, true); 246 | ATLASSERT(bRtn); 247 | 248 | LOGPRINT_INIT_FILE(lpwsLogFile); 249 | 250 | LOGPRINTTIMESTAMP(MAIN_PROJECT_NAME L" Start : %d", GetCurrentProcessId()); 251 | return S_FALSE; 252 | } 253 | 254 | HRESULT CSACModule::UninitLog() 255 | { 256 | LOGPRINTTIMESTAMP(MAIN_PROJECT_NAME L" Stop : %d", GetCurrentProcessId()); 257 | LOGPRINT_UNINIT(); 258 | return S_FALSE; 259 | } 260 | 261 | HRESULT CSACModule::InitCrashHandler(LPCWSTR lpwsPrefix) 262 | { 263 | if(NULL == lpwsPrefix) 264 | return E_INVALIDARG; 265 | 266 | UINT new_flags = 267 | SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX; 268 | UINT existing_flags = SetErrorMode(new_flags); 269 | SetErrorMode(existing_flags | new_flags); 270 | 271 | CMiniDump::SetDumpFileName(lpwsPrefix, NULL, MAIN_PROJECT_NAME L"Data\\logs"); 272 | 273 | bool bRtn = CMiniDump::EnableTrackException(true); 274 | return bRtn ? S_OK : S_FALSE; 275 | } 276 | 277 | HRESULT CSACModule::UninitCrashHandler() 278 | { 279 | CMiniDump::EnableTrackException(false); 280 | return S_FALSE; 281 | } 282 | 283 | void CSACModule::TerminateChildProcess() 284 | { 285 | CHandle hSnapShot(CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)); 286 | PROCESSENTRY32 pe = { 0 }; 287 | pe.dwSize = sizeof(PROCESSENTRY32); 288 | if (!Process32First(hSnapShot, &pe)) 289 | return; 290 | 291 | DWORD dwPIDSelf = GetCurrentProcessId(); 292 | do 293 | { 294 | if (pe.th32ProcessID == dwPIDSelf) 295 | continue; 296 | 297 | if (pe.th32ParentProcessID == dwPIDSelf) 298 | { 299 | DWORD dwProcessID = pe.th32ProcessID; 300 | HANDLE hProcess = ::OpenProcess(PROCESS_TERMINATE, FALSE, dwProcessID); 301 | if (hProcess) 302 | { 303 | ::TerminateProcess(hProcess, 0); 304 | CloseHandle(hProcess); 305 | } 306 | } 307 | } while (Process32Next(hSnapShot, &pe)); 308 | } 309 | 310 | void CSACModule::OnFirstCommandLine(LPCWSTR lpwsCmdLine) 311 | { 312 | if (NULL == lpwsCmdLine) 313 | return; 314 | 315 | // CCommandParse parse; 316 | // if (!parse.Parse(lpwsCmdLine)) 317 | // return; 318 | // 319 | // CCommand* pCmd = nullptr; 320 | // 321 | // pCmd = parse.FindCommand(L"shellopen"); 322 | // if (pCmd) 323 | // { 324 | // OnShellOpen(pCmd, parse); 325 | // } 326 | // pCmd = parse.FindCommand(L"enterclass"); 327 | // if (pCmd) 328 | // { 329 | // ParseEnterClassInfo(pCmd->GetArg(0)); 330 | // } 331 | } 332 | -------------------------------------------------------------------------------- /SACModule.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/SACModule.h -------------------------------------------------------------------------------- /TimeMgr.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/TimeMgr.h -------------------------------------------------------------------------------- /TroyControls.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/TroyControls.h -------------------------------------------------------------------------------- /UICef3Web.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "UICef3Web.h" 3 | namespace DuiLib 4 | { 5 | CCef3WebUI::CCef3WebUI(void) 6 | : m_pCef3Callback(NULL) 7 | { 8 | 9 | } 10 | 11 | CCef3WebUI::~CCef3WebUI(void) 12 | { 13 | LOGPRINTTIMESTAMP(L"CCef3WebUI::~CCef3WebUI"); 14 | } 15 | 16 | LPCTSTR CCef3WebUI::GetClass() const 17 | { 18 | return _T("UICCef3Web"); 19 | } 20 | 21 | LPVOID CCef3WebUI::GetInterface( LPCTSTR pstrName ) 22 | { 23 | if( _tcscmp(pstrName, _T("Cef3Web")) == 0 ) 24 | return static_cast(this); 25 | 26 | return CControlUI::GetInterface(pstrName); 27 | } 28 | 29 | void CCef3WebUI::SetVisible(bool bVisible) 30 | { 31 | CControlUI::SetVisible(bVisible); 32 | if(m_spCefWebBrowser) 33 | m_spCefWebBrowser->SetShow(bVisible?TRUE:FALSE); 34 | } 35 | 36 | void CCef3WebUI::SetInternVisible(bool bVisible) 37 | { 38 | CControlUI::SetInternVisible(bVisible); 39 | if(m_spCefWebBrowser) 40 | m_spCefWebBrowser->SetShow(bVisible?TRUE:FALSE); 41 | 42 | if (bVisible) 43 | InvalidateBrowserWndRect(&m_rcItem, true); 44 | } 45 | 46 | void CCef3WebUI::SetCef3CallBack( CCef3CallBack* pCallBack ) 47 | { 48 | if (NULL == m_pCef3Callback) 49 | { 50 | m_pCef3Callback = pCallBack; 51 | } 52 | } 53 | 54 | void CCef3WebUI::OpenURL( LPCWSTR lpUrl, BOOL bIgnore404/* = TRUE*/) 55 | { 56 | if(m_spCefWebBrowser) 57 | m_spCefWebBrowser->LoadURL(lpUrl, bIgnore404); 58 | } 59 | 60 | void CCef3WebUI::Reload() 61 | { 62 | if(m_spCefWebBrowser) 63 | m_spCefWebBrowser->Reload(FALSE); 64 | } 65 | 66 | void CCef3WebUI::GoBack() 67 | { 68 | if (m_spCefWebBrowser) 69 | { 70 | m_spCefWebBrowser->Goback(); 71 | } 72 | } 73 | 74 | void CCef3WebUI::GoForward() 75 | { 76 | if (m_spCefWebBrowser) 77 | { 78 | m_spCefWebBrowser->GoForward(); 79 | } 80 | } 81 | 82 | // bool CCef3WebUI::CreateBrowser(LPCTSTR szName, LPRECT rcBrowser) 83 | // { 84 | // if (__super::CreateBrowser(szName, rcBrowser)) 85 | // { 86 | // m_spCefWebBrowser->AdvisEvent(this); 87 | // return true; 88 | // } 89 | // return false; 90 | // } 91 | // 92 | // void CCef3WebUI::CloseBrowser() 93 | // { 94 | // if (m_spCefWebBrowser) 95 | // { 96 | // CComQIPtr spWB2 = m_spCefWebBrowser; 97 | // spWB2->Close(); 98 | // } 99 | // } 100 | 101 | const HWND CCef3WebUI::GetBrowserHWND() const 102 | { 103 | return m_hBrowerWnd; 104 | } 105 | 106 | // void CCef3WebUI::DestroyBrowser() 107 | // { 108 | // if (m_hBrowerWnd) 109 | // { 110 | // if (::IsWindow(m_hBrowerWnd)) 111 | // DestroyWindow(m_hBrowerWnd); 112 | // m_hBrowerWnd = NULL; 113 | // } 114 | // 115 | // if (m_spCefWebBrowser) 116 | // m_spCefWebBrowser->AdvisEvent(NULL); 117 | // m_spCefWebBrowser.Release(); 118 | // 119 | // m_pCef3Callback = NULL; 120 | // } 121 | 122 | void CCef3WebUI::SetPos(RECT rc, bool bNeedInvalidate /*= true*/) 123 | { 124 | __super::SetPos(rc, bNeedInvalidate); 125 | 126 | if(m_spCefWebBrowser) 127 | { 128 | m_spCefWebBrowser->AdjustRect(&rc); 129 | } 130 | } 131 | 132 | HRESULT CCef3WebUI::CallJSCommonFunc(LPCWSTR lpwsJSFuncName, LPCWSTR lpwsJSFuncParamJson) 133 | { 134 | if (!lpwsJSFuncName || !lpwsJSFuncParamJson) 135 | return E_FAIL; 136 | 137 | CString strJSFuncName =lpwsJSFuncName; 138 | CString strJSFuncParamJson = lpwsJSFuncParamJson; 139 | 140 | { 141 | strJSFuncName = MakeSafeJSString(lpwsJSFuncName); 142 | strJSFuncParamJson = MakeSafeJSString(lpwsJSFuncParamJson); 143 | } 144 | 145 | CString str; 146 | str.Format(L"comm_type_get('%s', '%s')", strJSFuncName, strJSFuncParamJson); 147 | LOGPRINTTIMESTAMP(L"CCef3WebWindow::CallJSCommonFunc %s", (LPCTSTR)str); 148 | return CallJS(str); 149 | } 150 | 151 | HRESULT CCef3WebUI::CallJS(LPCWSTR lpwsJS) 152 | { 153 | if(NULL == lpwsJS) 154 | return E_INVALIDARG; 155 | 156 | if(m_spCefWebBrowser) 157 | return m_spCefWebBrowser->CallJS(lpwsJS); 158 | return E_FAIL; 159 | } 160 | 161 | HRESULT CCef3WebUI::CallJS2(ICefStringArray* lpJS) 162 | { 163 | LOGPRINTTIMESTAMP(L"CCef3WebWindow::[%#X]CallJS2()", (DWORD_PTR)this); 164 | CComQIPtr spWB2 = m_spCefWebBrowser; 165 | if(!spWB2) 166 | return E_FAIL; 167 | 168 | return spWB2->CallJS2(lpJS); 169 | } 170 | 171 | HRESULT CCef3WebUI::SelectAll() 172 | { 173 | CComQIPtr spWB2 = m_spCefWebBrowser; 174 | if(!spWB2) 175 | return E_FAIL; 176 | 177 | return spWB2->SelectAll(); 178 | } 179 | 180 | HRESULT CCef3WebUI::CopySelect() 181 | { 182 | CComQIPtr spWB2 = m_spCefWebBrowser; 183 | if(!spWB2) 184 | return E_FAIL; 185 | 186 | return spWB2->CopySelect(); 187 | } 188 | 189 | HRESULT CCef3WebUI::Stop() 190 | { 191 | if (!m_spCefWebBrowser) 192 | return E_FAIL; 193 | return m_spCefWebBrowser->Stop(); 194 | } 195 | 196 | HRESULT CCef3WebUI::LogError(LPCWSTR lpwsId, LPCWSTR lpwsContent, LPCWSTR lpwsError) 197 | { 198 | if (!m_spCefWebBrowser) 199 | return E_FAIL; 200 | return m_spCefWebBrowser->LogError(lpwsId, lpwsContent, lpwsError); 201 | } 202 | 203 | STDMETHODIMP CCef3WebUI::OnBrowserCreated(LPCWSTR lpwsFlag) 204 | { 205 | LOGPRINTTIMESTAMP(L"CCef3WebWindow::[%#X]OnBrowserCreated(%s)", (DWORD_PTR)this, lpwsFlag?lpwsFlag:L"NOFLAG"); 206 | CComQIPtr spWB2 = m_spCefWebBrowser; 207 | if(spWB2) 208 | m_hBrowerWnd = spWB2->GetBrowserWindow(); 209 | 210 | if (m_pCef3Callback ) 211 | { 212 | m_pCef3Callback->OnBrowserCreated(this); 213 | } 214 | m_nTimeCreate = ::GetTickCount(); 215 | NotifyCreated(); 216 | return S_OK; 217 | } 218 | 219 | STDMETHODIMP CCef3WebUI::OnLoadError(LPCWSTR lpwsUrl, BOOL bMain, int nError) 220 | { 221 | if (!bMain) 222 | return S_OK; 223 | 224 | LOGPRINTTIMESTAMP(L"CCef3WebWindow::[%#X]OnLoadError(%d, %s)", (DWORD_PTR)this, nError, lpwsUrl?lpwsUrl:L"NOURL"); 225 | if (m_pCef3Callback ) 226 | { 227 | m_pCef3Callback->OnLoadError(nError, this); 228 | } 229 | return S_OK; 230 | } 231 | 232 | STDMETHODIMP CCef3WebUI::OnJSCallCPlus(LPCWSTR lpwsUrl, LPCWSTR lpwsId, LPCWSTR lpwsContent) 233 | { 234 | if (lpwsUrl == NULL || lpwsId == NULL || lpwsContent == NULL) 235 | { 236 | return S_FALSE; 237 | } 238 | LOGPRINTTIMESTAMP(L"CCef3WebUI[%s]::OnJSCallCPlus(%s, %s)[%#X][%s]", GetClass(), lpwsId, lpwsContent, this, lpwsUrl); 239 | if (m_pCef3Callback ) 240 | { 241 | m_pCef3Callback->OnJSCallCPlus(lpwsId, lpwsContent, this); 242 | } 243 | return S_OK; 244 | } 245 | 246 | STDMETHODIMP CCef3WebUI::OnLoadHtmlSize(LPCWSTR lpwsUrl, LONGLONG llSize) 247 | { 248 | m_nLoadSize = llSize; 249 | return S_OK; 250 | } 251 | 252 | STDMETHODIMP CCef3WebUI::OnSnapShot(IRingBuffer* spBuffer, int nWidth, int nHeight) 253 | { 254 | if (spBuffer) 255 | { 256 | CComPtr spRingBuffer; 257 | spRingBuffer.Attach(spBuffer); 258 | } 259 | return S_OK; 260 | } 261 | 262 | STDMETHODIMP CCef3WebUI::OnBrowserClosed(int) 263 | { 264 | if (m_pCef3Callback) 265 | { 266 | m_pCef3Callback->OnBrowserClosed(); 267 | } 268 | NotifyClosed(); 269 | return S_OK; 270 | } 271 | 272 | STDMETHODIMP CCef3WebUI::OnRenderProcessTerminated(LPCWSTR lpwsUrl, int nStatus, int nReserved) 273 | { 274 | if (m_pCef3Callback) 275 | { 276 | m_pCef3Callback->OnRenderProcessTerminated(lpwsUrl, nStatus); 277 | } 278 | return S_OK; 279 | } 280 | 281 | 282 | STDMETHODIMP CCef3WebUI::OnTitleChange(LPCWSTR lpwsTitle) 283 | { 284 | if (m_pCef3Callback) 285 | { 286 | m_pCef3Callback->OnTitleChange(lpwsTitle, this ); 287 | } 288 | return S_OK; 289 | } 290 | 291 | STDMETHODIMP CCef3WebUI::OnAddressChange(LPCWSTR lpwsaddress) 292 | { 293 | if (m_pCef3Callback) 294 | { 295 | m_pCef3Callback->OnAddressChange(lpwsaddress, this); 296 | } 297 | return S_OK; 298 | } 299 | 300 | STDMETHODIMP CCef3WebUI::OnGetCookie(LPCWSTR lpcookie) 301 | { 302 | if (m_pCef3Callback) 303 | { 304 | m_pCef3Callback->OnCookie(lpcookie, this); 305 | } 306 | 307 | return S_OK; 308 | } 309 | 310 | STDMETHODIMP CCef3WebUI::OnLoadingStateChange(bool bisLoading, bool isgoforure, bool isgoback) 311 | { 312 | if (m_pCef3Callback) 313 | { 314 | m_pCef3Callback->OnLoadingStateChange(this, bisLoading, isgoback, isgoforure); 315 | } 316 | 317 | return S_OK; 318 | } 319 | 320 | STDMETHODIMP CCef3WebUI::OnLoadEnd(LPCWSTR lpwsUrl, BOOL bMain) 321 | { 322 | if (!bMain) 323 | return S_OK; 324 | 325 | LOGPRINTTIMESTAMP(L"CCef3WebWindow::[%#X]OnLoadEnd(%s)", (DWORD_PTR)this, lpwsUrl?lpwsUrl:L"NOURL"); 326 | 327 | if (m_pCef3Callback ) 328 | { 329 | m_pCef3Callback->OnLoadEnd(this); 330 | } 331 | return S_OK; 332 | } 333 | 334 | HRESULT CCef3WebUI::CreateCEFStrignArray(ICefStringArray** lppArr) 335 | { 336 | //CComPtr spModule; 337 | //HRESULT hr = g_ACTalkApp.GetService(SID_ServiceModule, &spModule); 338 | //if(!spModule) 339 | // return hr; 340 | 341 | //CComPtr spCEFStrArray; 342 | //hr = spModule->GetObject(MODULE_ID_ACCEF, CLSID_CefStringArray, __uuidof(ICefStringArray), (LPVOID*)&spCEFStrArray); 343 | //if(!spCEFStrArray) 344 | // return hr; 345 | 346 | //return spCEFStrArray.QueryInterface(lppArr); 347 | return S_OK; 348 | } 349 | 350 | HRESULT CCef3WebUI::InvalidateBrowserWndRect(LPRECT lprc, BOOL bRedraw) 351 | { 352 | if(m_hBrowerWnd && ::IsWindow(m_hBrowerWnd)) 353 | { 354 | ::InvalidateRect(m_hBrowerWnd, lprc, bRedraw); 355 | ::UpdateWindow(m_hBrowerWnd); 356 | } 357 | return S_OK; 358 | } 359 | }//namespace 360 | -------------------------------------------------------------------------------- /UICef3Web.h: -------------------------------------------------------------------------------- 1 | /************************************************************************/ 2 | /* Cef3 UI Control */ */ 3 | /************************************************************************/ 4 | #pragma once 5 | #include "CefWndWrapManager.h" 6 | namespace DuiLib 7 | { 8 | class CCef3CallBack 9 | { 10 | public: 11 | virtual void OnBrowserCreated(void* ThisUI)PURE; // 创建完成,可以navigate 12 | virtual void OnLoadEnd(void* ThisUI)PURE; // Navigate完成 js上下文就绪,可以执行js代码 13 | virtual void OnLoadError(int nError, void* ThisUI)PURE; // Navigate错误 14 | virtual void OnJSCallCPlus(LPCWSTR lpwsId, LPCWSTR lpwsContent, void* ThisUI)PURE; // JS回调接口 15 | virtual void OnBrowserClosed()PURE; 16 | virtual void OnRenderProcessTerminated(LPCWSTR lpwsUrl, int nStatus) PURE; 17 | virtual void OnTitleChange(LPCWSTR lpTitle, void* ThisUI)PURE; 18 | virtual void OnAddressChange(LPCWSTR lpwsaddress, void* ThisUI)PURE; 19 | virtual void OnCookie(LPCWSTR cookie, void* ThisUI)PURE; 20 | virtual void OnLoadingStateChange(void* ThisUI, bool bisLoading, bool isgoback, bool isgoforure)PURE; 21 | }; 22 | 23 | class CCef3WebUI 24 | : public CCefUIBase 25 | { 26 | public: 27 | CCef3WebUI(void); 28 | virtual ~CCef3WebUI(void); 29 | 30 | public://DUILIB 31 | virtual LPCTSTR GetClass() const; 32 | virtual LPVOID GetInterface(LPCTSTR pstrName); 33 | virtual void SetPos(RECT rc, bool bNeedInvalidate = true); 34 | virtual void SetVisible(bool bVisible); 35 | virtual void SetInternVisible(bool bVisible = true); 36 | 37 | public: //IBrowserEvent 38 | STDMETHOD(OnBrowserCreated)(LPCWSTR lpwsFlag); 39 | STDMETHOD(OnLoadEnd)(LPCWSTR lpwsUrl, BOOL bMain); 40 | STDMETHOD(OnLoadError)(LPCWSTR lpwsUrl, BOOL bMain, int nError); 41 | STDMETHOD(OnJSCallCPlus)(LPCWSTR lpwsUrl, LPCWSTR lpwsId, LPCWSTR lpwsContent); 42 | STDMETHOD(OnLoadHtmlSize)(LPCWSTR lpwsUrl, LONGLONG llSize); 43 | STDMETHOD(OnSnapShot)(IRingBuffer* spBuffer, int nWidth, int nHeight); 44 | STDMETHOD(OnBrowserClosed)(int); 45 | STDMETHOD(OnRenderProcessTerminated)(LPCWSTR lpwsUrl, int nStatus, int nReserved); 46 | STDMETHOD(OnTitleChange)(LPCWSTR lpwsTitle); 47 | STDMETHOD(OnAddressChange)(LPCWSTR lpwsaddress); 48 | STDMETHOD(OnGetCookie)(LPCWSTR lpwsTitle); 49 | STDMETHOD(OnLoadingStateChange)(bool bisLoading, bool isgoforure, bool isgoback); 50 | 51 | public: 52 | void SetCef3CallBack(CCef3CallBack* pCallBack); 53 | // virtual bool CreateBrowser(LPCTSTR szName=NULL, LPRECT rcBrowser = NULL)override; 54 | // virtual void CloseBrowser() override; 55 | const HWND GetBrowserHWND() const; 56 | //void DestroyBrowser(); 57 | 58 | void OpenURL(LPCWSTR lpUrl, BOOL bIgnore404 = TRUE); 59 | void Reload(); 60 | 61 | void GoBack(); 62 | void GoForward(); 63 | 64 | HRESULT CallJSCommonFunc(LPCWSTR lpwsJSFuncName, LPCWSTR lpwsJSFuncParamJson); 65 | HRESULT CallJS(LPCWSTR lpwsJS); 66 | HRESULT CallJS2(ICefStringArray* lpJS); 67 | HRESULT SelectAll(); 68 | HRESULT CopySelect(); 69 | HRESULT InvalidateBrowserWndRect(LPRECT lprc, BOOL bRedraw); 70 | HRESULT Stop(); 71 | HRESULT LogError(LPCWSTR lpwsId, LPCWSTR lpwsContent, LPCWSTR lpwsError); 72 | 73 | public: 74 | CCef3CallBack* m_pCef3Callback; 75 | 76 | public: 77 | static HRESULT CreateCEFStrignArray(ICefStringArray** lppArr); 78 | 79 | }; 80 | } 81 | -------------------------------------------------------------------------------- /UIImageAnimate.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UIImageAnimate.h" 3 | 4 | CImageAnimateUI::CImageAnimateUI() 5 | { 6 | m_nFrameIndex = 0; 7 | m_nFrameCount = 1; 8 | m_nFrameTime = 1; 9 | m_bRepeatMode = FALSE; 10 | } 11 | 12 | CImageAnimateUI::~CImageAnimateUI() 13 | { 14 | 15 | } 16 | 17 | void CImageAnimateUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) 18 | { 19 | if( _tcsicmp(pstrName, _T("framecount")) == 0 ) { 20 | m_nFrameCount = _ttoi(pstrValue); 21 | } 22 | else if( _tcsicmp(pstrName, _T("RepeatMode")) == 0 ) { 23 | m_bRepeatMode = (_tcscmp(pstrValue, _T("true")) == 0); 24 | } 25 | else if( _tcsicmp(pstrName, _T("frametime")) == 0 ) { 26 | m_nFrameTime = _ttoi(pstrValue); 27 | } 28 | else 29 | CButtonUI::SetAttribute(pstrName, pstrValue); 30 | } 31 | 32 | void CImageAnimateUI::PaintBkImage(HDC hDC) 33 | { 34 | if( m_sBkImage.IsEmpty() ) return; 35 | 36 | const TImageInfo* data = m_pManager->GetImageEx((LPCTSTR)m_sBkImage, NULL, 0); 37 | if(data) 38 | { 39 | int nFrameWidth = data->nX/m_nFrameCount; 40 | 41 | CString strSrc; 42 | strSrc.Format(L"%d,%d,%d,%d", nFrameWidth*m_nFrameIndex,0,nFrameWidth*(m_nFrameIndex+1),data->nY); 43 | 44 | CString sImg = _T("file='"); 45 | sImg += m_sBkImage; 46 | sImg += L"' source='"; 47 | sImg += strSrc; 48 | sImg += L"'"; 49 | DrawImage(hDC, (LPCTSTR)sImg); 50 | } 51 | } 52 | 53 | void CImageAnimateUI::Start() 54 | { 55 | m_nFrameIndex = 0; 56 | Invalidate(); 57 | 58 | m_pManager->SetTimer(this, ANIMATE_TIMERID, m_nFrameTime); 59 | } 60 | 61 | void CImageAnimateUI::Stop() 62 | { 63 | m_pManager->KillTimer(this, ANIMATE_TIMERID); 64 | } 65 | 66 | void CImageAnimateUI::DoEvent(TEventUI& event) 67 | { 68 | if( event.Type == UIEVENT_TIMER ) 69 | OnTimer( (UINT_PTR)event.wParam ); 70 | CButtonUI::DoEvent(event); 71 | } 72 | 73 | void CImageAnimateUI::OnTimer( UINT_PTR idEvent ) 74 | { 75 | if( ANIMATE_TIMERID == idEvent ) 76 | { 77 | m_nFrameIndex++; 78 | if( m_nFrameIndex >= m_nFrameCount ) 79 | { 80 | m_nFrameIndex = 0; 81 | if( !m_bRepeatMode ) 82 | { 83 | m_pManager->KillTimer(this, ANIMATE_TIMERID); 84 | m_pManager->SendNotify(this, DUI_NOTIFY_ANIMATEFINISH); 85 | } 86 | } 87 | Invalidate(); 88 | } 89 | } -------------------------------------------------------------------------------- /UIImageAnimate.h: -------------------------------------------------------------------------------- 1 | #ifndef UIImageAnimate_h__ 2 | #define UIImageAnimate_h__ 3 | 4 | #define DUI_NOTIFY_ANIMATEFINISH L"AnimateFinish" 5 | 6 | class CImageAnimateUI : public CButtonUI 7 | { 8 | public: 9 | enum 10 | { 11 | ANIMATE_TIMERID = 1000, 12 | }; 13 | 14 | CImageAnimateUI(); 15 | ~CImageAnimateUI(); 16 | 17 | virtual void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) override; 18 | virtual void PaintBkImage(HDC hDC) override; 19 | virtual void DoEvent(TEventUI& event) override; 20 | 21 | void Start(); 22 | void Stop(); 23 | 24 | protected: 25 | void OnTimer( UINT_PTR idEvent ); 26 | 27 | protected: 28 | int m_nFrameIndex; 29 | int m_nFrameCount; 30 | int m_nFrameTime; 31 | bool m_bRepeatMode; 32 | }; 33 | 34 | #endif // UIImageAnimate_h__ -------------------------------------------------------------------------------- /UIListItemCust.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "UIListItemCust.h" 3 | 4 | 5 | CUIListItemCust::CUIListItemCust() 6 | { 7 | 8 | } 9 | 10 | 11 | LPCTSTR CUIListItemCust::GetClass() const 12 | { 13 | return _T("UIListItemCust"); 14 | } 15 | 16 | LPVOID CUIListItemCust::GetInterface(LPCTSTR pstrName) 17 | { 18 | if (_tcscmp(pstrName, L"ListItemWeijian") == 0) return static_cast(this); 19 | return CListLabelElementUI::GetInterface(pstrName); 20 | } 21 | 22 | void CUIListItemCust::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) 23 | { 24 | if (_tcsicmp(pstrName, _T("iconimage")) == 0) 25 | { 26 | SetIconImge(pstrValue); 27 | } 28 | if (_tcsicmp(pstrName, _T("imagepath")) == 0) { 29 | TImageInfo * pInfo = CRenderEngine::LoadImage(pstrValue); 30 | if (pInfo) 31 | { 32 | if (m_pImagePathBitmap) 33 | { 34 | delete m_pImagePathBitmap; 35 | m_pImagePathBitmap = NULL; 36 | } 37 | m_pImagePathBitmap = Gdiplus::Bitmap::FromHBITMAP(pInfo->hBitmap, NULL); 38 | if (pInfo->hBitmap) 39 | { 40 | DeleteObject(pInfo->hBitmap); 41 | } 42 | delete pInfo; 43 | } 44 | Invalidate(); 45 | } 46 | else 47 | CListLabelElementUI::SetAttribute(pstrName, pstrValue); 48 | } 49 | 50 | // void CUIListItemCust::PaintBkImage(HDC hDC) 51 | // { 52 | // CListLabelElementUI::PaintBkImage(hDC); 53 | // Gdiplus::Graphics graphics(hDC); 54 | // if (m_pImagePathBitmap) 55 | // { 56 | // Gdiplus::TextureBrush tBrush2(m_pImagePathBitmap); 57 | // Gdiplus::REAL cx = (Gdiplus::REAL)(m_rcItem.right - m_rcItem.left); 58 | // Gdiplus::REAL cy = (Gdiplus::REAL)(m_rcItem.bottom - m_rcItem.top); 59 | // Gdiplus::RectF rc((Gdiplus::REAL)m_rcItem.left, (Gdiplus::REAL)m_rcItem.top, cx, cy); 60 | // graphics.SetClip(rc); 61 | // tBrush2.SetWrapMode(Gdiplus::WrapModeTile); 62 | // graphics.SetSmoothingMode(Gdiplus::SmoothingMode::SmoothingModeAntiAlias); 63 | // tBrush2.TranslateTransform(rc.GetLeft(), rc.GetTop()); 64 | // tBrush2.ScaleTransform(cx / m_pImagePathBitmap->GetWidth(), cy / m_pImagePathBitmap->GetHeight()); 65 | // graphics.FillEllipse(&tBrush2, rc); 66 | // } 67 | // } 68 | 69 | void CUIListItemCust::DrawItemText(HDC hDC, const RECT& rcItem) 70 | { 71 | RECT rc; 72 | rc.left = m_rcItem.left + 20; 73 | rc.top = m_rcItem.top + 5; 74 | rc.right = rc.left + 35; 75 | rc.bottom = rc.top + 35; 76 | 77 | CRenderEngine::DrawImageString(hDC, m_pManager, rc, m_rcPaint, m_sSelIconimge, L""); 78 | 79 | CDuiString sText = GetText(); 80 | if (sText.IsEmpty()) return; 81 | 82 | if (m_pOwner == NULL) return; 83 | TListInfoUI* pInfo = m_pOwner->GetListInfo(); 84 | DWORD iTextColor = pInfo->dwTextColor; 85 | if ((m_uButtonState & UISTATE_HOT) != 0) { 86 | iTextColor = pInfo->dwHotTextColor; 87 | } 88 | if (IsSelected()) { 89 | iTextColor = pInfo->dwSelectedTextColor; 90 | if (!m_sSelText.IsEmpty()) sText = m_sSelText; 91 | } 92 | if (!IsEnabled()) { 93 | iTextColor = pInfo->dwDisabledTextColor; 94 | } 95 | int nLinks = 0; 96 | RECT rcText = rcItem; 97 | rcText.left += pInfo->rcTextPadding.left; 98 | rcText.right -= pInfo->rcTextPadding.right; 99 | rcText.top += pInfo->rcTextPadding.top; 100 | rcText.bottom -= pInfo->rcTextPadding.bottom; 101 | 102 | rcText.left += rc.right + 18; 103 | 104 | if (pInfo->bShowHtml) 105 | CRenderEngine::DrawHtmlText(hDC, m_pManager, rcText, sText, iTextColor, \ 106 | NULL, NULL, nLinks, DT_SINGLELINE | pInfo->uTextStyle); 107 | else 108 | CRenderEngine::DrawText(hDC, m_pManager, rcText, sText, iTextColor, \ 109 | pInfo->nFont, DT_SINGLELINE | pInfo->uTextStyle); 110 | } 111 | // 112 | // void CUIListItemCust::PaintBkImage(HDC hDC) 113 | // { 114 | // CListLabelElementUI::PaintBkImage(hDC); 115 | // 116 | // //draw icon 117 | // RECT rc; 118 | // rc.left = m_rcItem.left + 20; 119 | // rc.top = m_rcItem.top; 120 | // rc.right = rc.left + 35; 121 | // rc.bottom = rc.top + 35; 122 | // // CRenderEngine::DrawImageString(hDC, m_pManager, rc, m_rcPaint, m_sSelIconimge, L""); 123 | // 124 | // Gdiplus::Graphics graphics(hDC); 125 | // if (m_pImagePathBitmap) 126 | // { 127 | // Gdiplus::TextureBrush tBrush2(m_pImagePathBitmap); 128 | // // Gdiplus::REAL cx = (Gdiplus::REAL)(m_rcItem.right - m_rcItem.left); 129 | // // Gdiplus::REAL cy = (Gdiplus::REAL)(m_rcItem.bottom - m_rcItem.top); 130 | // // Gdiplus::RectF rc((Gdiplus::REAL)m_rcItem.left, (Gdiplus::REAL)m_rcItem.top, cx, cy); 131 | // // 132 | // Gdiplus::REAL cx = (Gdiplus::REAL)(rc.right - rc.left); 133 | // Gdiplus::REAL cy = (Gdiplus::REAL)(rc.bottom - rc.top); 134 | // Gdiplus::RectF rc((Gdiplus::REAL)rc.left, (Gdiplus::REAL)rc.top, cx, cy); 135 | // 136 | // graphics.SetClip(rc); 137 | // tBrush2.SetWrapMode(Gdiplus::WrapModeTile); 138 | // graphics.SetSmoothingMode(Gdiplus::SmoothingMode::SmoothingModeAntiAlias); 139 | // tBrush2.TranslateTransform(rc.GetLeft(), rc.GetTop()); 140 | // tBrush2.ScaleTransform(cx / m_pImagePathBitmap->GetWidth(), cy / m_pImagePathBitmap->GetHeight()); 141 | // graphics.FillEllipse(&tBrush2, rc); 142 | // } 143 | // } 144 | 145 | LPCTSTR CUIListItemCust::GetIconImge() 146 | { 147 | return m_sSelIconimge; 148 | } 149 | 150 | void CUIListItemCust::SetIconImge(LPCTSTR pstrIcon) 151 | { 152 | m_sSelIconimge = pstrIcon; 153 | } 154 | -------------------------------------------------------------------------------- /UIListItemCust.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class CUIListItemCust : public CListLabelElementUI 3 | { 4 | public: 5 | CUIListItemCust(); 6 | 7 | LPCTSTR GetClass() const; 8 | LPVOID GetInterface(LPCTSTR pstrName); 9 | 10 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 11 | 12 | void DrawItemText(HDC hDC, const RECT& rcItem); 13 | 14 | //void PaintBkImage(HDC hDC); 15 | 16 | LPCTSTR GetIconImge(); 17 | void SetIconImge(LPCTSTR pstrIcon); 18 | 19 | private: 20 | CDuiString m_sSelIconimge; 21 | CDuiString m_sSelText; 22 | 23 | protected: 24 | CDuiString m_sImagePath; 25 | Gdiplus::Bitmap* m_pImagePathBitmap; 26 | }; -------------------------------------------------------------------------------- /UIVerticalLayoutBK.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "UIVerticalLayoutBK.h" 3 | 4 | CVerticalLayoutBKUI::CVerticalLayoutBKUI(void) 5 | { 6 | } 7 | 8 | CVerticalLayoutBKUI::~CVerticalLayoutBKUI(void) 9 | { 10 | } 11 | 12 | LPCTSTR CVerticalLayoutBKUI::GetClass() const 13 | { 14 | return _T("VerticalLayoutBKUI"); 15 | } 16 | 17 | LPVOID CVerticalLayoutBKUI::GetInterface(LPCTSTR pstrName) 18 | { 19 | if (_tcscmp(pstrName, _T("VerticalLayoutBKUI")) == 0) 20 | return static_cast(this); 21 | 22 | return CVerticalLayoutUI::GetInterface(pstrName); 23 | } 24 | 25 | void CVerticalLayoutBKUI::PaintBkImage(HDC hDC) 26 | { 27 | if (m_sBkImage.IsEmpty()) return; 28 | const TImageInfo* data = NULL; 29 | 30 | data = m_pManager->GetImageEx((LPCTSTR)m_sBkImage, (LPCTSTR)NULL, 0); 31 | 32 | if (!data) return; 33 | RECT rcSource = {0}; 34 | double fScale = (m_rcItem.right - m_rcItem.left)*1.0 / (m_rcItem.bottom - m_rcItem.top); 35 | if (data->nX*1.0/data->nY >fScale) 36 | { 37 | rcSource.bottom = data->nY; 38 | rcSource.right = (long)(data->nY*fScale); 39 | } 40 | else 41 | { 42 | rcSource.right = data->nX; 43 | rcSource.bottom = data->nY; 44 | rcSource.top = (long)(rcSource.bottom - data->nX / fScale); 45 | } 46 | RECT rcCorner = { 0,0,0,0 }; 47 | CRenderEngine::DrawImage(hDC, data->hBitmap, m_rcItem, m_rcPaint, rcSource, rcCorner, false); 48 | } 49 | -------------------------------------------------------------------------------- /UIVerticalLayoutBK.h: -------------------------------------------------------------------------------- 1 | /********************************************** 2 | * @file : CUIGdiVideo.h for class room 3 | * @description : 4 | * @data : 2018.12.3 5 | * @author : liuyanbao 6 | ***********************************************/ 7 | 8 | #pragma once 9 | 10 | class CVerticalLayoutBKUI : public CVerticalLayoutUI 11 | { 12 | public: 13 | CVerticalLayoutBKUI(void); 14 | virtual ~CVerticalLayoutBKUI(void); 15 | 16 | protected: 17 | // ---------- CControlUI ---------- 18 | LPCTSTR GetClass() const; 19 | LPVOID GetInterface(LPCTSTR pstrName); 20 | 21 | virtual void PaintBkImage(HDC hDC); 22 | }; 23 | -------------------------------------------------------------------------------- /UIVideo.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "UIVideo.h" 3 | namespace DuiLib 4 | { 5 | 6 | #define HIDE_HANDUP_TIMERID 1000 7 | 8 | CVideoUI::CVideoUI() 9 | { 10 | m_pVideoWnd = NULL; 11 | // m_pNameWnd = NULL; 12 | 13 | // m_pSignalWnd = NULL; 14 | // m_pMicWnd = NULL; 15 | } 16 | 17 | CVideoUI::~CVideoUI(void) 18 | { 19 | } 20 | 21 | LPCTSTR CVideoUI::GetClass() const 22 | { 23 | return _T("VideoUI"); 24 | } 25 | 26 | LPVOID CVideoUI::GetInterface( LPCTSTR pstrName ) 27 | { 28 | if( _tcscmp(pstrName, _T("VideoUI")) == 0 ) 29 | return static_cast(this); 30 | 31 | return CControlUI::GetInterface(pstrName); 32 | } 33 | 34 | void CVideoUI::SetVisible(bool bVisible) 35 | { 36 | CControlUI::SetVisible(bVisible); 37 | } 38 | 39 | void CVideoUI::SetInternVisible(bool bVisible) 40 | { 41 | CControlUI::SetInternVisible(bVisible); 42 | } 43 | 44 | void CVideoUI::Init() 45 | { 46 | __super::Init(); 47 | if (IsVisible() == true) 48 | { 49 | CreateOwnWindow(); 50 | } 51 | } 52 | 53 | void CVideoUI::DoInit() 54 | { 55 | __super::DoInit(); 56 | } 57 | 58 | void CVideoUI::SetPos( RECT rc, bool bNeedInvalidate /*= true*/ ) 59 | { 60 | __super::SetPos(rc, bNeedInvalidate); 61 | WindowPosChanged(); 62 | } 63 | 64 | void CVideoUI::SetAttribute( LPCTSTR pstrName, LPCTSTR pstrValue ) 65 | { 66 | __super::SetAttribute(pstrName, pstrValue); 67 | } 68 | 69 | void CVideoUI::CreateOwnWindow() 70 | { 71 | if (NULL == m_pVideoWnd) 72 | { 73 | m_pVideoWnd = new CVideoWnd; 74 | m_pVideoWnd->Create(m_pManager->GetPaintWindow(), L"", UI_WNDSTYLE_CHILD, 0L); 75 | //m_pVideoWnd->SetBkColor(this->GetBkColor()); 76 | if (GetUserData().Compare(L"teacher") == 0) 77 | { 78 | m_pVideoWnd->SetImageHorheiandwidth(125, 105); 79 | } 80 | else if (GetUserData().Compare(L"studentme") == 0) 81 | { 82 | m_pVideoWnd->SetImageHorheiandwidth(95, 79); 83 | } 84 | else if (GetUserData().Compare(L"studentone") == 0) 85 | { 86 | m_pVideoWnd->SetImageHorheiandwidth(98, 80); 87 | } 88 | else if (GetUserData().Compare(L"studenttwo") == 0) 89 | { 90 | m_pVideoWnd->SetImageHorheiandwidth(97, 79); 91 | } 92 | else if (GetUserData().Compare(L"studenttree") == 0) 93 | { 94 | m_pVideoWnd->SetImageHorheiandwidth(94, 80); 95 | } 96 | 97 | m_pVideoWnd->SetDefaultCtrolBkImage(this->GetBkImage()); 98 | } 99 | 100 | } 101 | 102 | CVideoWnd* CVideoUI::GetOwnWindow() 103 | { 104 | return m_pVideoWnd; 105 | } 106 | 107 | void CVideoUI::WindowPosChanged() 108 | { 109 | CRect rcwindow = GetPos(); 110 | if (rcwindow.IsRectEmpty()) 111 | { 112 | return; 113 | } 114 | 115 | if (m_pVideoWnd) 116 | { 117 | ::SetWindowPos(m_pVideoWnd->GetHWND(), HWND_TOP, rcwindow.left, rcwindow.top, rcwindow.Width(), rcwindow.Height(), SWP_NOACTIVATE); 118 | } 119 | 120 | } 121 | 122 | }//namespace 123 | -------------------------------------------------------------------------------- /UIVideo.h: -------------------------------------------------------------------------------- 1 | /************************************************************************/ 2 | /* Video UI Control */ */ 3 | /************************************************************************/ 4 | #pragma once 5 | #include "VideoWnd.h" 6 | namespace DuiLib 7 | { 8 | class CVideoUI : public CHorizontalLayoutUI 9 | { 10 | public: 11 | CVideoUI(); 12 | virtual ~CVideoUI(void); 13 | 14 | void SetAttribute( LPCTSTR pstrName, LPCTSTR pstrValue ); 15 | 16 | public://DUILIB 17 | virtual LPCTSTR GetClass() const; 18 | virtual LPVOID GetInterface(LPCTSTR pstrName); 19 | virtual void SetPos(RECT rc, bool bNeedInvalidate = true); 20 | virtual void SetVisible(bool bVisible); 21 | virtual void SetInternVisible(bool bVisible = true); 22 | 23 | virtual void Init(); 24 | virtual void DoInit(); 25 | 26 | void CreateOwnWindow(); 27 | 28 | CVideoWnd* GetOwnWindow(); 29 | 30 | void WindowPosChanged(); 31 | 32 | private: 33 | 34 | CVideoWnd* m_pVideoWnd; 35 | 36 | }; 37 | }; 38 | 39 | -------------------------------------------------------------------------------- /UserDatMgr.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "UserDataMgr.h" 3 | -------------------------------------------------------------------------------- /UserDataMgr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | -------------------------------------------------------------------------------- /VideoWnd.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "VideoWnd.h" 3 | #include "Utils.h" 4 | 5 | UINT CVideoWnd::s_uMsgStateChanged = RegisterWindowMessage(L"VideoWndStateChanged_RegiterMessageString"); 6 | 7 | 8 | CVideoWnd::CVideoWnd() 9 | { 10 | m_hParentWnd=NULL; 11 | m_nNotifyEnterMsgId=0; 12 | m_nNotifyLeaveMsgId=0; 13 | m_nNotifyLButtonDownMsgId = 0; 14 | m_bMouseTracking=FALSE; 15 | m_hNotifyWnd = NULL; 16 | 17 | m_pRootVL = NULL; 18 | m_pImgHL = NULL; 19 | m_pTitleImg = NULL; 20 | m_pTileLab = NULL; 21 | 22 | m_pUILabelDefaultBkImage = NULL; 23 | m_pHorUI = NULL; 24 | } 25 | 26 | CVideoWnd::~CVideoWnd() 27 | { 28 | 29 | } 30 | 31 | void CVideoWnd::SetBkImage(LPCTSTR lpszBkImage) 32 | { 33 | utils::SetBkImage(m_pRootVL, lpszBkImage); 34 | } 35 | 36 | void CVideoWnd::SetBkColor(DWORD dwBkColor) 37 | { 38 | utils::SetBkColor(m_pRootVL, dwBkColor); 39 | } 40 | 41 | void CVideoWnd::SetBkText(LPCTSTR lpszText) 42 | { 43 | utils::SetText(m_pTileLab, lpszText); 44 | if(lpszText && lstrlen(lpszText)) 45 | utils::SetVisible(m_pTileLab, true); 46 | else 47 | utils::SetVisible(m_pTileLab, false); 48 | } 49 | 50 | void CVideoWnd::SetBkIcon(LPCTSTR lpszBkIcon) 51 | { 52 | if (!lpszBkIcon) 53 | { 54 | utils::SetVisible(m_pTitleImg, false); 55 | return; 56 | } 57 | 58 | const TImageInfo* data = m_PaintManager.GetImageEx((LPCTSTR)lpszBkIcon, NULL, 0); 59 | if (data && m_pTitleImg && m_pImgHL) 60 | { 61 | m_pTitleImg->SetVisible(true); 62 | m_pTitleImg->SetFixedWidth(data->nX); 63 | m_pTitleImg->SetFixedHeight(data->nY); 64 | m_pImgHL->SetFixedHeight(data->nY); 65 | m_pTitleImg->SetBkImage(lpszBkIcon); 66 | } 67 | } 68 | 69 | LPCTSTR CVideoWnd::GetWindowClassName() const 70 | { 71 | return _T("VideoWnd"); 72 | } 73 | 74 | 75 | void CVideoWnd::OnFinalMessage(HWND hWnd) 76 | { 77 | __super::OnFinalMessage(hWnd); 78 | } 79 | 80 | void CVideoWnd::InitWindow() 81 | { 82 | m_pRootVL = static_cast(m_PaintManager.FindControl(L"VRootUI")); 83 | m_pImgHL = static_cast(m_PaintManager.FindControl(L"imgHL")); 84 | m_pTitleImg = static_cast(m_PaintManager.FindControl(L"titleImg")); 85 | m_pTileLab = static_cast(m_PaintManager.FindControl(L"titleLab")); 86 | 87 | m_pUILabelDefaultBkImage = static_cast(m_PaintManager.FindControl(L"DefaultImageBk")); 88 | 89 | m_pHorUI = static_cast(m_PaintManager.FindControl(L"imgHLLLLL")); 90 | } 91 | 92 | LRESULT CVideoWnd::HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) 93 | { 94 | LRESULT lRes = 0; 95 | switch (uMsg) 96 | { 97 | case WM_LBUTTONDOWN: 98 | { 99 | if(m_hParentWnd!=NULL && m_nNotifyLButtonDownMsgId!=0) 100 | ::PostMessage(m_hParentWnd,m_nNotifyLButtonDownMsgId,wParam,lParam); 101 | } 102 | break; 103 | case WM_RBUTTONDOWN: 104 | { 105 | if(m_hParentWnd) 106 | { 107 | ::PostMessage(m_hParentWnd, WM_RBUTTONDOWN, wParam, lParam); 108 | } 109 | } 110 | break; 111 | case WM_WINDOWPOSCHANGED: 112 | { 113 | 114 | } 115 | break; 116 | default: 117 | bHandled=FALSE; 118 | break; 119 | } 120 | 121 | bHandled = FALSE; 122 | return 0; 123 | } 124 | 125 | void CVideoWnd::RefreshWnd() 126 | { 127 | if(IsWindow(m_hWnd)) 128 | { 129 | InvalidateRect(m_hWnd, NULL, TRUE); 130 | } 131 | } 132 | 133 | DuiLib::UILIB_RESOURCETYPE CVideoWnd::GetResourceType() const 134 | { 135 | return UILIB_FILE; 136 | } 137 | 138 | DuiLib::CDuiString CVideoWnd::GetSkinFile() 139 | { 140 | return _T("VideoWnd.xml"); 141 | } 142 | 143 | DuiLib::CDuiString CVideoWnd::GetSkinFolder() 144 | { 145 | return _T("BMSkin\\"); 146 | } 147 | 148 | void CVideoWnd::SetDefaultCtrolBkImage(LPCTSTR lpszBkImage) 149 | { 150 | if (m_pUILabelDefaultBkImage) 151 | { 152 | m_pUILabelDefaultBkImage->SetBkImage(lpszBkImage); 153 | } 154 | } 155 | 156 | void CVideoWnd::SetImageHorheiandwidth(int iheight, int iwidth) 157 | { 158 | if (m_pUILabelDefaultBkImage && m_pHorUI ) 159 | { 160 | m_pUILabelDefaultBkImage->SetFixedWidth(iwidth); 161 | m_pHorUI->SetFixedHeight(iheight); 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /VideoWnd.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CVideoWnd : public WindowImplBase 4 | { 5 | public: 6 | CVideoWnd(); 7 | virtual ~CVideoWnd(); 8 | 9 | void SetKid(BOOL bKid); 10 | void Set1V1(BOOL b1v1); 11 | void SetBkImage(LPCTSTR lpszBkImage); 12 | void SetBkColor(DWORD dwBkColor); 13 | void SetBkText(LPCTSTR lpszText); 14 | void SetBkIcon(LPCTSTR lpszBkIcon); 15 | void SetVideoMode(BOOL bVideo = TRUE); 16 | void SetDefaultCtrolBkImage(LPCTSTR lpszBkImage); 17 | LPCTSTR GetWindowClassName() const; 18 | void OnFinalMessage(HWND hWnd); 19 | 20 | void RefreshWnd(); 21 | BOOL IsVideoMode(); 22 | 23 | void SetImageHorheiandwidth(int iheight, int iwidth ); 24 | 25 | virtual void InitWindow(); 26 | LRESULT HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) override; 27 | 28 | DuiLib::CDuiString GetSkinFolder(); 29 | DuiLib::CDuiString GetSkinFile(); 30 | UILIB_RESOURCETYPE GetResourceType() const; 31 | 32 | static UINT GetStateChangedMessage(){return s_uMsgStateChanged;} 33 | 34 | public: 35 | void SetParentHwnd(HWND hParentWnd,UINT nNotifyEnterMsgId,UINT nNotifyLeaveMsgId, UINT nNotifyLButtonDownMsgId = 0); 36 | void UserEnter(); 37 | void UserLeave(); 38 | 39 | protected: 40 | static UINT s_uMsgStateChanged; 41 | 42 | BOOL m_bMouseTracking; 43 | HWND m_hParentWnd; 44 | UINT m_nNotifyEnterMsgId; 45 | UINT m_nNotifyLeaveMsgId; 46 | UINT m_nNotifyLButtonDownMsgId; 47 | BOOL m_bkid; 48 | 49 | BOOL m_bVideo; 50 | BOOL m_b1v1; 51 | 52 | HWND m_hNotifyWnd; 53 | BOOL m_bUserEntry; 54 | 55 | CVerticalLayoutUI* m_pRootVL; 56 | CHorizontalLayoutUI* m_pImgHL; 57 | CLabelUI* m_pTitleImg; 58 | CLabelUI* m_pTileLab; 59 | 60 | 61 | CLabelUI* m_pUILabelDefaultBkImage; 62 | CHorizontalLayoutUI* m_pHorUI; 63 | 64 | }; 65 | -------------------------------------------------------------------------------- /small.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/small.ico -------------------------------------------------------------------------------- /stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/stdafx.cpp -------------------------------------------------------------------------------- /stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/stdafx.h -------------------------------------------------------------------------------- /targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kwan-Yiu/Live-streaming-app/113df35f6a87a6edf43e91bbc4aedf8d11ee6f42/targetver.h --------------------------------------------------------------------------------