Help Center/ Meeting/ Client SDK Reference/ Windows SDK/ API Reference/ UI Customization/ Making Windows Transparent During Screen Sharing
Updated on 2024-09-13 GMT+08:00

Making Windows Transparent During Screen Sharing

SetTransparentWnd

API Description

This API is used to make windows transparent during screen sharing.

Precautions

  1. Up to four window handles are supported.
  2. This API is an asynchronous API. The return value only indicates whether the API is successfully called. The actual service processing result is returned in the corresponding callback function.

Method Definition

1
HWM_SDK_AGENT_API hwmsdk::HwmErrCode SetTransparentWnd(HWND handle[], unsigned int count);

Callback Function

1
virtual void OnSetTransparentWndResult(hwmsdk::HwmErrCode ret, const char* reason) {};

Parameter Description

Table 1 Parameter description

Parameter

Type

Description

handle

HWND[]

Window handles.

count

unsigned int

Number of window handles.

Table 2 Return value

Type

Description

HwmErrCode

If 0 is returned, the operation is successful. If other values are returned, the operation fails. For details about values returned upon failures, see Common Error Codes.

Sample Code
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* Make windows transparent during screen sharing.
*/
void demoSetTransparentWndDlg::OnBnClickedOk()
{
    CString tempCString;
    m_wndsEdit.GetWindowText(tempCString);
    std::string tempString = CTools::UNICODE2UTF(tempCString.GetString());
    vector<std::string> list = CTools::split(tempString, ';');
    std::string temp;
    int count = list.size();

    int realCount = 0;
    if (count > 0)
    {
        // Apply for the structure memory.
        HWND* handles;
        handles = (HWND*)malloc(sizeof(HWND) * count);
        if (handles == NULL)
        {
            return -1;
        }
        memset(handles, 0, sizeof(HWND)*count);

        HWND* handlesTemp = handles;
        for (int i = 0; i < count; i++)
        {
            temp = list[i];
            *handlesTemp = CTools::str2hwnd(temp);
            handlesTemp++;
            realCount++;
        }
        int ret = hwmsdkagent::SetTransparentWnd(handles, realCount);

        // Release memory space.
        free(handles);
        handles = NULL;
        if (hwmsdk::HWM_COMMON_SUCCESS != ret)
        {
            AfxMessageBox(_T("get error message error"));
            return;
        }
    }
}