TCanvas *c1 = nullptr; TRootCanvas *imp = nullptr; void print_sizes(const char *header) { printf("\n%s\n", header); printf("Window size %d x %d\n", c1->GetWindowWidth(), c1->GetWindowHeight()); printf("Window pos %d x %d\n", c1->GetWindowTopX(), c1->GetWindowTopY()); printf("Canvas size %d x %d\n", c1->GetWw(), c1->GetWh()); if (imp) printf("Canvas imp size %d x %d\n", imp->GetCwidth(), imp->GetCheight()); } void realsize() { const int width = 700, height = 700; c1 = new TCanvas("c1", "c1", width, height); imp = dynamic_cast (c1->GetCanvasImp()); print_sizes("Create canvas"); c1->SetWindowSize(width, height); print_sizes(Form("c1->SetWindowSize(%d, %d)", width, height)); c1->SetWindowSize(width + (width - c1->GetWw()), height + (height - c1->GetWh())); print_sizes(Form("c1->SetWindowSize(%d + (%d - c1->GetWw()), %d + (%d - c1->GetWh()))", width, width, height, height)); auto hist = new TH2I("test","test", 50, 0., 50., 50, 0., 50.); for (int i = 0; i < 50; i++) hist->Fill(i, 25, 100); hist->Draw(""); c1->Update(); print_sizes("c1->Update()"); }