Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - EnableOffice2007Frame OpenGL refresh question
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

EnableOffice2007Frame OpenGL refresh question

 Post Reply Post Reply
Author
Message
Cheerios View Drop Down
Groupie
Groupie


Joined: 19 December 2006
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote Cheerios Quote  Post ReplyReply Direct Link To This Post Topic: EnableOffice2007Frame OpenGL refresh question
    Posted: 05 March 2009 at 11:13am

Product: Xtreme Toolkit (MFC) version 13.0.0
Platform: Windows Vista (64bit) - SP 1 (running CodeJock and program  in 32bit mode)
Language: C++

Hi,

I have created an MDI application with an MFC OpenGL window within each child window.  I am using the Office 2007 frame on the parent window with no problems, but as soon as I call EnableOffice2007Frame on the creation of the child windows, I have issues with the inner window refreshing correctly when moving it around, going between the MDI child windows, etc. (see picture below).  I don't have this problem at all if I don't use the framing on the child windows.  However, for the sake of consistency, I would really like the inner windows to be framed the same way as the parent.  Any ideas?

Thanks!






Back to Top
adrien View Drop Down
Senior Member
Senior Member


Joined: 30 April 2007
Location: New Zealand
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote adrien Quote  Post ReplyReply Direct Link To This Post Posted: 05 March 2009 at 3:30pm
do you create the sub frames within their own thread?
Back to Top
Cheerios View Drop Down
Groupie
Groupie


Joined: 19 December 2006
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote Cheerios Quote  Post ReplyReply Direct Link To This Post Posted: 05 March 2009 at 3:58pm
Hi Adrien,

