Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Docking Pane
  New Posts New Posts RSS Feed - Pane's OnInitDialog not called
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Pane's OnInitDialog not called

 Post Reply Post Reply
Author
Message
MichaelN View Drop Down
Senior Member
Senior Member


Joined: 19 September 2006
Status: Offline
Points: 112
Post Options Post Options   Thanks (0) Thanks(0)   Quote MichaelN Quote  Post ReplyReply Direct Link To This Post Topic: Pane's OnInitDialog not called
    Posted: 08 June 2011 at 1:25pm
I'll start by saying I've been using panes for some time for a lot of other things and they work fine. But I can't make this one work and I can't figure out the initialization sequence for it.
 
The pane uses a dialog that has a CEdit control that the app sends text strings to. The app starts with this pane docked to the side of the mainframe. Strings may be sent with or without the pane open, and the app sends some strings to it before the pane is opened the first time.  Then, when I open the pane the first time, the app crashes. I can see that the dialog's OnInitDialog() was not called and the DDX was never called to attach a window to the edit control.
 
What I did to initialize: At the end of the mainframe's OnCreate(), the pane's dialog object was created and pane->Create(IDD,this) was called. The first message fired inside CMainFrame::OnDockingPaneNotify() is xtpPaneActionExpanding. Inside that case,  pane->IsValid() returns FALSE. Therefore, I call pane->Attach(m_pPaneTextEditor) and it crashes. As I said, the dialog's OnInitDialog() was never called and the window handles are 0.
 
Where/how can I make this work in the pane opening sequence?
 
Thanks,
 
Michael
Back to Top
MichaelN View Drop Down
Senior Member
Senior Member


Joined: 19 September 2006
Status: Offline
Points: 112
Post Options Post Options   Thanks (0) Thanks(0)   Quote MichaelN Quote  Post ReplyReply Direct Link To This Post Posted: 08 June 2011 at 6:39pm
There's Progress, but there still is a glitch.  I was able to prevent the crash by inserting the following code into CMainFrame::OnDockingPaneNotify()
 

(m_pPaneTextEditor is a dialog)
case XTP_DPN_SHOWWINDOW:
{
  CXTPDockingPane* pPane = (CXTPDockingPane*)lParam;
  if ( pPane )
  {
  switch ( pPane->GetID() )
  {
    case IDR_PANE_TEXT_EDITOR:
      if ( ! pPane->IsValid() )
      {
        if ( ! ::IsWindow( m_pPaneTextEditor->GetSafeHwnd() ) )    // added
          m_pPaneTextEditor->Create(IDD_PANE_TEXT_EDITOR, this);
        pPane->Attach(m_pPaneTextEditor);
      }
      break;
    }
    return TRUE;
 
After this change, I can open the pane without a crash. Remember that the app opens with this pane closed on the right main frame border. Text is written into its CEdit control before the pane is ever opened. After I open it the first time, it does not auto-hide. When I move the mouse off the pane, it does not snap shut. I fact, there's no way I can make it hide unless I pin and then unpin it.
 
On the other hand, if I open a document before opening the pane the first time, then the pane auto-hides as expected. But if I close the document before opening the pane the first time, the pane does not auto-hide. In other words, a document must be open when I open the pane the first time in order to have it auto-hide when it closes the first time.
 
After the pane closes once, it auto-hides correctly in the future.
 
Any thoughts?
 
Michael
Back to Top
MichaelN View Drop Down
Senior Member
Senior Member


Joined: 19 September 2006
Status: Offline
Points: 112
Post Options Post Options   Thanks (0) Thanks(0)   Quote MichaelN Quote  Post ReplyReply Direct Link To This Post Posted: 08 June 2011 at 7:50pm
I forgot to mention a couple of things:
 
Identical code works as expected when the docking pane is attached to an MDI child frame instead of the MainFrame window.
 
Using ToolkitPro 13.4.2 DLL with x64 debug.
 
Michael
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 09 June 2011 at 7:42am
If you need this dialog before user open pane you can create it directly in CMainFrame::OnCreate and only attach here.


Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
MichaelN View Drop Down
Senior Member
Senior Member


Joined: 19 September 2006
Status: Offline
Points: 112
Post Options Post Options   Thanks (0) Thanks(0)   Quote MichaelN Quote  Post ReplyReply Direct Link To This Post Posted: 13 June 2011 at 6:09pm
Hi Oleg,
 
That is exactly what I already do, create panes at the end of the main frame's OnCreate(). The pane crashes because the pane dialog's window handle is 0 when OnDockingPaneNotify is called. I found that the dialog template fails in CheckDialogTemplate(lpszTemplateName, FALSE)  inside  CDialog::Create(LPCTSTR lpszTemplateName, CWnd* pParentWnd).
 
However, using identical pane code and creation code, everything works as expected when created on a CMDIChildWnd. I wonder if the mainframe is interfering with pane creation? My main frame is derived from two of your classes, like this:

class CMainFrame : public CXTPMDIFrameWnd, CXTPOffice2007FrameHook

Are you sure they don't interfere with pane creation?
 
Michael
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 14 June 2011 at 1:32am
Try create it before you create DockingPanes.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
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.188 seconds.