# TControlBar - Coordinates Problem

**URL:** <https://root-forum.cern.ch/t/tcontrolbar-coordinates-problem/37725>\
**Category:** Newbie\
**Created:** [January 26, 2020, 11:23pm UTC](https://root-forum.cern.ch/t/tcontrolbar-coordinates-problem/37725 "2020-01-26T23:23:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ilomi](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ilomi/32/21077_2.png) [@ilomi](https://root-forum.cern.ch/u/ilomi)\
**Post date:** [January 26, 2020, 11:23pm UTC](https://root-forum.cern.ch/t/tcontrolbar-coordinates-problem/37725/1 "2020-01-26T23:23:49Z")

</div>

\_ROOT Version: 6.18/04  
\_Platform: Linux Kubuntu  
\_Compiler: VS Code

I can’t set the coordinates of the ControlBar

```auto
{
  Int_t w = 4000;
    Int_t h = 200;

    TControlBar *cb = new TControlBar("vertical", "Initialisation", w, h);

    cb->AddButton("test", "int k = 2; cout << k << endl;", "test");
    cb->AddButton("quit", ".q;", "quit test");

    cb->Show();
}

```

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [January 27, 2020, 9:41am UTC](https://root-forum.cern.ch/t/tcontrolbar-coordinates-problem/37725/2 "2020-01-27T09:41:18Z")

</div>

Add those lines after `cb->Show();`:

```auto
   TRootControlBar *rcb = (TRootControlBar *)cb->GetControlBarImp();
   rcb->Move(1200, 800); // or any x,y values

```

---

<div class="post-metadata">

**Author:** ![ilomi](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ilomi/32/21077_2.png) [@ilomi](https://root-forum.cern.ch/u/ilomi)\
**Post date:** [January 27, 2020, 10:12am UTC](https://root-forum.cern.ch/t/tcontrolbar-coordinates-problem/37725/3 "2020-01-27T10:12:39Z")

</div>

Thank you. It works perfectly.

Can you give me a brief explanation why it didn’t work or how you figured it out (solution).

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [January 27, 2020, 10:20am UTC](https://root-forum.cern.ch/t/tcontrolbar-coordinates-problem/37725/4 "2020-01-27T10:20:42Z")

</div>

`TControlBar` is actually not the window you see on screen. What you see is a `TRootControlBar` (which is what gets returned by `GetControlBarImp()`)

---

<div class="post-metadata">

**Author:** ![ilomi](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ilomi/32/21077_2.png) [@ilomi](https://root-forum.cern.ch/u/ilomi)\
**Post date:** [January 27, 2020, 10:38am UTC](https://root-forum.cern.ch/t/tcontrolbar-coordinates-problem/37725/5 "2020-01-27T10:38:06Z")

</div>

1 more question and done…

For what are than **w** and **h** for in constructor (or just in general Int\_t x, and Int\_t h)

```auto
TControlBar *cb = new TControlBar("vertical", "Initialisation", w, h);

```

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [January 27, 2020, 11:36am UTC](https://root-forum.cern.ch/t/tcontrolbar-coordinates-problem/37725/6 "2020-01-27T11:36:08Z")

</div>

Looking at the [TControlBar class documentation](https://root.cern.ch/doc/master/classTControlBar.html), I would say it should be the initial position of the control bar, multiplied by the screen factor, whatever that means…
