# Using ROOT 5.32 standalone with VS2008 and saving canvas as image

**URL:** <https://root-forum.cern.ch/t/using-root-5-32-standalone-with-vs2008-and-saving-canvas-as-image/34548>\
**Category:** Newbie\
**Created:** [June 12, 2019, 7:43am UTC](https://root-forum.cern.ch/t/using-root-5-32-standalone-with-vs2008-and-saving-canvas-as-image/34548 "2019-06-12T07:43:43Z")\
**Posts on this page:** 5\
**Page:** 2

<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:** [June 12, 2019, 10:45am UTC](https://root-forum.cern.ch/t/using-root-5-32-standalone-with-vs2008-and-saving-canvas-as-image/34548/21 "2019-06-12T10:45:03Z")

</div>

OK, sorry, I overlooked it…

---

<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:** [June 12, 2019, 10:46am UTC](https://root-forum.cern.ch/t/using-root-5-32-standalone-with-vs2008-and-saving-canvas-as-image/34548/22 "2019-06-12T10:46:04Z")

</div>

Note that you can also build everything in debug mode an try to figure out what’s happening…

---

<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:** [June 12, 2019, 10:48am UTC](https://root-forum.cern.ch/t/using-root-5-32-standalone-with-vs2008-and-saving-canvas-as-image/34548/23 "2019-06-12T10:48:12Z")

</div>

And see also:  
[https://root.cern.ch/how/how-embed-tcanvas-external-applications](https://root.cern.ch/how/how-embed-tcanvas-external-applications)

---

<div class="post-metadata">

**Author:** ![JMed](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/e5b9ba/32.png) [@JMed](https://root-forum.cern.ch/u/JMed)\
**Post date:** [June 14, 2019, 9:16am UTC](https://root-forum.cern.ch/t/using-root-5-32-standalone-with-vs2008-and-saving-canvas-as-image/34548/24 "2019-06-14T09:16:38Z")

</div>

Sry, I was not allowed to reply due to being a new user. Needed to wait 23h and I did some more tests since then.

The last link looks exactly what I was looking for, thanks! I implemented it, but it still is not working correctly. In the meantime I checked out the latest 5.34 branch, which is is a lot newer than the last tagged version I could find (5.32). Now at least I got my env vars and ROOTSYS is being used.

I had a bit trouble with the new lz4 support, because the defines for c99 check are wrong and thus it fails to compile with vs2008, but I could fix it.

I use both the debug and release builds for testing. Current state is, that in debug it crashes when doing gTws = &fWindows[wid] in TGWin32::SetDoubleBuffer, because wid has default debug (0xcdcdcdcd) value. I use gVirtualX-\>AddWindow((ULong\_t)wnd, width, height) as described in the link and it also returns this value for the id. In release mode it doesn’t crash and the id value is zero, but I don’t get an image either.

I will try RelWithDebInfo and dig some further. Thanks for you help so far.

---

<div class="post-metadata">

**Author:** ![JMed](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/e5b9ba/32.png) [@JMed](https://root-forum.cern.ch/u/JMed)\
**Post date:** [July 5, 2019, 1:52pm UTC](https://root-forum.cern.ch/t/using-root-5-32-standalone-with-vs2008-and-saving-canvas-as-image/34548/25 "2019-07-05T13:52:04Z")

</div>

I was able to pinpoint the issue. Long story short, don’t use the tagged version from Github as I did at the beginning. Use the latest trunk, or 5.34 when it is tagged (that part I already wrote above).

The second problem is, that you can not use different threads for

```auto
TApplication *gMyRootApp = new TApplication("My ROOT Application", 0, 0);

```

and

```auto
int wid = gVirtualX->AddWindow((ULong_t)hWnd, width, height);

```

If you do, you will get an invalid window ID. Both have to be executed in the same thread, even though there is a mechanism for thread handling in AddWindow. This probably is a bug. I am using the same thread now and got it working. Even image saving works.

[Previous page](https://root-forum.cern.ch/t/using-root-5-32-standalone-with-vs2008-and-saving-canvas-as-image/34548.md?page=1)
