Using ROOT 5.32 standalone with VS2008 and saving canvas as image

OK, sorry, I overlooked it…

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

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

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.

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

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

and

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.

1 Like