clipping GeUserArea on parent GeDialog [CLOSED]

On 17/02/2015 at 05:42, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   R13.061 
Platform:   Windows  ;   
Language(s) :     C++  ;

Hi to all,

I'm using a GeUserArea to render some OpenGL content into. The parent of the GeUserArea is a GeDialog.
When I scroll the GeUserArea in the GeDialog the user area overdraws other dialogs. 
So I want to clip the UserArea on the borders of its parent GeDialog.

Is this possible?
If not, is it possible to just scroll the User Area?

Thanks so far!

On 17/02/2015 at 06:22, xxxxxxxx wrote:


I have to admit, I do not understand exactly, what you are trying to do or what is happening. Sorry 😢

Somehow your description reminds me a bit of another thread (see here). Maybe you can look into it and see, if your problem is similar.

If not, please try to describe your situation in a bit more detail. At best with some code snippets.

On 18/02/2015 at 02:50, xxxxxxxx wrote:

Hi Andreas,

thanks for your help.
The issue you found is exacly the same issue posted by my colleague.
See the following 2 pics:

Nr 1.:


Nr1 shows how it should be. No overdraw. Nr 2 shows the error. What I want to do is to clip the user area at the parent dialog's borders to remove the graphical error.

If there is any other way to draw openGL content and clip it (instead of user area) I'm all ears.
Thanks in advance.

On 18/02/2015 at 02:59, xxxxxxxx wrote:

uups, uploading pics not possible...

On 18/02/2015 at 04:51, xxxxxxxx wrote:

I didn't see the images so I can't judge, but try these 2 lines in the start of GeUserArea::DrawMsg() virtual function:


On 18/02/2015 at 05:43, xxxxxxxx wrote:

Thanks, Mohamed, but didn't work.
I had a closer look at the code and think the issue is not related  to the user area.
We create a child hwnd from a GeDialog via WinApi's CreateWindowEx() and this window is not clipped out of the dialogs client area  if it is repositioned via WinApi's MoveWindow() function. It just draws over other C4D gui- elements.
Any ideas?

On 18/02/2015 at 10:44, xxxxxxxx wrote:

ok, i know more about the issue right now.
- We use a HWND to render OpenGL into.
- this HWND is created via CreateWindowEx()
- it's parent HWND (lets call it pHWND) is derived via iCustomGui::GetWindowHandle()
--the problem:  pHWND is not a HWND from some window in the attribute manager, it is the C4D- Mainwindow.

So to solve that:

- how can I obtain a hwnd from the attribute manager to use as pHWND?

On 18/02/2015 at 10:46, xxxxxxxx wrote:

I'm sorry, but as far as I know, you can't. 😢

On 18/02/2015 at 11:41, xxxxxxxx wrote:

I think the best approach is render this OpenGL with Cinema4D classes "C4DGL" , it is difficult to do, but it is doable

On 19/02/2015 at 02:19, xxxxxxxx wrote:

Could you point me somewhere?
I couldn't find anything by Google/Maxon documentation

Perhaps C4D dialog system can also do the trick. Basically i need the hwnd only for 2 things:

1.) parent-child relationship to obtain clipping of child window on parent windows borders. This is obviously done in C4D with other dialogs.

2.) Obtaining a HDC (HDC h= GetDC( hWnd );) for OpenGL rendering.

I don't know where to look in the documentation to get an idea, probably you know better...

On 19/02/2015 at 02:48, xxxxxxxx wrote:

it depends on what you are drawing with OpenGL, you need to specify more.
in general the SDK got "as I remember" 4 examples,  gl_test_object, gl_material, vpstereo, and another example which I don't remember its name, 1 of them is using vertex buffer object, others are using frame buffer object.

the documentation is limited "no docs!!" , so just reading the header with OpenGL experience and deep C++ experience should let you get your feet wet.

I played with gl_test_object example, and "hacked" the OpenGL VBO "from CUDA context" as Cinema4D doesn't give the VBO handle!!, so it was some fun time doing it , here is the result:

On 19/02/2015 at 03:57, xxxxxxxx wrote:

@Mohamed: cool demo!

On 23/02/2015 at 02:32, xxxxxxxx wrote:

ok, after fumbling around forever with windows and clipping, i worked around the issue. Isn't perfect, but works ok. What i did:
I create a hwnd of a smaller size so i don't get a vertical scrollbar (which messes up the win-coords you get over GeUserArea::DrawMsg().
I don't move the window, so clipping is not necessary. Instead i listen to GeUserArea::InputEvent() and catch the mouse wheel (seems to be the only input you can get in that function). I use this data to transform the view in Open GL only, so the window i create doesn't move.