0

在 C++ 应用程序(使用 C++Builder 10.3 和 VCL)中,我使用派生自的自定义类TGraphicControl来绘制自定义用户界面和一小块不断变化的数据。

在 Windows 10 和 Windows 7 中一切正常,但如果我在每次重绘时在远程桌面会话(通过本机 Windows 服务)中执行应用程序,图形就会更加混乱。

问题从消失的元素和错误LineTo的端点开始,但有时元素甚至出现在不同的对话框中。

此外,将 PC 从直接访问切换到远程访问会导致动态插入的 VCLTComboBox元素获取无效的父项和所有者,然后显示TComboBox该类未知的错误消息。

ClientRect在我的代码中使用。这可能是在远程会话中工作时的问题吗?

我看到问题的代码(它有点长,我无法在不省略可能的问题原因的情况下制作一个最小示例)
cpp:https ://pastebin.com/vpk3De7J (第 228 行的画家)
标题:https:// pastebin.com/3pLy4dEY

class CustomTrgDrawings : public TGraphicControl
{
private:
    void __fastcall Paint(void);
public:
    __fastcall CustomTrgDrawings(TComponent* Owner);
    bool updating;      //stops painting when true
}; 

__fastcall CustomTrgDrawings::CustomTrgDrawings(TComponent* Owner)
    : TGraphicControl(Owner)
{
    updating = true;
}

void __fastcall CustomTrgDrawings::Paint(void)
{
    if (!updating)
        return;

    Canvas->Brush->Color = TColor(0x220022);
    Canvas->Brush->Style = bsSolid;
    Canvas->Pen->Color = TColor(0x222222);
    Canvas->Pen->Style = psSolid;
    Canvas->Pen->Width = 1;

    Canvas->FillRect(ClientRect);
}

//---insertion in a vcl form
void __fastcall TMyForm::FormCreate(TObject *Sender)
{
    //uses TLabel *myLabel as container
    CustomTrgDrawings *drg = new CustomTrgDrawings(myLabel);
}
4

0 回答 0