共用方式為


GameChatOverlay 類別

定義

代表遊戲聊天重迭。

public ref class GameChatOverlay sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 262144)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class GameChatOverlay final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 262144)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class GameChatOverlay
Public NotInheritable Class GameChatOverlay
繼承
Object Platform::Object IInspectable GameChatOverlay
屬性

Windows 需求

裝置系列
Windows 10 Creators Update (已於 10.0.15063.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v4.0 引進)

範例

此範例示範如何設定遊戲聊天,並將簡訊新增至其中。

#include <winrt/Windows.Gaming.UI.h>
using namespace winrt;
using namespace Windows::Gaming::UI;
...
GameChatOverlay m_gameChatOverlay{nullptr};
...
void ChatSample::SetUpGameChat(GameChatOverlayPosition position)
{
    // Get the default game chat overlay object. Platforms that don't support
    // it will return null.
    m_gameChatOverlay = GameChatOverlay::GetDefault();

    if (m_gameChatOverlay)
    {
        // Position the overlay in the given position.
        m_gameChatOverlay.DesiredPosition(position);
    }
}

// This method typically would be wired to a text entry box in order to send
// text messages.
void ChatSample::SendTextMessage(std::wstring gamertag, std::wstring message)
{
    if (m_gameChatOverlay)
    {
        // Render the text in the overlay.
        m_gameChatOverlay.AddMessage(
            gamertag,
            message,
            GameChatMessageOrigin::Text);
    }
    else
    {
        // The game should render the outgoing message in its own UI.
    }
}
void ChatSample::SetUpGameChat(GameChatOverlayPosition position)
{
    // Get the default game chat overlay object. Platforms that don't support
    // it will return null.
    m_gameChatOverlay = GameChatOverlay::GetDefault();

    if (m_gameChatOverlay)
    {
        // Position the overlay in the given position.
        m_gameChatOverlay->DesiredPosition = position;
    }
}

// This method typically would be wired to a text entry box in order to send
// text messages.
void ChatSample::SendTextMessage(String^ gamertag, String^ message) 
{
    if (m_gameChatOverlay)
    {
        // Render the text in the overlay.
        m_gameChatOverlay->AddMessage(
            gamertag, 
            message, 
            GameChatMessageOrigin::Text);
    }
    else 
    { 
        // The game should render the outgoing message in its own UI.
    } 
}

備註

這個類別提供方法來取得預設遊戲聊天重迭實例、設定重迭所需的位置,並將訊息新增至其中。

屬性

DesiredPosition

遊戲聊天重迭所需的位置。

方法

AddMessage(String, String, GameChatMessageOrigin)

在遊戲聊天重迭中轉譯訊息。

GetDefault()

取得預設遊戲聊天重迭實例。

適用於

另請參閱