Print Page | Close Window

Pane's OnInitDialog not called

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Docking Pane
Forum Description: Topics Related to Codejock Docking Pane
URL: http://forum.codejock.com/forum_posts.asp?TID=18517
Printed Date: 28 April 2024 at 10:08am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Pane's OnInitDialog not called
Posted By: MichaelN
Subject: Pane's OnInitDialog not called
Date 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



Replies:
Posted By: MichaelN
Date 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


Posted By: MichaelN
Date 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


Posted By: Oleg
Date 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


Posted By: MichaelN
Date 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


Posted By: Oleg
Date Posted: 14 June 2011 at 1:32am
Try create it before you create DockingPanes.

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net