0

我正在尝试wxTextCtrl通过从它驱动并自己绘制文本来创建自定义透明,如下所示:

BEGIN_EVENT_TABLE(TextLayer, wxTextCtrl)
    EVT_PAINT(TextLayer::OnPaint)
    EVT_ERASE_BACKGROUND(TextLayer::OnEraseBackground)
END_EVENT_TABLE()

void TextLayer::OnEraseBackground(wxEraseEvent& event) {}
void TextLayer::OnPaint(wxPaintEvent & evt)
{
    wxAutoBufferedPaintDC  dc(this);
    PrepareDC(dc);

    wxGraphicsContext *gc = wxGraphicsContext::Create( dc );

    if(gc)
    {
        dc.SetFont(GetFont());
        dc.SetTextForeground(GetForegroundColour());
        auto a = GetValue();
        dc.DrawText(GetValue(), 0, 0);
        delete gc;
    }
}

但它不起作用,它不透明,我应该如何正确地做到这一点?

4

1 回答 1

1

抱歉,您将无法使本机控件透明。您可以使用 wxGTK 自定义透明控件(请参阅“擦除”示例),但不能使用本机控件。

于 2016-08-02T08:58:44.787 回答