Skip to content

Commit ac1bb1c

Browse files
committed
GetScreenCaptureSources
1 parent 98be1cf commit ac1bb1c

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

windows/APIExample/APIExample/Advanced/ScreenShare/AgoraScreenCapture.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ void CAgoraScreenCapture::OnBnClickedButtonStartShare()
345345
return;
346346
HWND hWnd = NULL;
347347
//if (m_cmbScreenCap.GetCurSel() != m_cmbScreenCap.GetCount() - 1)
348-
hWnd = m_listWnd.GetAt(m_listWnd.FindIndex(m_cmbScreenCap.GetCurSel()));
348+
hWnd = (HWND)m_listWnd.GetAt(m_listWnd.FindIndex(m_cmbScreenCap.GetCurSel())).sourceId;
349349
int ret = 0;
350350
m_windowShare = !m_windowShare;
351351
if (m_windowShare)
@@ -420,9 +420,9 @@ void CAgoraScreenCapture::ReFreshWnd()
420420
int index = 0;
421421
//enumerate hwnd to add m_cmbScreenCap.
422422
while (pos != NULL) {
423-
hWnd = m_listWnd.GetNext(pos);
424-
::GetWindowText(hWnd, strName, 255);
425-
m_cmbScreenCap.InsertString(index++, strName);
423+
agora::rtc::ScreenCaptureSourceInfo info = m_listWnd.GetNext(pos);
424+
//::GetWindowText(hWnd, strName, 255);
425+
m_cmbScreenCap.InsertString(index++, utf82cs(info.sourceTitle));
426426
}
427427
//m_cmbScreenCap.InsertString(index++, L"DeskTop");
428428
m_cmbScreenCap.SetCurSel(0);
@@ -609,7 +609,13 @@ BOOL CALLBACK CAgoraScreenCapture::WndEnumProc(HWND hWnd, LPARAM lParam)
609609
int CAgoraScreenCapture::RefreashWndInfo()
610610
{
611611
m_listWnd.RemoveAll();
612-
::EnumWindows(&CAgoraScreenCapture::WndEnumProc, (LPARAM)&m_listWnd);
612+
SIZE sz = { 300, 300 };
613+
agora::rtc::IScreenCaptureSourceList* listCapture = m_rtcEngine->getScreenCaptureSources(sz, sz, false);
614+
for (int i = 0; i < listCapture->getCount(); ++i) {
615+
agora::rtc::ScreenCaptureSourceInfo info = listCapture->getSourceInfo(i);
616+
m_listWnd.AddTail(info);
617+
}
618+
//::EnumWindows(&CAgoraScreenCapture::WndEnumProc, (LPARAM)&m_listWnd);
613619
return static_cast<int>(m_listWnd.GetCount());
614620
}
615621

windows/APIExample/APIExample/Advanced/ScreenShare/AgoraScreenCapture.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class CAgoraScreenCapture : public CDialogEx
151151
DECLARE_MESSAGE_MAP()
152152

153153
CAGVideoWnd m_localVideoWnd;
154-
CList<HWND> m_listWnd;
154+
CList<agora::rtc::ScreenCaptureSourceInfo> m_listWnd;
155155
CScreenCaputreEventHandler m_eventHandler;
156156

157157
IRtcEngine* m_rtcEngine = nullptr;

0 commit comments

Comments
 (0)