No, I don't believe so -- at least I didn't explicitly create any new threads.  They are VTK render windows <vtkWin32OpenGLRenderWindow>, if that clarifies things any (http://www.vtk.org/doc/release/5.2/html/a01538.html).

As long as I don't put the Office2007 frames on the child windows, the inner windows render/update correctly, and everything works perfectly.  The  only difference in the code is within the ChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct), the very last line I added: 

EnableOffice2007Frame(this, ((CXTPMDIFrameWnd*)GetParentFrame())->GetCommandBars()->GetPaintManager());


Thanks for your help.
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 07 March 2009 at 4:56am
Do these OpenGL-windows have the WS_CLIPCHILDREN|WS_CLIPSIBLINGS style? If yes, is it possible that your OpenGL surfaces don't handle that style properly? Just a thought.
PokerMemento - http://www.pokermemento.com/
Back to Top
Cheerios View Drop Down
Groupie
Groupie


Joined: 19 December 2006
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote Cheerios Quote  Post ReplyReply Direct Link To This Post Posted: 07 March 2009 at 5:12am
They do have the WS_CLIPSIBLINGS style.  I'll  take a closer look at that. 

Thanks!
Product: Xtreme ToolkitPro 2009 (13.0.0)
Platform: Windows Vista (64bit) - SP 1 (running CodeJock and program in 32bit mode)
Language: Visual C++ 2008
Back to Top
scottp View Drop Down
Groupie
Groupie


Joined: 16 October 2006
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote scottp Quote  Post ReplyReply Direct Link To This Post Posted: 10 March 2009 at 2:27am
This sounds similar to the problem I discovered when using the Tabbed MDI style (with tab group style enabled) and the MDI child windows contained OpenGL windows.

(see thread: https://forum.codejock.com/forum_posts.asp?TID=6997 )

I found that in several places in the code the Codejock decorations drawing was not excluding the client area of the window using dcPaint.ExcludeClipRect  this causes funny things to happen to Vista when using Aero (and DWM).

I still have some problems related to this in 13.0
Back to Top
adrien View Drop Down
Senior Member
Senior Member


Joined: 30 April 2007
Location: New Zealand
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote adrien Quote  Post ReplyReply Direct Link To This Post Posted: 13 March 2009 at 5:05am
I found you need a thread per frame if you want it all to work properly, else onidle processing doesn't happen and you don't get lots of things updating.

I just spawn a new thread and create the window in its initialiser.
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 13 March 2009 at 7:42am
adrien, could you please provide a sample?
PokerMemento - http://www.pokermemento.com/
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 13 March 2009 at 7:45am
PokerMemento - http://www.pokermemento.com/
Back to Top
Cheerios View Drop Down
Groupie
Groupie


Joined: 19 December 2006
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote Cheerios Quote  Post ReplyReply Direct Link To This Post Posted: 13 March 2009 at 10:53am
Hi All,

Thanks so much for all the input.  I had put this on the back-burner for awhile, so I apologize for my lack of response.


znakeeye --

I tried removing the WS_CLIPSIBLING and that didn't seem to make any difference.  I am running Aero on Vista, so I'll take a look at the GdiSetBatchLimit API.  Thanks!


scottp --

I actually saw your thread before posting this problem.  I was hoping that maybe there was a simple setting that I had overlooked.  Your code changes are in my arsenal, though!  Like you, I am using the Tabbed MDI style (I never explicitly enable the grouping style). As I stated above, I am also using Aero on Vista, so your problem could easily be related to mine.  Thanks for the link and insight.


adrien --

I don't have much experience using threads, but I'll look into implementing threading as well.  Like znakeeye, I would love an example!


Thanks again to all of you for your input, suggestions, and (hopefully) solutions.  I'm impressed with your interest and responses!  I'll keep you apprised of my progress.




Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 14 March 2009 at 11:12am
I'm evaluating an OpenGL-crafted component for my software. I found a very interesting setting in this component:
 
"OpenGL context recreation is a feature in all Nevron components forcing the component to recreate the OpenGL context and associated window when the viewable area of the component changes. This is necessary because Windows does not properly resize the OpenGL viewport when the attached window is resized and is at the same time overlapped by another window."
 
"Remarks: Recreates the OpenGL context when the control runs in window mode. This function can be very useful when you run the control in a window or VB form which is resizable or scrollable. Microsoft OpenGL has problems to detect when a certain area of the window is valid and this function helps you to fix unpleasant visual artifacts."
 
If you ask me, this makes sense. Your OpenGL context must be recreated on resize!
PokerMemento - http://www.pokermemento.com/
Back to Top
Cheerios View Drop Down
Groupie
Groupie


Joined: 19 December 2006
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote Cheerios Quote  Post ReplyReply Direct Link To This Post Posted: 14 March 2009 at 3:36pm
Thanks for the information, znakeeye!  I'll have to do a search on OpenGL and Nevron.

I actually get the refresh problem even when I'm not resizing.  In the illustration above, I'm merely going between MDI child windows and moving the windows around.  The problem does happen on resize as well, but not exclusively. 

I also don't have any problems at at all with the OpenGL windows (except when using MDI tabs) unless I try to use the EnableOffice2007Frame() on the inner MDI child windows.  To resolve the problem, I've just been using the default frame on the child windows.  That seems to work well for now.

Thanks for your continued input!  I'll definitely look into the Nevron components.
Product: Xtreme ToolkitPro 2009 (13.0.0)
Platform: Windows Vista (64bit) - SP 1 (running CodeJock and program in 32bit mode)
Language: Visual C++ 2008
Back to Top
adrien View Drop Down
Senior Member
Senior Member


Joined: 30 April 2007
Location: New Zealand
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote adrien Quote  Post ReplyReply Direct Link To This Post Posted: 15 March 2009 at 8:54pm
class CGUIWorker : public CWinThread
{
public:
     CGUIWorker(CMyFrame* pFrame)
     {
          m_pMainWnd = pFrame;
     }
     virtual BOOL InitInstance()
     {
          OleInitialize(NULL);
          ((CMyFrame*)m_pMainWnd)->Create(NULL, "Some name", WS_OVERLAPPEDWINDOW | WS_VISIBLE);
          // bring new frame to foreground
          m_pMainWnd->SetForegroundWindow();
          return TRUE;
     }
     virtual int ExitInstance()
     {
          return 0;
     }
     DECLARE_MESSAGE_MAP()
};

BEGIN_MESSAGE_MAP(CGUIWorker, CWinThread)
END_MESSAGE_MAP()

to spawn a window you then do something like

CGUIWorker* pWorker = new CGUIWorker(new CMyFrame());
pWorker->CreateThread();

you'll need to change the call to Create in InitInstance to whatever kind of create you want.

You will also need to implement a PostNCDestroy func in your frame class...

void CMyFrame::PostNcDestroy( )
{
     // tell the thread that created this frame to terminate
     ::PostThreadMessage(::GetCurrentThreadId(), WM_QUIT, 0, 0);

     CXTPFrameWnd::PostNcDestroy();
}





Back to Top
Cheerios View Drop Down
Groupie
Groupie


Joined: 19 December 2006
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote Cheerios Quote  Post ReplyReply Direct Link To This Post Posted: 16 March 2009 at 9:37am
Thanks a ton, adrien!  This will be a huge help.  I'll let you know how it goes.  It will be a few days until I can get to it, though.

Thanks again!
Product: Xtreme ToolkitPro 2009 (13.0.0)
Platform: Windows Vista (64bit) - SP 1 (running CodeJock and program in 32bit mode)
Language: Visual C++ 2008
Back to Top
Cheerios View Drop Down
Groupie
Groupie


Joined: 19 December 2006
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote Cheerios Quote  Post ReplyReply Direct Link To This Post Posted: 10 May 2009 at 9:15am
Hi again adrien,

I'm just now having the time to implement the threading code that you provided earlier.  I have one question, though.  Do I spawn off a new thread in the initialization of each MDI child frame or in the init of each actual OpenGL window within that frame?

Thanks for your continued help!


Product: Xtreme ToolkitPro 2009 (13.0.0)
Platform: Windows Vista (64bit) - SP 1 (running CodeJock and program in 32bit mode)
Language: Visual C++ 2008
Back to Top
adrien View Drop Down
Senior Member
Senior Member


Joined: 30 April 2007
Location: New Zealand
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote adrien Quote  Post ReplyReply Direct Link To This Post Posted: 11 May 2009 at 9:19pm
the thread needs to be spawned before any created window.

The thread you spawn has to create the window inside itself.

InitInstance is called in the context of the new thread. So you can see from the sample code, the create call is done inside that. You just need to provide enough information to the thread to enable it to create the window / frame you want.
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 07 May 2010 at 2:55pm
Hmm, I actually ran into this issue today. Did you find a final solution to it?
 
I have an OpenGL window with hardware acceleration turned off (not sure what that means since I'm using a 3rd party component here), and then I open up a modal dialog. If I move around this dialog, the underlying OpenGL window looks just like the screenshot posted by Cheerios. The problem goes away after explicitly resizing the whole window. Tried all possible "redraw tricks", but none helped. Only resizing the window...
 
So sick!
PokerMemento - http://www.pokermemento.com/
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 07 May 2010 at 3:08pm
Cheerios, I really don't see why one would want a worker thread here. It's just weird.
 
I think I understand what needs to be done. When the docking pane is resized, and hence the OpenGL HWND, then you must recreate the OpenGL context!
PokerMemento - http://www.pokermemento.com/
Back to Top
Cheerios View Drop Down
Groupie
Groupie


Joined: 19 December 2006
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote Cheerios Quote  Post ReplyReply Direct Link To This Post Posted: 07 May 2010 at 4:26pm
Hi znakeeye,

I had basically given up on this problem, hoping that it was something that Codejock would be able to fix in future releases.  I'm using a third party component as well; in fact, we may actually be using the same one.  Can you explain what you mean by "recreate the OpenGL context" or provide an example of doing that?

Thanks!


Product: Xtreme ToolkitPro 2009 (13.0.0)
Platform: Windows Vista (64bit) - SP 1 (running CodeJock and program in 32bit mode)
Language: Visual C++ 2008
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2010 at 6:51am
Cheerios, I PMed you about this.
PokerMemento - http://www.pokermemento.com/
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.093 seconds.