How to add vertical or horizontal scroll on the TGCanvas?

Hi rooters,

I want to add scroll on the TGEmbeddedCanvas? Thanks in advance.

Xiaodong

Hi Xiaodong,

Here is an example:

// add a canvas widget with a viewport and scroll bars to the main window fGCanvas = new TGCanvas(this, 600, 400); AddFrame(fGCanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 2, 2, 0, 2)); // composite frame (i.e. container) for embedded canvas fContainer = new TGCompositeFrame(fGCanvas->GetViewPort()); fGCanvas->SetContainer(fContainer); // create embedded canvas and place into the container fCanvas = new TRootEmbeddedCanvas("Canvas", fContainer, 1000, 1000); fContainer->AddFrame(fCanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
Cheers, Bertrand.

Hi Bertrand,

It works, Thanks for your help.

Best regards,

Xiaodong

Hi Xiaodong,

You’re welcome :slight_smile:

Cheers, Bertrand.